VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



writing on the desktop

by Harini Srinivasan (1 Submission)
Category: Windows API Call/Explanation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 24th January 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

writing on the desktop

API Declarations


Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd 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 Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long

Rate writing on the desktop



Form1.Show
End Sub

Private Sub Timer1_Timer()
Dim dc As Long
Form1.WindowState = vbMinimized
dc = GetWindowDC(GetWindow(GetDesktopWindow(), 1))
a = TextOut(dc, Rnd * 600, Rnd * 400, "HAI MANI!", 8)
Randomize
x = Rnd * 600
y = Rnd * 400
Randomize
X1 = Rnd * 600
Y1 = Rnd * 400
a = SetPixel(dc, X1, Y1, RGB(10, 20, 30))
'For i = 1 To 100
 'For j = 1 To 100
'   a = GetPixel(dc, x + i, y + j)
 '  a = SetPixel(dc, X1 + i, Y1 + j, a)
    a = LineTo(dc, x, y)
 'Next j
'Next i

End Sub


Download this snippet    Add to My Saved Code

writing on the desktop Comments

No comments have been posted about writing on the desktop. Why not be the first to post a comment about writing on the desktop.

Post your comment

Subject:
Message:
0/1000 characters