1。在OnInitDialog中调用
CRect rect;
GetClientRect(rect);
SetWindowPos(&wndTopMost,rect.left,rect.top,rect.Width(),rect.Height(),0);2。你用vc的popup_menu component吧!,也不用费劲去算什么位置了
CRect rect;
GetClientRect(rect);
SetWindowPos(&wndTopMost,rect.left,rect.top,rect.Width(),rect.Height(),0);2。你用vc的popup_menu component吧!,也不用费劲去算什么位置了
第三行
GetWindowRect(rect)
好象很多新人都不知道有这些COMPONENT。很方便的哦。
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函数来调整窗口位置}
SetWindowPos(&wndTopMost,0,0,0,0,WM_NOSIZE);
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);