C++/MFC
MFC 리소스로 만든 다이얼로그 사이즈 변경
kimc
2021. 6. 4. 22:42

MFC에서 CPP 프로그래밍 동적으로 다이얼로그 사이즈를 변경
방법 1
다이얼로그 윈도우 사이즈와 위치를 직접 정한다.
MoveWindow(int x, int y, int Width, int Height);
방법 2
기존의 다이얼로그 윈도우 사이즈와 위치를 참조해 작성한다.
아래 코드는 사각형 위치에 x축과 y 축 모두 10을 더하고 너비와 높이에 모두 10을 더한 경우임
CRect rec;
GetWindowRect(&rec);
int Dif1 = 10;
int Dif2 = 10;
int Dif3 = 10;
int Dif4 = 10;
MoveWindow((rc.left + Dif1), (rc.top + Dif2), (rec.Width() + Dif3), (rec.Height() + Dif4));
인자값
x(int): 새로운 윈도우의 왼쪽 위치 값
y(int): 새로운 윈도우의 상단 위치 값
nWidth(int) : 새로운 윈도우의 너비
nHeight(int): 새로운 윈도우의 높이
참조
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-movewindow
MoveWindow function (winuser.h) - Win32 apps
Changes the position and dimensions of the specified window.
docs.microsoft.com
728x90