SetWindowPos´Â Ŭ¶óÀÌ¾ðÆ® ÁÂÇ¥¸¦ »ç¿ëÇϴ°ɷΠ¾Ë°í ÀÖ½À´Ï´Ù.
±×·¡¼
case WM_LBUTTONDOWN:
SetWindowPos(hBtn, NULL, LOWORD(lParam), HIWORD(lParam), 0, 0, SWP_NOSIZE | SWP_NOZORDER);
return 0;
ÀÌ¿Í °°ÀÌ ÀÛ¼ºÇصµ ¸¶¿ì½º·Î Ŭ¸¯ÇÑ À§Ä¡·Î À©µµ¿ìÀÇ ÁÂÇ¥°¡ º¯°æµË´Ï´Ù.
±×·±µ¥, À©µµ¿ì¸¦ ºÎ¸ðÀ©µµ¿ìÀÇ Áß½ÉÀ¸·Î À̵¿½ÃŰ´Â °úÁ¦¸¦ Ǫ´Â Áß¿¡ ÀÌ¿Í °°Àº ÇÔ¼ö¸¦ ÀÛ¼ºÇߴµ¥
void MoveToParentCenter(HWND hWnd)
{
HWND hWndParent = GetParent(hWnd);
WINDOWPLACEMENT WndPl;
WndPl.length = sizeof(WINDOWPLACEMENT);
GetWindowPlacement(hWndParent, &WndPl);
if (WndPl.showCmd == SW_MINIMIZE) {
ShowWindow(hWndMain, SW_SHOWNORMAL);
}
GetClientRect(hWndParent, &WndPl.rcNormalPosition); //GetWindowPlacement ÇÔ¼ö°¡ ȸéÁÂÇ¥¸¦ Á༠´Ù½Ã ÁÂÇ¥ ±¸ÇÔ.
RECT hrt; GetClientRect(hWnd, &hrt);
hrt.left = WndPl.rcNormalPosition.right / 2 - hrt.right / 2;
hrt.top = WndPl.rcNormalPosition.bottom / 2 - hrt.bottom / 2;
SetWindowPos(hWnd, hWndParent, hrt.left, hrt.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
}
Á¤»óÀûÀ¸·Î µ¿ÀÛÇÏÁö ¾Ê°í ¿ÀÈ÷·Á À̵¿½Ãų À©µµ¿ì°¡ ¸ÞÀÎ À©µµ¿ìÀÇ È¸é ¹ÛÀ¸·Î ³ª°¡´Â °æ¿ì°¡ ¹ß»ýÇß½À´Ï´Ù.
°á±¹ 2°¡Áö Àǹ®À» °®°Ô µÆ´Âµ¥ ´äº¯ÇØÁÖ¼ÌÀ¸¸é ÇÕ´Ï´Ù.
1. GetWindowPlacement ÇÔ¼ö¸¦ »ç¿ëÇϸé ÀÛ¾÷¿µ¿ª(Client) ÁÂÇ¥¸¦ ±¸ÇÒ ¼ö ÀÖ´Ù°í Çߴµ¥ ¿Ö ȸ鿵¿ª(Window) ÁÂÇ¥¸¦ ¾ò°Ô µÈ°Ç°¡¿ä?
2.SetWindowPos´Â ÀÛ¾÷¿µ¿ª ÁÂÇ¥¸¦ »ç¿ëÇÑ´Ù°í ¹è¿ü½À´Ï´Ù. ±×·¸´Ù¸é À̵¿½Ãų À©µµ¿ì¿Í ÀÛ¾÷¿µ¿ª ÁÂÇ¥¸¸À» Áִµ¥ ÀÌ ÀÛ¾÷¿µ¿ª ÁÂÇ¥´Â ¾î´À À©µµ¿ì¸¦ ±âÁØÀ¸·Î ÇÑ °ÍÀԴϱî? À̵¿½Ãų À©µµ¿ìÀÇ ºÎ¸ðÀ©µµ¿ìÀΰ¡¿ä?
ÀÌ µÎ °¡Áö Àǹ®¸¸ ÇØ°áµÇ¸é °úÁ¦¸¦ ¿øÈ°ÇÏ°Ô ¼öÇàÇÒ ¼ö ÀÖÀ» °Í °°Àºµ¥, Á¦°¡ ´õ ¾Ë¾Æ¾ß ÇÏ´Â°Ô ÀÖÀ¸¸é ¾Ë·ÁÁÖ½Ã¸é °¨»çÇϰڽÀ´Ï´Ù.
Âü°í·Î Á¦°¡ ¸¸µç Äڵ忡¼ SetWindowPos ÇÔ¼ö¸¦ ½ÇÇàÇßÀ» ¶§ ¸Å°³º¯¼ö·Î ÁØ x,y°¡ ȸéÁÂǥó·³ ¾²¿´½À´Ï´Ù. À̰͵µ ¿Ö ±×·±Áö ¸ð¸£°Ú½À´Ï´Ù. |
|