Results 1 to 7 of 7

Thread: Screensaver + Preview Window

  1. #1
    anoop007
    Guest

    Screensaver + Preview Window

    Code:
            GetClientRect GetHwndFromCmd(cmd), SDim
            
            Style = GetWindowLong(Form2.hwnd, GWL_STYLE) ' ** Get current window style
            Style = Style Or WS_CHILD                        ' ** Append "WS_CHILD" style To the hWnd window style
            SetWindowLong Form2.hwnd, GWL_STYLE, Style   ' ** Add New style To window
            SetParent Form2.hwnd, GetHwndFromCmd(cmd)   ' ** Set preview window As parent window
            SetWindowLong Form2.hwnd, GWL_HWNDPARENT, GetHwndFromCmd(cmd) ' ** Save the hWnd Parent In hWnd's window struct.
                    
            SetWindowPos Form2.hwnd, HWND_TOP, 0&, 0&, SDim.Right, SDim.Bottom, SWP_SHOWWINDOW
    This code does show the screensaver in the small preview box in display properties.. but it does not scale the form.. How can I achieve this?

    Also can i draw directly into the preview box..?

    GetDC(GetHwndFromCmd) doesn't seem to be working!

  2. #2
    Hyperactive Member
    Join Date
    May 2001
    Location
    Beirut, Lebanon
    Posts
    318
    Hello there,

    For zooming, you might want to try multiplying all your numbers by the ratio ScreenWidth/PreviewScreenWidth when displaying in the preview window (/c), and by 1 when displaying on the screen (/s).

  3. #3
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    This is a slightly modified version of the code found on vbworld
    Code:
    Public Sub DoPreviewMode()
            
        'get the handle for the preview area
        dispHWND = CLng(Right$(Command$, Len(Command$) - 3))
        'load the preview window independently, but do not show it
        Load frmPreview
        
        'get the size of the preview area
        GetClientRect dispHWND, DispRec
        
        'set the preview window according to the size of the preview area
        SetWindowPos frmPreview.hwnd, HWND_TOP, 0&, 0&, _
        DispRec.Right, DispRec.Bottom, _
        SWP_NOZORDER Or SWP_NOACTIVATE Or SWP_HIDEWINDOW
        
        'set the preview window as child window
        style = GetWindowLong(frmPreview.hwnd, GWL_STYLE)
        style = style Or WS_CHILD ' Append "WS_CHILD"
        SetWindowLong frmPreview.hwnd, GWL_STYLE, style
        SetParent frmPreview.hwnd, dispHWND
        SetWindowLong frmPreview.hwnd, GWL_HWNDPARENT, dispHWND
        'show the form
        frmPreview.Show
    
    End Sub
    This code is working fine for me. It sizes the form according
    to the preview area. I don't think you can draw directly into
    the preview area as its most probably a mdi window.

    Gush, Preview window command line switch is "/p". "/c" is for
    configuration settings.

  4. #4
    anoop007
    Guest
    Thanks

  5. #5
    anoop007
    Guest
    No.. but form is still not scaled!!

  6. #6
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    The form does not gets scaled. A portion of the form equal to
    the size of the preview window is taken starting from the top left
    of your form. There is no automatic scaling of the form. If you are
    drawing onto the form, draw on the form after you have sized
    according to the preview area.

  7. #7
    anoop007
    Guest
    ok.. thanks for the idea.. didn't think about it b4

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