點出來以后,必須選其中一項才能使這個菜單退出,否則,它就一直呆在那兒。怎么搞定?

解决方案 »

  1.   

    1)有时候这是系统的bug
    2)
    case WM_RBUTTONDOWN:
    {
    CMenu Menu;
    Menu.LoadMenu( IDR_MENU_ICON );

    CPoint point;
    GetCursorPos( &point ); SetForegroundWindow(); Menu.GetSubMenu( 0 )->TrackPopupMenu( TPM_LEFTBUTTON | TPM_RIGHTBUTTON, point.x, point.y, this, NULL );

    PostMessage( WM_USER, 0, 0 );
    break;
    }
      

  2.   

    这个问题,在天网防火墙中也有这个问题,比如主窗口不是焦点时,弹出菜单,非要选一下菜单,才能消失,
       解决这个问题的关键是.
    在MYMENU.TrackPopupMenu(ID_MENU1);
    之前加一句:   SetForegroundWindow();
    这个函数的功能为: puts the thread that created the specified window into the foreground and activates the window. Keyboard input is directed to the window, and various visual cues are changed for the user.