Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Winapi 弹出菜单不发送WM_命令消息_Winapi_Visual C++_Contextmenu_Visual C++ 6_Popupmenu - Fatal编程技术网

Winapi 弹出菜单不发送WM_命令消息

Winapi 弹出菜单不发送WM_命令消息,winapi,visual-c++,contextmenu,visual-c++-6,popupmenu,Winapi,Visual C++,Contextmenu,Visual C++ 6,Popupmenu,我正在使用vc6.0。右键单击列表框项目时,我会加载一个弹出菜单。但当我单击POP菜单项时,它似乎没有发送WM_命令消息。在谷歌搜索之后,我对此一无所知。有人知道吗 void PT_OnContextMenu(HWND hwnd, HWND hwndContext, UINT xPos, UINT yPos) { HWND hList = GetDlgItem(hwnd,IDC_LIST_PRESTYPE); if (hList == hwndContext) {

我正在使用vc6.0。右键单击列表框项目时,我会加载一个弹出菜单。但当我单击POP菜单项时,它似乎没有发送WM_命令消息。在谷歌搜索之后,我对此一无所知。有人知道吗

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;
    }
}
解决了。找到它了吗

我将
hwnd
设置为列表框而不是对话框

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.