how to invoke a popup menu on menubar without clicking the softkey

hi,

I have a menubar "Done" and "Menu", Done is "button" and "Menu" is a popup menu with 2 items. I would like to popup the menu items when user press the action key but I have no idea what message to be sent to or to which window. Is there a way to accomplish that

thanks in advance.



Answer this question

how to invoke a popup menu on menubar without clicking the softkey

  • Cathie 64

    hi,

    thanks for reply and I just found the solution from MSDN library(if you don't reply I wouldn't look into this problem again) here is what I did to simulate the softkey press

    keybd_event(VK_TSOFT2, 0, 0, 0);
    keybd_event(VK_TSOFT2, 0, KEYEVENTF_KEYUP, 0);
    Sleep(60);

    hope it will help others that have similar situation like me.


  • beto81

    Hi,

    I think sending the appropriate WM_HOTKEY message corresponding to the hardware button associated with the menu item should do the job of popping up the smartphone menu.

    In case you want to popup a new menu programatically all you need to open a new menu shall be to load the menu and use TrackPopupMenu API. You may find this interesting: http://www.codecomments.com/archive372-2006-2-818073.html


    Hope this helps.
    Thanks



  • MaxHeadCase

    What is your device

  • Fredrik Melin

    keybd_event is forbidden in some phone by OEM.
    The best solution, Try this code:

    // If you know current menu bar window, you don't need to search it...
    HWND softkeyMB=SHFindMenuBar(GetForegroundWindow());


    // Post the WM_HOTKEY message into Softkey like this:
    // For Left Softkey
    PostMessage(softkeyMB,WM_HOTKEY,0,MAKELPARAM(0,VK_F1));
    PostMessage(softkeyMB,WM_HOTKEY,0,MAKELPARAM(4096,VK_F1));

    // For Right Softkey
    PostMessage(softkeyMB,WM_HOTKEY,0,MAKELPARAM(0,VK_F2));
    PostMessage(softkeyMB,WM_HOTKEY,0,MAKELPARAM(4096,VK_F2));


  • dfullerws

    hi,

    sorry for bumping this post, just wanted to know anyone know the solution for the above question.


  • R2 DJ

    Great, that shall do just fine. Thanks for posting.




  • DrunkPanda

    hi,

    I'm coding for smartphone device.


  • how to invoke a popup menu on menubar without clicking the softkey