Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

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



Building the Right Environment to Support AI, Machine Learning and Deep Learning

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
	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.



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