Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- write
- bitcoin
- API
- Linux
- File
- windows
- Callback
- window
- Sync
- Golang
- GO 언어
- go
- C
- 책
- mutex
- Close
- http
- install
- c++
- 영화
- tcp
- range
- Python
- json
- channel
- 리뷰
- package
- FOR
- JavaScript
- go언어
Archives
- Today
- Total
Code Habit
[WinAPI] 윈도우 크기 변경 ( SYS_COMMAND, SC_SIZE 사용 ) 본문
팝업 윈도우를 생성하고 직접 메시지를 이용해 윈도우 크기 변경하고 싶을 때 윈도우 메시지 WM_SYSCOMMAND, SC_SIZE를 활용할 수 있다.
WM_LBUTTONDOWN 메시지 함수에서 다음과 같이 처리하면 된다.
SendMessage(WM_SYSCOMMAND, SC_SIZE | HT_BOTTOMRIGHT);
HT_BOTTOMRIGHT는 마우스 포인터가 해당 윈도우의 어디 부분에 위치해 있는지를 정해주는 값이므로 마우스 포인터가 위치하는 경계선 기준에 따라 아래와 같은 값들을 주면 된다.
( 위 예제 코드를 활용하여 실제 마우스 L버튼 클릭 후 드래그 하면 팝업 윈도의 오른하단 경계부분을 클릭 후 resize하는 것마냥 동작한다. )
#define HT_NOWHERE 0 // On the screen background
#define HT_LEFT 1 // In the left border of a resizable dialog
// (the user can click the mouse to resize the dialog horizontally)
#define HT_RIGHT 2 // In the right border of a resizable dialog
// (the user can click the mouse to resize the dialog horizontally)
#define HT_TOP 3 // In the upper-horizontal border of a dialog
// (the user can click the mouse to resize the dialog vertically)
#define HT_TOPLEFT 4 // In the upper-left corner of a dialog border
// (the user can click the mouse to resize the dialog diagonally)
#define HT_TOPRIGHT 5 // In the upper-right corner of a dialog border
// (the user can click the mouse to resize the dialog diagonally)
#define HT_BOTTOM 6 // In the lower-horizontal border of a resizable dialog
// (the user can click the mouse to resize the dialog vertically)
#define HT_BOTTOMLEFT 7 // In the lower-left corner of a border of a resizable dialog
// (the user can click the mouse to resize the dialog diagonally)
#define HT_BOTTOMRIGHT 8 // In the lower-right corner of a border of a resizable dialog
// (the user can click the mouse to resize the dialog diagonally)
#define HT_BAR 9 // In the bar area
// (the user can move the dialog)
참고로 위 정의된 값들은 WTL 기준이고 WinAPI 기준 값들은 다음 링크를 참고한다. https://learn.microsoft.com/en-us/windows/win32/inputdev/wm-nchittest