Option Explicit
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Const SWP_NOSIZE = &H1 Private Const SWP_NOMOVE = &H2 Private Const HWND_TOPMOST = -1 Private Const HWND_NOTOPMOST = -2
Private Sub Check1_Click() If Check1.Value = 1 Then Picture1.FontBold = True Else Picture1.FontBold = False End If End Sub
Private Sub Check2_Click() If Check2.Value = 1 Then Picture1.FontItalic = True Else Picture1.FontItalic = False End If End Sub
Private Sub Check3_Click() If Check3.Value = 1 Then SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Else SetWindowPos Me.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE End If End Sub
Private Sub Command1_Click() On Error Resume Next Dim TxtWidth As Integer, TxtHeight As Integer Dim TxtColor As Long Dim i As Integer, j As Integer Dim tempStr As String Me.MousePointer = 11 With Picture1 If Not IsNumeric(Combo2.Text) Then MsgBox "字体大小错误!", vbInformation, "提示" Exit Sub Else .FontSize = Val(Combo2.Text) End If .Cls .AutoRedraw = True .FontName = Combo1.Text Picture1.Print Text1.Text TxtWidth = .TextWidth(Text1.Text) TxtHeight = .TextHeight(Text1.Text) End With Text2.Text = "" tempStr = "" For i = 0 To TxtHeight - 1 For j = 0 To TxtWidth - 1 TxtColor = GetPixel(Picture1.hdc, j, i) If TxtColor <> Picture1.BackColor Then tempStr = tempStr & Combo3.Text Else tempStr = tempStr & Combo4.Text End If Next tempStr = tempStr & vbCrLf Next Text2.Text = tempStr Me.MousePointer = 0 End Sub
Private Sub Command2_Click() Clipboard.Clear Clipboard.SetText Text2.Text End Sub
Private Sub Command3_Click() Unload Me End Sub
Private Sub Form_Load() On Error Resume Next Dim i As Integer Dim Str As String Picture1.BackColor = vbWhite Picture1.ForeColor = vbBlack For i = 0 To Screen.FontCount - 1 Combo1.AddItem Screen.Fonts(i) Next Combo1.Text = "宋体" Combo2.AddItem 9 Combo2.AddItem 10 Combo2.AddItem 12 Combo2.AddItem 15 Str = "§№☆★○●◎◇◆□■△▲※→←↑↓〓$£¥·?‖~《》「」『』〖〗【】 " For i = 1 To Len(Str) Combo3.AddItem Mid(Str, i, 1) Combo4.AddItem Mid(Str, i, 1) Next Combo3.Text = "★" Combo4.Text = " " Randomize End Sub
Private Sub Form_Resize() If Me.WindowState = 0 Then Me.Width = 6750 Me.Height = 6000 ElseIf Me.WindowState = 1 Then sysTrayOcx1.AddToTray Me Me.Hide End If End Sub
Private Sub sysTrayOcx1_DblClick(Button As Integer) Me.WindowState = 0 Me.Visible = True sysTrayOcx1.RemoveFromTray End Sub
Private Sub Timer1_Timer() Label9.Left = Label9.Left - 30 Label9.ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255) If Label9.Left < -Label9.Width Then Label9.Left = 3165 End If End Sub