|
-
Nov 17th, 1999, 05:48 AM
#1
Thread Starter
Hyperactive Member
Ok, I'm making a screen saver, and one of the things it does to work is get the shapes of all the parent forms on the screen. I have a nice, accurate code, however I was just wondering if anyone knew how to speed it up a little or maybe know of a faster code. Thanks to any help anyone can give. Even if you don't know, tell me, cus I atleast want to know someone looked at this!
Code:
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function SetPixelV Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
'--------------------------------------------
For i = 0 To (Screen.Width / Screen.TwipsPerPixelX) 'Beginning to end of the screen's width
For j = 0 To (Screen.Height / Screen.TwipsPerPixelY) 'Beginning to end of the screen's height
If GetParent(WindowFromPoint(i, j)) = 0 And WindowFromPoint(i, j) <> WindowFromPoint(i, 0) Then SetPixelV picture1.hdc, i, j, vbWhite ' If the window from the point has no parent, and it is not at the top of the screen or higher, then draw a pixel on Picture1.
Next j
Next i
This basically draws a mask of all the windows on the screen into 'Picture1' (A picturebox). However, it's pretty slow, especially with larger screen resolutions. Now I know I can use the GetWindowRect to get a window's rectangle alltogether, but that won't get me uniquely shaped windows, plus it will still have to keep scanning the screen.
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
|