|
-
Jun 26th, 2000, 01:54 AM
#1
Thread Starter
Junior Member
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!
-
Jun 26th, 2000, 02:10 AM
#2
PowerPoster
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 )
-
Jun 26th, 2000, 02:10 AM
#3
Hyperactive Member
Did you set the timer1.interval = a number? It won't work if you don't do this.
-
Jun 26th, 2000, 02:11 AM
#4
Is your Timer Enabled? Did you set a valid Interval for it?
-
Jun 26th, 2000, 02:34 AM
#5
Thread Starter
Junior Member
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!
-
Jun 26th, 2000, 05:44 AM
#6
transcendental analytic
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
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 26th, 2000, 11:33 AM
#7
PowerPoster
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
-
Jun 26th, 2000, 03:21 PM
#8
Thread Starter
Junior Member
-
Jun 27th, 2000, 12:53 AM
#9
PowerPoster
Kedaman cares
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|