Results 1 to 5 of 5

Thread: How can i add an click event...

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2000
    Location
    Switzerland
    Posts
    53
    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

  2. #2
    Guest
    Just preset it.

    Code:
    Private Sub MyMenu_Click()
        Msgbox "You clicked MyMenu."
    End Sub

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2000
    Location
    Switzerland
    Posts
    53
    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

  4. #4
    New Member
    Join Date
    Jan 2001
    Posts
    1

    Smile 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.

  5. #5

    Thread Starter
    Member
    Join Date
    Mar 2000
    Location
    Switzerland
    Posts
    53
    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
  •  



Click Here to Expand Forum to Full Width