Rechte Maustaste -> Menu



  • Morgen,
    kann mir jemand verraten wie ich wenn ich auf die rechte Maustaste druecke ein Menu zum auswaehlen bekomme.

    Gruss und dank
    msp



  • WM_CONTEXTMENU und dort dann TrackPopupMenu(Ex) entsprechen aufrufen



  • habs so probiert, ging leider nicht:

    case WM_CONTEXTMENU:
    TrackPopupMenuEx((HMENU)IDR_KONTEXTMENU,0,100,100,hWnd,NULL);
    break;



  • was sagtn GetLastError();

    btw: vllt siehst du das neue menu nur nicht ;>

    probier halt mal LOWORD(lParam) als x und HIWORD(lParam) als y position.



  • MSDN-Library schrieb:

    VOID APIENTRY DisplayContextMenu(HWND hwnd, POINT pt) 
    { 
        HMENU hmenu;            // top-level menu 
        HMENU hmenuTrackPopup;  // shortcut menu 
     
        // Load the menu resource. 
     
        if ((hmenu = LoadMenu(hinst, "ShortcutExample")) == NULL) 
            return; 
     
        // TrackPopupMenu cannot display the menu bar so get 
        // a handle to the first shortcut menu. 
     
        hmenuTrackPopup = GetSubMenu(hmenu, 0); 
     
        // Display the shortcut menu. Track the right mouse 
        // button. 
     
        TrackPopupMenu(hmenuTrackPopup, 
                TPM_LEFTALIGN | TPM_RIGHTBUTTON, 
                pt.x, pt.y, 0, hwnd, NULL); 
     
        // Destroy the menu. 
     
        DestroyMenu(hmenu); 
    }
    

    Man beachte LoadMenu und GetSubMenu (evtl. noch TPM_LEFTALIGN | TPM_RIGHTBUTTON)


Anmelden zum Antworten