Третий раз выкладую этот исходник! Блин как же нам всем поиска нехватает!
Ну вот:
Private Declare Function BeginPath Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function EndPath Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function PathToRegion Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" _
(ByVal hWnd As Long, ByVal hRgn As Long, _
ByVal bRedraw As Boolean) As Long
Dim mMove As Boolean
Dim SX As Integer
Dim SY As Integer
Private Sub Form_Load()
Beep
Const TEXT = "Привет, я вирус"
Dim hRgn As Long
Font.Name = "Times New Roman"
Font.Bold = True
Font.Size = 70
Width = TextWidth(TEXT)
Height = TextHeight(TEXT)
BeginPath hdc
Print TEXT
EndPath hdc
hRgn = PathToRegion(hdc)
SetWindowRgn hWnd, hRgn, False
Move (Screen.Width - Width) / 2, (Screen.Height - Height) / 2
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift _
As Integer, X As Single, Y As Single)
mMove = True
SX = X
SY = Y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift _
As Integer, X As Single, Y As Single)
If mMove = True Then
Me.Move Left + X - SX, Top + Y - SY
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift _
As Integer, X As Single, Y As Single)
mMove = False
End Sub
Private Declare Function CreateDCAsNull Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, lpDeviceName As Any, lpOutput As Any, lpInitData As Any) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function DrawText Lib "user32" Alias "rawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
Private Declare Function GetTextColor Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function SetTextColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As Long
Public Sub TestDesktopDC()
Dim hdc As Long
Dim tR As RECT
Dim lCol As Long
hdc = CreateDCAsNull("ISPLAY", ByVal 0&, ByVal 0&, ByVal 0&
tR.Left = 60
tR.Top = 0
tR.Right = 640
tR.Bottom = 32
lCol = GetTextColor(hdc)
SetTextColor hdc, &HFF&
DrawText hdc, "vbAccelerator", Len("vbAccelerator", tR, 0
SetTextColor hdc, lCol
DeleteDC hdc
End Sub
Private Sub Command1_Click()
TestDesktopDC
End Sub
Это, как я понял пример который не понравился, но ведь можно как нарисовал, так и убрать, необязательно смотреть на него постоянно. А с формой - будет коряво.