jackryan
|
|
Group: Forum Members
Posts: 95,
Visits: 102
|
hello,
with my apps, i'm trying to disable min max button or if possible hide them. ive tried several suggestion but nothing seems to work for me, can somebody help me? thankss
jack ryan
Let your plans be dark and impenetrable as night, and when you move, fall like a thunderbolt. - Sun Tzu
|
|
|
Keithuk
|
|
Group: Moderators
Posts: 1.9K,
Visits: 5.5K
|
I presume you mean the Form's Min and Max buttons. Look at the Form properties for MaxButton and MinButton and set them to False.
KeithI've been programming with VB for 17 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
|
|
|
jackryan
|
|
Group: Forum Members
Posts: 95,
Visits: 102
|
i'm sorry if i haven't been clear on my first post, i mean to say min-max button of mdi parent. i've tried several suggestion but nothing seems to work for me
jack ryan
Let your plans be dark and impenetrable as night, and when you move, fall like a thunderbolt. - Sun Tzu
|
|
|
Sunil KC
|
|
Group: Forum Members
Posts: 209,
Visits: 145
|
for disable Max button, here is some code 'Declaration in Form Level Private Declare Function GetSystemMenu Lib "user32" _ (ByVal hwnd As Long, _ ByVal bRevert As Long) As Long Private Declare Function RemoveMenu Lib "user32" _ (ByVal hMenu As Long, _ ByVal nPosition As Long, _ ByVal wFlags As Long) As Long Const MF_BYPOSITION = &H400& Public Sub DisableCloseWindowButton(frm As Form) Dim hSysMenu As Long hSysMenu = GetSystemMenu(frm.hwnd, 0) RemoveMenu hSysMenu, 6, MF_BYPOSITION RemoveMenu hSysMenu, 5, MF_BYPOSITION End Sub Private Sub MDIForm_Load() DisableCloseWindowButton Me End Sub
____________Sunil KC http://www.sunil.com.np
|
|
|
jackryan
|
|
Group: Forum Members
Posts: 95,
Visits: 102
|
thanks for your reply but it also didn't work
jack ryan
Let your plans be dark and impenetrable as night, and when you move, fall like a thunderbolt. - Sun Tzu
|
|
|
Sunil KC
|
|
Group: Forum Members
Posts: 209,
Visits: 145
|
Oh, sorry above code works for disable close button.
____________Sunil KC http://www.sunil.com.np
|
|
|
Othor
|
|
Group: Forum Members
Posts: 272,
Visits: 604
|
Remove Min/Max Buttons From MDI Form '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)
KlinerDraken http://new.kd-radio.com
|
|
|
jackryan
|
|
Group: Forum Members
Posts: 95,
Visits: 102
|
kliner, thanks for your response, i placed your code on my mdi form and only the min button is working, the max button is still not working, can you please help me more? thanks
jack ryan
Let your plans be dark and impenetrable as night, and when you move, fall like a thunderbolt. - Sun Tzu
|
|
|
Sunil KC
|
|
Group: Forum Members
Posts: 209,
Visits: 145
|
Nice job
____________Sunil KC http://www.sunil.com.np
|
|
|
Sunil KC
|
|
Group: Forum Members
Posts: 209,
Visits: 145
|
But it works for me. I have used following code 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 WS_MINIMIZEBOX = &H20000 Const WS_MAXIMIZEBOX = &H10000 Const GWL_STYLE = (-16)Private 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
____________Sunil KC http://www.sunil.com.np
|
|
|