Window Client Area

I have created a windows with WS_SIZEBOX so the user can resize it. This window contains a Header View and a List View. When I change the size of the window, neither the Header View nor the List View are changing and not been resized. I captured the WM_SIZING message in the window handler as below, but both controls are disappearing. I don't know why. See below code:

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
29
30
31
32
33

LRESULT CALLBACK BsolPopWndProc (HWND hWnd_p, UINT msg_p, WPARAM wParam_p, LPARAM lParam_p) {
RECT * rc_v;
HWND hvWnd_v, lvWnd_v;
WINDOWPOS wp_v;
HDLAYOUT hdl_v; 

switch(msg_p) {
case WM_SIZING: 
	rc_v = (RECT*)lParam_p;

	hvhWnd_v = GetDlgItem (hWnd_p, 2601);
	lvhWnd_v = GetDlgItem (hWnd_p, 2602);

	hdl_v.prc = rc_v;
	hdl_v.pwpos = &wp_v;

	if (!SendMessage (hvWnd_v, HDM_LAYOUT, 0, (LPARAM) &hdl_v))
		return NULL;

	SetWindowPos (hvWnd_v, wp_v.hwndInsertAfter, rc_v->left, rc_v->top, 
		      rc_v->right - rc_v->left, wp_v.cy, wp_v.flags | SWP_SHOWWINDOW);
	RedrawWindow(hvWnd_v, NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW | RDW_VALIDATE);

	SetWindowPos (lvWnd_v, NULL, rc_v->left, rc_v->top + wp_v.cy, 
		      rc_v->right - rc_v->left, rc_v->bottom - rc_v->top - wp_v.cy, 
		      SWP_NOZORDER | SWP_SHOWWINDOW);
	RedrawWindow(lvWnd_v, NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW | RDW_VALIDATE);
	break;
}
return DefWindowProc(hWnd_p, msg_p, wParam_p, lParam_p);

}

Please let me know what is wrong and what is missing in my code.
This is giving me headache..
You are using the wrong rectangle;
1
2

rc_v = (RECT*)lParam_p; //ERROR - This is the drag rectangle which is the screen corordinates of the drag outline 


You need to use the client area rectangle.


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
29
30
31
32
33
LRESULT CALLBACK BsolPopWndProc (HWND hWnd_p, UINT msg_p, WPARAM wParam_p, LPARAM lParam_p) {
RECT  rc_v; //<<==No longer need to be a pointer
HWND hvWnd_v, lvWnd_v;
WINDOWPOS wp_v;
HDLAYOUT hdl_v; 

switch(msg_p) {
case WM_SIZING: 
	//rc_v = (RECT*)lParam_p; //<<==Remove 
          GetClientRect( hWnd_p, &rc_v); // <<==Add this line

	hvhWnd_v = GetDlgItem (hWnd_p, 2601);
	lvhWnd_v = GetDlgItem (hWnd_p, 2602);

	hdl_v.prc =&rc_v; //<<==this line updated
	hdl_v.pwpos = &wp_v;

	if (!SendMessage (hvWnd_v, HDM_LAYOUT, 0, (LPARAM) &hdl_v))
		return NULL;

	SetWindowPos (hvWnd_v, wp_v.hwndInsertAfter, rc_v->left, rc_v->top, 
		      rc_v->right - rc_v->left, wp_v.cy, wp_v.flags | SWP_SHOWWINDOW);
	RedrawWindow(hvWnd_v, NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW | RDW_VALIDATE);

	SetWindowPos (lvWnd_v, NULL, rc_v->left, rc_v->top + wp_v.cy, 
		      rc_v->right - rc_v->left, rc_v->bottom - rc_v->top - wp_v.cy, 
		      SWP_NOZORDER | SWP_SHOWWINDOW);
	RedrawWindow(lvWnd_v, NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW | RDW_VALIDATE);
	break;
}
return DefWindowProc(hWnd_p, msg_p, wParam_p, lParam_p);

}



EDIT:
I would expect header window to appear near or at the top of the client area.
(We can always adjust this function
1
2
SetWindowPos (hvWnd_v, wp_v.hwndInsertAfter, rc_v->left, rc_v->top, 
		      rc_v->right - rc_v->left, wp_v.cy, wp_v.flags | SWP_SHOWWINDOW);

for fine positioning))
Last edited on
Topic archived. No new replies allowed.