Announcement

Collapse
No announcement yet.

Conflicting MenuID and keyboard

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Conflicting MenuID and keyboard

    Sadly enough i have currently a misused menuitem id's of 1 and 2
    Pressing esc or enter invokes these menus.
    Can i detect if this is a keystroke or not?

    The wparam and lparam values remain equal in this case.

    Even worse, the window where this happens is modeless and shares the messagepump of another (main) window.
    So no routing of the accelerator.

    I see no alternative than to rewrite the menuid id's.
    (Which is bit problematic in this case)
    hellobasic

  • #2
    Well, you can pick off LOWRD(wParam) = IDCANCEL (2) or IDOK(1)... and do something else.

    On WM_COMMAND, you can test wParam to see if message from an accelerator or a menu....
    wParam
    The high-order word specifies the notification code if the message is from a control. If the message is from an accelerator, this value is 1. If the message is from a menu, this value is zero.
    .... I'm not sure what "Alt+<Underlined letter>" returns, but I would think that would appear as an accelerator. Easy enough to test.

    Alternately, you might tinker with your WM_MENUSELECT and/or WM_MENUCOMMAND notification message processing.

    MCM
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      In both cases wparam and lparam are the same.
      Therefore no distinct between accel or menu.
      (The accel number is not set)
      The menuid is a valid menuid therefore i can not abort on IDOK or IDCANCEL.

      I'll try to use the other menu messages.
      hellobasic

      Comment


      • #4
        Here's a thought...

        On startup, delete the offending items from the menu, then add new items with different IDs.

        ????
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          Code:
          If ISTRUE(GetAsyncKeyState(%VK_ESCAPE)) OR ISTRUE(GetAsyncKeyState(%VK_RETURN)) THEN
          
          ' IT WAS A KEYPRESS.
          
          END IF

          Comment


          • #6
            Originally posted by Elias Montoya View Post
            Code:
            If ISTRUE(GetAsyncKeyState(%VK_ESCAPE)) OR ISTRUE(GetAsyncKeyState(%VK_RETURN)) THEN
            
            ' IT WAS A KEYPRESS.
            
            END IF
            Yes i thought about that before but i skipped it since i thought the key may have been released already when it invokes the menu.
            But now i see i hold the esc and enter key down and the action occures right away.
            So this simple catch may be valid after all.

            Thanks,
            hellobasic

            Comment

            Working...
            X