Solved

disable MDI form minimize button

Posted on 2001-06-08
6
389 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Technology Partners: 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!

Question has a verified solution.

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

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

696 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