CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 1999
    Location
    Israel
    Posts
    140

    Maximize form HELP..

    I don't want the form to be displayed on all the screen width when it is maximized by the user ? can i do it? How?


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Maximize form HELP..

    I can think of 2 ways to do it:
    1. the ugly way: trap the Form_Resize event

    private Sub Form_Resize()
    If WindowState = vbMaximized then
    me.WindowState = vbNormal
    me.Height = 800
    End If
    End Sub



    ugly, because it causes flickering effect

    2. the nice way: use subclassing and trap the WM_GETMINMAXINFO message -> no flicker, but more work


  3. #3
    Join Date
    Jul 1999
    Location
    Israel
    Posts
    140

    Re: Maximize form HELP..

    Thank you!! I am a beginner - can you tell me more about the second option
    Tanks
    Sigal.


  4. #4
    Join Date
    May 1999
    Posts
    3,332

    Re: Maximize form HELP..

    Ok,
    here is the sample code for one of my projects:


    private Const WM_GETMINMAXINFO = &H24
    private Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" (lpDest as Any, lpSource as Any, byval nCount as Long)

    'Windows data types
    private Type POINTAPI
    x as Long
    y as Long
    End Type

    private Type MINMAXINFO
    ptReserved as POINTAPI
    ptMaxSize as POINTAPI
    ptMaxPosition as POINTAPI
    ptMinTrackSize as POINTAPI
    ptMaxTrackSize as POINTAPI
    End Type


    ' initialize Subclass.ocx
    scs.hwnd = me.hwnd
    scs.Messages(WM_GETMINMAXINFO) = true

    private Sub scs_WndProc(Msg as Long, wParam as Long, lParam as Long, Result as Long)
    Dim MinMax as MINMAXINFO

    If Msg = WM_GETMINMAXINFO then
    'Copy to our local MinMax variable
    CopyMemory MinMax, byval lParam, len(MinMax)
    'set minimum/maximum tracking size
    MinMax.ptMinTrackSize.x = (me.cmdSave.Left + me.cmdSave.Width * 1.25) / Screen.TwipsPerPixelX
    MinMax.ptMinTrackSize.y = (3 * fraTrans.Height) / Screen.TwipsPerPixelY
    'Copy data back to Windows
    CopyMemory byval lParam, MinMax, len(MinMax)
    Result = 0
    End If

    End Sub



    it makes use of a freeware ocx: subclass.ocx (don't remember where I downloaded it from).
    This code does NOT allow to make the window smaller than I want, no matter how hard the user tries.


  5. #5
    Join Date
    Jul 1999
    Location
    Israel
    Posts
    140

    Re: Maximize form HELP..

    Thanks you very much. I hope it will help me!.


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

Featured