Solved

how to remove the minimized/maximized button of a MDIForm?

Posted on 2002-03-04
13
400 Views
Last Modified: 2008-02-01
how can I remove the minimized/maximized button of a MDIForm, but preserve the close button?
0
Comment
Question by:eugeneng
[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
  • 3
  • 2
  • +2
13 Comments
 
LVL 1

Expert Comment

by:Madmarlin
ID: 6841059
Dont they have a MinButton and MaxButton property you can set to false???????
0
 
LVL 1

Expert Comment

by:Madmarlin
ID: 6841063
Sorry didnt realise those properties dont exsist..
0
 
LVL 15

Expert Comment

by:Eyal
ID: 6841101
change the form BorderStyle property value to Fixed Single or Fixed Dialog
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 4

Expert Comment

by:trkcorp
ID: 6841962
Hey e,  I see you posted this question to see about your other issue.  I'll be listening to hear the answer. T
0
 

Expert Comment

by:warlox
ID: 6842017
<<ping>>
0
 

Author Comment

by:eugeneng
ID: 6843008
Eya,
  MDIForm doesn't have BorderStyle for you to set!!
0
 

Author Comment

by:eugeneng
ID: 6843061
Eya,
  MDIForm doesn't have BorderStyle for you to set!!
0
 
LVL 4

Expert Comment

by:trkcorp
ID: 6843656
eugeneng, guess what... I have a solution for you utilizing the same APIs that we used to set the borders on your MDI form to fixed. see: http://www.experts-exchange.com/visualbasic/Q.20272107.html

Amend your code as follows in the MDI Form:

'** = changes added since the code I gave you to get fixed borders

Option Explicit
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
 (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
 (ByVal hwnd As Long, ByVal nIndex As Long) As Long

Const GWL_STYLE = (-16)
Const WS_THICKFRAME = &H40000
Const WS_MINIMIZEBOX = &H20000  '**
Const WS_MAXIMIZEBOX = &H10000  '**

Private Sub MDIForm_Load()
Dim CurStyle As Long
Dim NewStyle As Long
Dim L As Long  '**
'This code will remove the min and max boxes from the MDI form
L = GetWindowLong(Me.hwnd, GWL_STYLE) '**
L = L And Not (WS_MINIMIZEBOX) '**
L = L And Not (WS_MAXIMIZEBOX) '**
L = SetWindowLong(Me.hwnd, GWL_STYLE, L) '**
'This code will set the borderstyle = fixed
CurStyle = GetWindowLong(MDIForm1.hwnd, GWL_STYLE)
NewStyle = SetWindowLong(MDIForm1.hwnd, GWL_STYLE, CurStyle And Not (WS_THICKFRAME))
End Sub

I think this will take care of all your woes!
0
 
LVL 4

Expert Comment

by:trkcorp
ID: 6843659
eugeneng - This is better... In my haste I did not look carefully enough at what I was doing.  Use this code instead for your MDIForm load:

Private Sub MDIForm_Load()
Dim CurStyle As Long
Dim NewStyle As Long

CurStyle = GetWindowLong(Me.hwnd, GWL_STYLE)
CurStyle = CurStyle And Not (WS_MINIMIZEBOX)
CurStyle = CurStyle And Not (WS_MAXIMIZEBOX)
CurStyle = CurStyle And Not (WS_THICKFRAME)
NewStyle = SetWindowLong(Me.hwnd, GWL_STYLE, CurStyle)
End Sub
0
 
LVL 4

Expert Comment

by:trkcorp
ID: 6843665
e, you may want to leave this code, provided in the referenced question above in your program:

Private Sub MDIForm_Resize()
Static bMsgd As Boolean
Me.WindowState = vbNormal
If Not bMsgd Then
  MsgBox "You are not allowed to resize this window!"
  bMsgd = True
Else
  bMsgd = False
End If
End Sub

The reason is... if you click on the upper left icon of the MDI Form, you STILL have Min & Max options there!  Inclusion of this code will override those if the user discovers them.
0
 
LVL 4

Accepted Solution

by:
trkcorp earned 20 total points
ID: 6843707
E,
To get rid of the close button and the icon dropdown you can add this constant like so:

Const WS_SYSMENU = &H80000

Private Sub MDIForm_Load()
Dim CurStyle As Long
Dim NewStyle As Long
CurStyle = GetWindowLong(Me.hwnd, GWL_STYLE)
CurStyle = CurStyle And Not (WS_MINIMIZEBOX)
CurStyle = CurStyle And Not (WS_MAXIMIZEBOX)
CurStyle = CurStyle And Not (WS_THICKFRAME)
CurStyle = CurStyle And Not (WS_SYSMENU)
NewStyle = SetWindowLong(Me.hwnd, GWL_STYLE, CurStyle)

Then you can rely on your form menu for an exit...  I
0
 

Author Comment

by:eugeneng
ID: 6845838
Excellent!!! you are great trkcorp, thanx alot man.
0
 
LVL 4

Expert Comment

by:trkcorp
ID: 6845848
Hey, You are welcome. I learned a few things too!
0

Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

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.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

763 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