I'm using from Karl Moore's screensaver tutorial:
http://www.vb-world.net/graphics/scr...er/index4.html
How do I know the size of the preview window so I can resize my form at load to fit it?
Printable View
I'm using from Karl Moore's screensaver tutorial:
http://www.vb-world.net/graphics/scr...er/index4.html
How do I know the size of the preview window so I can resize my form at load to fit it?
When the OS calls the Screensaver in the preview mode, it also supplies the handle to the display area where the preview is to be run. You have to use this handle to know the size of the preview area. I have explained in comments further
Code:Public Sub DoPreviewMode(PreviewForm As Form)
Dim lngStyle As Long, dispHWND As Long, DispRec As RECT
'get the handle from the command line
dispHWND = CLng(Right(Command, Len(Command) - 3))
Load PreviewForm
'get the display area size and co-ordinates
GetClientRect dispHWND, DispRec
'set your window as a child window in the next few lines
lngStyle = GetWindowLong(PreviewForm.hwnd, GWL_STYLE)
lngStyle = lngStyle Or WS_CHILD 'Append "WS_CHILD"
SetWindowLong PreviewForm.hwnd, GWL_STYLE, lngStyle
SetParent PreviewForm.hwnd, dispHWND
SetWindowLong PreviewForm.hwnd, GWL_HWNDPARENT, dispHWND
'resize your window according to the preview area
SetWindowPos PreviewForm.hwnd, HWND_TOP, 0&, 0&, _
DispRec.Right, DispRec.Bottom, _
SWP_NOZORDER Or SWP_NOACTIVATE Or SWP_SHOWWINDOW
End Sub
Nope, that's the exact code I'm using that doesn't size it right. Unless I check for preview mode at form load and do something like me.height = 2500, me.width = 2500, what shows in the preview window is the upper left corner of the form as it would be scaled to full screen.
hy,
could anyone post a demonstration... (vbp projekt)
of an screensafen for me ...
i try to create one, but i dont't get it ... also with the tutorial here
i hope sb has one 4 me ??
THX Longbow
P;) U:p T:cool: T:D I:) N:eek: G:rolleyes: :rolleyes: O:p N:cool: :cool: T:( O:mad: P
cu:confused: :confused: :confused: :confused: :eek: :eek: :cool: :cool: :rolleyes: ;)
JoshT
It will never size the form. It will just cut the form starting from left top to the required size. You will have to do the sizing programatically.
[DBH]Longbow
What exactly don't you understand? I have an example but it has become quite complicated. If you could clarify, I might be able to help you.
That's what I'm trying to do, but I don't know what size to size it to.Quote:
It will never size the form. It will just cut the form starting from left top to the required size. You will have to do the sizing programatically.
This should return you the height and width in pixels:
Code:YourForm.Width = DispRec.Right - DispRec.Left
YourForm.Height = DispRec.Bottom - DispRec.Top
Okay, thanks, that makes sense, I'll try it tonight.