-
Hi...
Look, i try to do a little prog that just print a random pixels on the desktop and i have a little problem...
this is the code:
Code:
'Module
Public Declare Function SetPixel Lib "gdi32.dll" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
Public Declare Function GetDesktopWindow Lib "user32" () As Long
Public Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Code:
'This the Code...
Private Sub Command1_Click()
Dim DC As Long
'Get the DC
DC = GetWindowDC(GetDesktopWindow)
Randomize Timer
Timer1.Enabled = True
SetPixel DC, 100, 100, 200 'This is work just fine...
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
SetPixel DC, 100, 100, 200 'This, the same line!
SetPixel DC, Rnd * 100,Rnd * 100, 200 '& This !!!Dont Work!!!
End Sub
This is the problem, the function don't work in the timer sub...
WHY ???
if you can help me... THANKS!
-
Just put this into your timer
Code:
Dim DC As Long
'Get the DC
DC = GetWindowDC(GetDesktopWindow)
SetPixel DC, 100 * Rnd, 100 * Rnd, 255
(Should always get the DC again ;))
-
Did you set the timer1.interval = a number? It won't work if you don't do this.
-
Is your Timer Enabled? Did you set a valid Interval for it?
-
Thanks Fox !!!
but there is another way, easy one...
just dim the dc in the start of code and then it public and no private.
i didn't see it before!
thanks again!
-
Sorry to disappoint you but the pixels wont stay there, if you put another window over it it will erase them. If anyone knows how to make them persistent, i would be glad to know
-
The only way it prolly to store them in your own DC and copy it to the desktop every time... and backup the pixels behind... Yeah, I know the problem :(
-
it's ok i get what i want...
it's dont bother me that you can delete them...
;) ;) ;) ;) ;) ;)
[Edited by TalZ on 06-27-2000 at 04:24 AM]
-