DandL
asked on
MinButton=true Maxbutton=False
I am trying to turn off the MaxButton and the closebutton.
This is what I am doing:
frmConnect.MaxButton = False
But it will not let me do that. I tried to set the borderStyle property but it does not have the functionality that I need. In short what I want to do is to "gray out" the MaxButton and the close button. How can I do that?
This is what I am doing:
frmConnect.MaxButton = False
But it will not let me do that. I tried to set the borderStyle property but it does not have the functionality that I need. In short what I want to do is to "gray out" the MaxButton and the close button. How can I do that?
ASKER
That does not seem to work I get this error.
"Function marked as restricted or uses a type not supported in Visual Basic"
I want to be able to see all three buttons, but i only want to be able to click the min button. What I ment by grayed out is that the button is unclickable. Can this be done?
"Function marked as restricted or uses a type not supported in Visual Basic"
I want to be able to see all three buttons, but i only want to be able to click the min button. What I ment by grayed out is that the button is unclickable. Can this be done?
Set the property controlbox to false.
Form1.controlbox = False
WoK
Form1.controlbox = False
WoK
You can also grey out the Minmax Buttons with:
Form1.MaxButton = False
Form1.MinButton = False
WoK
Form1.MaxButton = False
Form1.MinButton = False
WoK
THe problem is that, if your set the controlbox to flase, the min and max button will disable as well. Nevertheless you can disable the close button without the api code here.
************************** ********** ********** ********** ********** ***
Option Explicit
Public defWindowProc As Long
Public Const GWL_WNDPROC As Long = (-4)
Public Const WM_NCHITTEST As Long = &H84
Public Const HTNOWHERE As Long = 0
Public Const HTCLOSE As Long = 20
Declare Function GetWindowLong Lib "User32" _
Alias "GetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long) As Long
Declare Function SetWindowLong Lib "User32" _
Alias "SetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Declare Function CallWindowProc Lib "User32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Sub SubClass(hWnd As Long)
On Error Resume Next
defWindowProc = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub
Public Sub UnSubClass(hWnd As Long)
If defWindowProc Then
SetWindowLong hWnd, GWL_WNDPROC, defWindowProc
defWindowProc = 0
End If
End Sub
Public Function WindowProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
On Error Resume Next
Dim retVal As Long
retVal = CallWindowProc(defWindowPr oc, hWnd, uMsg, wParam, lParam)
If uMsg = WM_NCHITTEST Then
If retVal = HTCLOSE Then retVal = HTNOWHERE
End If
WindowProc = retVal
End Function
************************** ********** ********** ********** *
Call the form using this way
Private Sub Form_Load()
Call SubClass(Me.hWnd)
End Sub
************************** ********** ********** ********** ***
You can set the max button to disable and the min button to enable. THe border style remain as fixed single or sizebale
Regards
**************************
Option Explicit
Public defWindowProc As Long
Public Const GWL_WNDPROC As Long = (-4)
Public Const WM_NCHITTEST As Long = &H84
Public Const HTNOWHERE As Long = 0
Public Const HTCLOSE As Long = 20
Declare Function GetWindowLong Lib "User32" _
Alias "GetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long) As Long
Declare Function SetWindowLong Lib "User32" _
Alias "SetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Declare Function CallWindowProc Lib "User32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Sub SubClass(hWnd As Long)
On Error Resume Next
defWindowProc = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub
Public Sub UnSubClass(hWnd As Long)
If defWindowProc Then
SetWindowLong hWnd, GWL_WNDPROC, defWindowProc
defWindowProc = 0
End If
End Sub
Public Function WindowProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
On Error Resume Next
Dim retVal As Long
retVal = CallWindowProc(defWindowPr
If uMsg = WM_NCHITTEST Then
If retVal = HTCLOSE Then retVal = HTNOWHERE
End If
WindowProc = retVal
End Function
**************************
Call the form using this way
Private Sub Form_Load()
Call SubClass(Me.hWnd)
End Sub
**************************
You can set the max button to disable and the min button to enable. THe border style remain as fixed single or sizebale
Regards
Sorry, you can't reset the properties at runtime ...
WoK
WoK
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I had to call it this way for it to work
Call DisableClose(Me)
It would not recognize the type this way clsDisableClose or DisableClose.
Thanks for your help. I am upping the points to 100 because it was more complex then I thought.
DandL
Call DisableClose(Me)
It would not recognize the type this way clsDisableClose or DisableClose.
Thanks for your help. I am upping the points to 100 because it was more complex then I thought.
DandL
no problem dandl, glad i could help here
Regards
Regards
>>It would not recognize the type this way clsDisableClose or DisableClose.
This might because that you did not place it as a class module and the namne is not the same as the calling function. But anyway glad i could help here
REgards
This might because that you did not place it as a class module and the namne is not the same as the calling function. But anyway glad i could help here
REgards
THen set the minbutton to true and maxbutton to false
Regards