T
Tom
Hi,
I was trying to add MINIMIZE and MAXIMIXE buttons to vba E2007 form
system menu - and after that gray MAXIMIZE button. The problem is that
disabling by graying works only for the only initial default one
button 'X' for closing form and not working for the two new buttons
added programmatically. I was first positively surprised that the code
required for so customizing the vba form in win api is quite short,
but since it only works for 'X' button I must have missed something.
My code is:
Private Sub CommandButton1_Click()
Me.Hide 'secure a means to close the form after disabling 'X'
'after that I reset the project to restore the initial state of the
form
End Sub
Private Sub CommandButton2_Click()
'adding two buttons to system menu
hwnd = GetActiveWindow
Dim lng As Long
lng = GetWindowLong(hwnd, GWL_STYLE)
lng = lng Or WS_MINIMIZEBOX
lng = lng Or WS_MAXIMIZEBOX
Dim b As Long
b = SetWindowLong(hwnd, GWL_STYLE, lng)
b = SendMessage(hwnd, WM_NCACTIVATE, 1, 0) 'repaint non-client area
End Sub
Private Sub CommandButton3_Click()
'disabling 'X' button denoted by position GetMenuItemCount(hm) - 1
'I want this working for the two added buttons as well but it won't !
Dim hm As Long
hm = GetSystemMenu(hwnd, 0)
Dim b As Long
b = EnableMenuItem(hm, GetMenuItemCount(hm) - 1, MF_BYPOSITION Or
MF_GRAYED)
b = SendMessage(hwnd, WM_NCACTIVATE, 1, 0)'repaint
End Sub
I suspect that I'm making a simple mistake by having the two added
buttons not recognizable
for graying but I don't know how
Thanks for anny suggestions
Tom
I was trying to add MINIMIZE and MAXIMIXE buttons to vba E2007 form
system menu - and after that gray MAXIMIZE button. The problem is that
disabling by graying works only for the only initial default one
button 'X' for closing form and not working for the two new buttons
added programmatically. I was first positively surprised that the code
required for so customizing the vba form in win api is quite short,
but since it only works for 'X' button I must have missed something.
My code is:
Private Sub CommandButton1_Click()
Me.Hide 'secure a means to close the form after disabling 'X'
'after that I reset the project to restore the initial state of the
form
End Sub
Private Sub CommandButton2_Click()
'adding two buttons to system menu
hwnd = GetActiveWindow
Dim lng As Long
lng = GetWindowLong(hwnd, GWL_STYLE)
lng = lng Or WS_MINIMIZEBOX
lng = lng Or WS_MAXIMIZEBOX
Dim b As Long
b = SetWindowLong(hwnd, GWL_STYLE, lng)
b = SendMessage(hwnd, WM_NCACTIVATE, 1, 0) 'repaint non-client area
End Sub
Private Sub CommandButton3_Click()
'disabling 'X' button denoted by position GetMenuItemCount(hm) - 1
'I want this working for the two added buttons as well but it won't !
Dim hm As Long
hm = GetSystemMenu(hwnd, 0)
Dim b As Long
b = EnableMenuItem(hm, GetMenuItemCount(hm) - 1, MF_BYPOSITION Or
MF_GRAYED)
b = SendMessage(hwnd, WM_NCACTIVATE, 1, 0)'repaint
End Sub
I suspect that I'm making a simple mistake by having the two added
buttons not recognizable
for graying but I don't know how
Thanks for anny suggestions
Tom