Results 1 to 7 of 7

Thread: How To Disable Maximize Button in MDI Form

Hybrid View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    23

    Question How To Disable Maximize Button in MDI Form

    Hello There,
    Can anyone please tell me how to disable maximize button in MDI Form. I also want to disable form resize function on that MDI Form. I have a little idea that if I use API programming I could do it. But I dont know how to do it. Plz help me...THANKS

  2. #2
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Re: How To Disable Maximize Button in MDI Form

    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  3. #3

  4. #4
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Re: How To Disable Maximize Button in MDI Form

    Use Rhino's link.
    (Just as I've already written this code for you, I'm posting it here. )

    Disable MDI Form Resize:
    VB Code:
    1. ' Inside MDI Form
    2. Option Explicit
    3. '================================================================
    4. Private Sub MDIForm_Load()
    5.     ' Subclass the form
    6.     pOldWindPoc = SetWindowLong(Me.hwnd, GWL_WNDPROC, AddressOf WndProc)
    7. End Sub
    8. '==================================================================
    9. Private Sub MDIForm_Unload(Cancel As Integer)
    10.     ' Un-subclass the form
    11.     SetWindowLong Me.hwnd, GWL_WNDPROC, pOldWindPoc
    12. End Sub
    VB Code:
    1. 'Inside a Module
    2. Option Explicit
    3.  
    4. Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" _
    5.                           (ByVal lpPrevWndFunc As Long, _
    6.                            ByVal hwnd As Long, _
    7.                            ByVal msg As Long, _
    8.                            ByVal wParam As Long, _
    9.                             lParam As WINDOWPOS) As Long
    10.                            
    11. Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
    12.                           (ByVal hwnd As Long, _
    13.                            ByVal nIndex As Long, _
    14.                            ByVal dwNewLong As Long) As Long
    15.  
    16. Private Type WINDOWPOS
    17.     hwnd As Long
    18.     hWndInsertAfter As Long
    19.     x As Long
    20.     y As Long
    21.     cx As Long
    22.     cy As Long
    23.     flags As Long
    24. End Type
    25.  
    26. Public pOldWindPoc As Long ' A pointer to the old window procedure
    27.  
    28. Public Const GWL_WNDPROC& = (-4)
    29.  
    30. Private Const WM_WINDOWPOSCHANGING As Long = &H46
    31. Private Const SWP_NOSIZE As Long = &H1
    32.  
    33. '================================================================
    34. ' Our new window procedure
    35. Public Function WndProc(ByVal hwnd As Long, _
    36.        ByVal uMsg As Long, _
    37.        ByVal wParam As Long, _
    38.        lParam As WINDOWPOS) As Long
    39.    
    40.     If uMsg = WM_WINDOWPOSCHANGING Then
    41.         ' Ignore sizing
    42.         lParam.flags = lParam.flags Or SWP_NOSIZE
    43.     End If
    44.    
    45.     ' Pass the message to original WinProc
    46.     WndProc = CallWindowProc(pOldWindPoc, hwnd, uMsg, wParam, lParam)
    47.      
    48. End Function
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  5. #5
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Re: How To Disable Maximize Button in MDI Form

    The code doesn't changes mouse cursor. You may want to use SetCursor API for that.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  6. #6
    New Member
    Join Date
    May 2010
    Posts
    1

    Re: How To Disable Maximize Button in MDI Form

    Hi There can anyone tell me how to disable the minimize button on an mdi parent form, as i've written quite a big application and when a person minimizes the app it disappears, so i thought of stopping them from minimizing at all for now. thank you

  7. #7
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: How To Disable Maximize Button in MDI Form

    Quote Originally Posted by Psycho187 View Post
    ... when a person minimizes the app it disappears, ...
    Not sure what it means.

    Quote Originally Posted by Psycho187 View Post
    Hi There can anyone tell me how to disable the minimize button on an mdi parent form...
    You can find your answer in post #3.

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