void MoveToParentCenter(HWND hWnd)
{
  // 부모 윈도우의 중앙으로 윈도우를 이동하는 함수
  HWND hParentWnd;
  RECT rtParent, rtWindow;
  POINT pt;
 
  // 부모윈도우와 다이얼로그의 크기를 구해서 중간값(x, y 좌표)을 얻는다.
  hParentWnd = GetParent( hWnd );
  GetWindowRect( hParentWnd, &rtParent );
  GetWindowRect( hWnd, &rtWindow );
  pt.x = (rtParent.right - rtWindow.right) / 2;
  pt.y = (rtParent.bottom - rtWindow.bottom) / 2;
 
  // x, y 위치를 화면값으로 변환하고 다이얼로그 위치를 이동한다.
  ClientToScreen( hParentWnd, &pt );
  SetWindowPos( hWnd, NULL, pt.x, pt.y, 0, 0, SWP_NOZORDER SWP_NOSIZE );
}
 
2006/05/14 00:03 2006/05/14 00:03

덧글을 달아 주세요