|
-
Feb 12th, 2001, 10:34 AM
#1
Thread Starter
Hyperactive Member
I'm trying to grey out the Restore menu item on a from's menu. I thought i should be able to do it something like this, but it's not working....
Code:
Declare Function GetMenu Lib "user32" (ByVal hWnd As Long) As Long
Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpString As Any) As Long
Const MF_GRAYED = &H1
Dim hMenu As Long
Dim hID As Long
Dim hSubMenu As Long
hMenu = GetMenu(Current.hWnd)
hSubMenu = GetSubMenu(hMenu, 0)
hID = GetMenuItemID(hMenu, 0)
ModifyMenu hMenu, hID, MF_GRAYED, hSubMenu, "Restore"
but it doesnt work. hMenu (and consequently hSubMenu and hID ) all return 0.
Can someone tell me where i am going wrong?
-
Feb 12th, 2001, 12:20 PM
#2
Fanatic Member
Code:
Private Declare Function GetMenu Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpString As Any) As Long
Private Const MF_GRAYED = &H1
Public Sub GrayMenu()
Dim hMenu&
Dim hID&
Dim hSubMenu&
hMenu = GetMenu(Me.hWnd)
hSubMenu = GetSubMenu(hMenu, 0)
hID = GetMenuItemID(hSubMenu, 0)
ModifyMenu hSubMenu, hID, MF_GRAYED, 0&, "GettheMenuTextBeforehand"
End Sub
Private Sub Command1_Click()
GrayMenu
End Sub
Crispin
VB6 ENT SP5
VB.NET
W2K ADV SVR SP3
WWW.BLOCKSOFT.CO.UK
[Microsoft Basic: 1976-2001, RIP]
-
Feb 12th, 2001, 04:11 PM
#3
Code:
Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpString As Any) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Const MF_GRAYED = &H1
Private Const MF_BYPOSITION = &H400&
Private Sub Form_Load()
hMenu = GetSystemMenu(hwnd, 0)
ModifyMenu hMenu, 0, MF_BYPOSITION, MF_GRAYED, "Restore"
End Sub
-
Nov 28th, 2002, 06:45 AM
#4
New Member
This last answer is a good one, you can also use MF_BYCOMMAND
to make the job.
Unhappily it does not work anymore with Windows XP, and I would like to find a solution.
Thank you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|