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
Printable View
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
Just preset it.
Code:Private Sub MyMenu_Click()
Msgbox "You clicked MyMenu."
End Sub
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
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.
That would be very nice :D, when you can mail me the code.
Thanks a lot
Greets
Scand