1。在OnInitDialog中调用
CRect rect;
GetClientRect(rect);
SetWindowPos(&wndTopMost,rect.left,rect.top,rect.Width(),rect.Height(),0);2。你用vc的popup_menu component吧!,也不用费劲去算什么位置了

解决方案 »

  1.   

    不好意思,瞧错了函数
    第三行
    GetWindowRect(rect)
      

  2.   

    project->add to project->component and controls-> popupmenu->insert->ok
    好象很多新人都不知道有这些COMPONENT。很方便的哦。
      

  3.   

    第一个问题也可以用SetWindowLong来解决:
    API写法:
    HWND hwnd;//须改变得窗口句柄
    //******************
    LONG style;//窗口风格
    style = GetWindowLong(hwnd,GWL_EXSTYLE);
    style |=WS_EX_TOPMOST;
    SetWindowLong(hwnd,GWL_EXSTYLE,style);
    c++ 写法:
    CWnd * pWnd;
    LONG style;
    style=pWnd->GetWindowLong(GWL_EXSTYLE);
    style |=WS_EX_TOPMOST;
    pWnd->SetWindowLong(GWL_EXSTYLE,style);
    第二个问题:
    如果你是用右键触发弹出窗口,则在消息映射里加入对右键按下的消息处理函数:
    类名::OnRButtonDown( UINT nFlags, CPoint point )
    {
    ::CreateWindow(...,point.x,point.y,...);
    .....
    .....
    //或者如果窗口已创建,用SetWindowPlacement函数或SetWindowPos函数来调整窗口位置}
      

  4.   

    其实不用得到当前窗口的RECT,如下
    SetWindowPos(&wndTopMost,0,0,0,0,WM_NOSIZE);
      

  5.   

    I am Sunlet,netsinger,认识我吗?
      

  6.   

    弹出菜单:
    GetCursorPos(&pt);
    TrackPopupMenu(m_hSubMenu, TPM_LEFTBUTTON, pt.x, pt.y, 0, m_hWnd, NULL);
    弹出窗口?
    GetCursorPos(&pt);
    SetWindowPos(hwnd, hwndParent, pt.x, pt.y, 0, 0, SWP_NOSIZE);