Solved

disable MDI form minimize button

Posted on 2001-06-08
6
380 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 27

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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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 27

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now