CWindow::CenterWindow
將視窗對指定的視窗。
BOOL CenterWindow(
HWND hWndCenter = NULL
) throw();
參數
- hWndCenter
[in] 控制代碼的視窗為中心。 如果此參數為 NULL (預設值),則方法會將 hWndCenter 到這個視窗之父視窗,如果它是子視窗。 否則,它會設定 hWndCenter 至視窗的主控視窗。
傳回值
是 ,如果視窗已成功置中;否則, 否。
範例
//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