Solved

disable MDI form minimize button

Posted on 2001-06-08
6
387 Views
Last Modified: 2012-05-04
How i can disable or invisible the Minimize button of a MDIform?
0
Comment
Question by:ahmadpj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MsgBox 2 61
MsgBox 4 71
Automatically generate a pdf file from an excel file and email out everyday 2 68
Help with Classic ASP - Parameterizing Query 16 24
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

726 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