|
-
Jan 17th, 2001, 07:26 AM
#1
Thread Starter
Member
I've created a menu with
CreateMenu()
and with
InsertMenu()
I've insert two items to the menu.
Know I want to add code to the click event.
How can I add a click event for my created menu items???
Greets
Scand
-
Jan 17th, 2001, 07:32 AM
#2
Just preset it.
Code:
Private Sub MyMenu_Click()
Msgbox "You clicked MyMenu."
End Sub
-
Jan 17th, 2001, 07:52 AM
#3
Thread Starter
Member
I've created my menu's with an variable, so they are not a fixed name.
Mhhh I try to explain.
I've a Menu called mnuTest which a added in the design phase.
In my code I recieve a string for example:
"P&rinter;Add...;Setup...;"
Now I create a menu "P&rinter" and add a "Add..." menuitem and a "Setup..." menuitem to the "P&rinter" menu
After this I do Insert my Menu to the mnuTest menu
with:
hMenu = GetMenu(myapp.hWnd)
hMenu2 = GetSubMenu(hMenu, 0)
InsertMenu(hMenu2, 0, MF_BYPOSITION Or MF_POPUP, hNewMenu, "P&rinter")
For the new Menu's i do not know how can I call the click event, because I haven't any menu mame, like mnuTest.
Can you help me?
Greets
Scand
-
Jan 19th, 2001, 09:55 AM
#4
New Member
Responding to Menu Clicks
Well, the only sensible way I know ho to fix this is to set the SubMenuItem's wId to something.
Then you have to subclass the WindowProc (using our good friend SetWindowLong and the AddressOf operator), trap the WM_COMMAND message and test the wParam of the message for the variable (wId) set above.
I've done this to the System Menu and, if you'd like, I can e-mail you a project with the code in so that you can see the idea.
Good luck.
Tony.
-
Jan 19th, 2001, 10:12 AM
#5
Thread Starter
Member
That would be very nice , when you can mail me the code.
Thanks a lot
Greets
Scand
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
|