2014-04-19 3 views
1

vc6.0을 사용하고 있습니다. 목록 상자 항목을 마우스 오른쪽 버튼으로 클릭하면 팝 메뉴가로드됩니다. 그러나 popmenu 항목을 클릭하면 WM_COMMAND 메시지를 보내지 않는 것 같습니다. 나는 google에 seaching 후 이것에 대해 어떤 단서도 갖고 있지 않다. 아무도 몰라?POPUP 메뉴가 WM_COMMAND 메시지를 보내지 않습니다.

void PT_OnContextMenu(HWND hwnd, HWND hwndContext, UINT xPos, UINT yPos) 
{ 
    HWND hList = GetDlgItem(hwnd,IDC_LIST_PRESTYPE); 
    if (hList == hwndContext) 
    { 
     if(-1!=indexLB) 
     { 
      RECT rect; 
      POINT pt; 
      pt.x = xPos; 
      pt.y = yPos; 
      ListBox_GetItemRect(hwndContext, indexLB, &rect); 
      ScreenToClient(hwndContext, &pt); 
      if(PtInRect(&rect, pt)) 
      {     
       HMENU hMenu = LoadMenu((HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), MAKEINTRESOURCE(IDR_MENU_RDELTYPE));     
       if(hMenu) 
       { 
        HMENU hpop = GetSubMenu(hMenu,0); 
        ClientToScreen(hwndContext, &pt); 
        TrackPopupMenu(hpop, 
         TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON, 
         pt.x, 
         pt.y, 
         0, 
         hwndContext, 
         NULL); 
        DestroyMenu(hMenu); 
       } 
      } 
     } 
    } 
} 

아래 코드에서 메시지 상자를 가져 오지 못했습니다.

void PT_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) 
{ 
    switch(id) 
    { 
     case ID_MENUITEM_RDELTYPE: 
     { 
      MessageBox(hwnd,TEXT("dddd!"),TEXT("dddd"),MB_OK); 
     } 
     break; 
     default: 
     break; 
    } 
} 

답변

2

해결. MSDN

A handle to the window that owns the shortcut menu. This window receives all messages 
from the menu. The window does not receive a WM_COMMAND message from the menu until the 
function returns. If you specify TPM_NONOTIFY in the uFlags parameter, the function does 
not send messages to the window identified by hWnd. However, you must still pass a window 
handle in hWnd. It can be any window handle from your application. 

에 발견 난 안 대화를 목록 상자로 hwnd을 설정합니다.

관련 문제