CWindow::CenterWindow

焦点窗口特定窗口。

BOOL CenterWindow(
   HWND hWndCenter = NULL 
) throw();

参数

  • hWndCenter
    [in]句柄的窗口为中心。 如果此参数是 NULL (默认值),则方法将设置 hWndCenter 到窗口的父窗口,如果延续为子窗口。 否则,它将设置 hWndCenter 到窗口的所有者窗口。

返回值

TRUE,如果窗口成功集中;否则,FALSE

示例

//The following example attaches various HWNDs to the CWindow objects 
//and calls CWindow::CenterWindow() for each of them

CWindow childWindow, popupWindow, overlappedWindow;

childWindow.Attach(hWndChild); //a window created with WS_CHILD style
childWindow.CenterWindow();    //This will center the child 
                               //window against its Parent window

popupWindow.Attach(hWndPopup); //a window created with WS_POPUP style
popupWindow.CenterWindow();    //This will center the popup window 
                               //against its Owner window

overlappedWindow.Attach(hWndOverlapped); //a window created with 
                                         //WS_OVERLAPPED style
overlappedWindow.CenterWindow(::GetDesktopWindow()); //This will center 
                       //the overlapped window against the DeskTop window

要求

Header: atlwin.h

请参见

参考

CWindow选件类

CWindow::MoveWindow

CWindow::SetWindowPos