LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Tom is offline
external usenet poster
 
Posts: 12
Default Adding and Graying MAXIMIZE button on vba E2007 form system menu

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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding command button to menu excel-tr Excel Programming 0 March 28th 07 02:01 AM
adding command button to menu urkec Excel Programming 0 March 28th 07 12:57 AM
How to invoke a user form from a custom button on the menu bar JLGWhiz Excel Programming 0 January 20th 07 03:32 AM
Adding a Menu Item into a sheet as a button [email protected] Excel Programming 3 March 23rd 05 06:37 PM
Maximize Form Adrian[_7_] Excel Programming 3 September 22nd 04 03:31 PM


All times are GMT +1. The time now is 06:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"