?
Solved

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

Posted on 2002-03-04
13
Medium Priority
?
411 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
Independent Software Vendors: 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 80 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

752 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