Solved

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

Posted on 2002-03-04
13
404 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
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.

 
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

707 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