Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Dec 22, 1998

Remove Min/Max Buttons From MDI Form

Unlike other forms, MDI forms don't have MinButton and MaxButton properties to enable or disable the form's Minimize and Maximize buttons. If you add this code to an MDI parent form's Load event, it disables the Minimize and Maximize buttons on the MDI form. If you just want to disable one or the other, comment out the appropriate line, based on which constant you don't need:
 
Sub MDIForm_Load()
	Dim lWnd as Long
	lWnd = GetWindowLong(Me.hWnd, GWL_STYLE)
	lWnd = lWnd And Not (WS_MINIMIZEBOX)
	lWnd = lWnd And Not (WS_MAXIMIZEBOX)
	lWnd = SetWindowLong(Me.hWnd, GWL_STYLE, lWnd)
End Sub
Add this code (which includes the required API declarations) to a BAS module:
 
#If Win32 Then
	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
#Else
	Declare Function SetWindowLong Lib "User" (ByVal hwnd _
		As Integer, ByVal nIndex As Integer, ByVal _
		dwNewLong As Long) As Long
	Declare Function GetWindowLong Lib "User" (ByVal hwnd _
		As Integer, ByVal nIndex As Integer) As Long
#End If

Const WS_MINIMIZEBOX = &H20000
Const WS_MAXIMIZEBOX = &H10000
Const GWL_STYLE = (-16)
Joselito Ogalesco
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date