Solved

disable MDI form minimize button

Posted on 2001-06-08
6
385 Views
Last Modified: 2012-05-04
How i can disable or invisible the Minimize button of a MDIform?
0
Comment
Question by:ahmadpj
6 Comments
 
LVL 28

Accepted Solution

by:
Ark earned 5 total points
ID: 6170325
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd&, ByVal nIndex&) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd&, ByVal nIndex&, ByVal dwNewLong&) As Long
Const GWL_STYLE As Long = (-16&)
Private Const WS_MINIMIZEBOX = &H20000

Private Sub MDIForm_Load()
   SetWindowLong Me.hWnd, GWL_STYLE, GetWindowLong(Me.hWnd, GWL_STYLE) Xor WS_MINIMIZEBOX
End Sub
0
 
LVL 1

Expert Comment

by:VBMAD
ID: 6170329
Private Declare Function GetSystemMenu Lib "User32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Private Declare Function RemoveMenu Lib "User32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long

hSysMenu = GetSystemMenu(Me.hWnd, 0)
Call RemoveMenu(hSysMenu, 1, &H400&)
Call RemoveMenu(hSysMenu, 2, &H400&)
Call RemoveMenu(hSysMenu, 3, &H400&)
Call RemoveMenu(hSysMenu, 4, &H400&)


0
 
LVL 1

Expert Comment

by:kdg2000
ID: 6170362
Each form has system menu. It occurs at click mouse on icon in the left upper corner of the form.
Its units:
- Restore
- Move
- Size
- Minimize
- Maximize
- (separator)
- Close
In an example the first 5 menu items are deleted.

Example:
-------------------------------Module1 -------------------------------------------
Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, _
    ByVal wFlags As Long) As Long
Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Const MF_BYPOSITION = &H400&
Const MF_REMOVE = &H1000&

Public Sub DisableMaxMin(ByVal Form_hWnd As Long)
    Dim hMenu As Long
    Dim nCount As Long
    Dim i as Long

    hMenu = Module1.GetSystemMenu(Form_hWnd, 0)
    nCount = Module1.GetMenuItemCount(hMenu)
    For i=1 To 5
        Module1.RemoveMenu hMenu, 1, Module1.MF_REMOVE Or Module1.MF_BYPOSITION
    Next i
    Module1.DrawMenuBar Form_hWnd
End Sub

Sub main()
    MDIForm1.Show
End Sub
------------------------------- end Module1 ------------------------------------

------------------------------- MDIForm1 ----------------------------------------
Private Sub MDIForm_Load()
     Module1.DisableMaxMin Me.hwnd
End Sub
------------------------------- end MDIForm1-----------------------------------
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Author Comment

by:ahmadpj
ID: 6170391
Thank u all, i used Ark code, and it works, but i have a question from Ark, how u find out the value of WS_MINIMIZEBOX, i asked it cuz i want it for WS_MAXIMIZEBOX
0
 
LVL 28

Expert Comment

by:Ark
ID: 6170400
Private Const WS_MAXIMIZEBOX = &H10000
0
 
LVL 1

Author Comment

by:ahmadpj
ID: 6170413
Yes i know it is &H10000 but how we can find it?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA open file from excel cell 4 44
How to set the sa password in a vb6 code for sql connection 9 60
Spell Check in VB6 13 127
vb6 - Transfer from MSHFlexgrid1 to xls issue 8 56
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question