Results 1 to 9 of 9

Thread: Screen Saver Preview Size

  1. #1

    Thread Starter
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032

    Screen Saver Preview Size

    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?
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  2. #2
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    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

  3. #3

    Thread Starter
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    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.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  4. #4
    Addicted Member
    Join Date
    Jul 2001
    Location
    Germany, BW
    Posts
    157

    Question Screensafer - demonstration ??

    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
    Old enough to know better,
    but young enough to don't give a ****!

  5. #5
    Addicted Member
    Join Date
    Jul 2001
    Location
    Germany, BW
    Posts
    157

    Wink putting on top

    P U T T I N G O N T O P


    cu
    Old enough to know better,
    but young enough to don't give a ****!

  6. #6
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    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.

  7. #7

    Thread Starter
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    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.
    That's what I'm trying to do, but I don't know what size to size it to.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  8. #8
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    This should return you the height and width in pixels:
    Code:
    YourForm.Width = DispRec.Right - DispRec.Left
    YourForm.Height = DispRec.Bottom - DispRec.Top

  9. #9

    Thread Starter
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Okay, thanks, that makes sense, I'll try it tonight.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width