窗口置顶方法
CWindow::SetWindowPos
BOOL SetWindowPos( HWND hWndInsertAfter, int x, int y, int cx, int cy, UINT nFlags );
BOOL SetWindowPos( HWND hWndInsertAfter, LPCRECT lpRect, UINT nFlags );
1 BOOL CXXX::OnInitDialog() 2 { 3 CRect rect; 4 GetWindowRect(&rect); 5 ::SetWindowPos(this->m_hWnd,HWND_TOPMOST,Rect.left,Rect.top, 6 Rect.Width(),Rect.Height(),SWP_NOMOVE | SWP_NOSIZE); 7 }
BringWindowToTop
This function brings the specified window to the top of the z-order. If the window is a top-level window, it is activated. If the window is a child window, the top-level parent window associated with the child window is activated.
BOOL BringWindowToTop( HWND hWnd );
Parameters
- hWnd
- Handle to the window to bring to the top of the z-order.
Return Values
Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.
bringwindowtotop 如果窗口为顶层窗口,则该窗口被激活;如果窗口为子窗口,则相应的顶级父窗口被激活。