창 가운데 두 가지 방법 설정

본문 @lonelyrains 출품, 전재 출처 를 밝 혀 주세요.  글 링크: http://blog.csdn.net/lonelyrains/article/details/10469933
첫 번 째 방법
두 번 째 방법
void CenterWindowOnScreen(HWND hWnd)
{
	RECT	rect;
	int		xLeft,yTop;
	GetWindowRect(hWnd,&rect);  
	xLeft = (GetSystemMetrics(SM_CXFULLSCREEN)-(rect.right-rect.left))/2;
	yTop = (GetSystemMetrics(SM_CYFULLSCREEN)-(rect.bottom-rect.top))/2;
	// Move the window to the correct coordinates with SetWindowPos()
	//bResult = SetWindowPos(hWnd,HWND_TOP,xLeft,yTop,-1,-1,SWP_NOSIZE|SWP_NOZORDER/*|SWP_NOACTIVATE*/);
	SetWindowPos(hWnd, HWND_TOPMOST, xLeft,yTop,-1,-1, SWP_NOSIZE | SWP_NOZORDER);
	SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
}

좋은 웹페이지 즐겨찾기