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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
// So, this is my WM_CREATE message of my window.
// Here I will create my controls
// This is main_panel, child of the main window.
// I get its bottom and right values correctly, no matter the way I re-size the window
main_panel = CreateWindowEx(
0,
"STATIC",
NULL,
WS_CHILD|WS_VISIBLE|SS_BLACKFRAME,
205, 0, 400, 600,
hWnd,
(HMENU)MAIN_PANEL,
hInstance,
NULL
);
// This is head_panel, child of main_panel, "grandchild" of the main window
// For this one I get the right and bottom values correctly, too
head_panel = CreateWindowEx(
0,
"STATIC",
NULL,
WS_CHILD|WS_VISIBLE|WS_VSCROLL,
5, 21, 390, 580,
main_panel,
(HMENU)HEAD_PANEL,
hInstance,
NULL
);
// I sub-classed this control, in order to get some messages that I don't get
// if they are sent to the main window's message handler
orig_hpanel_proc = (WNDPROC)SetWindowLong(head_panel, GWL_WNDPROC, (LONG)head_proc);
// Now, this is the control of which right and bottom
// values are wrong when I re-size the window (not when the first re-sizing is made)
title_panel = CreateWindowEx(
0,
"STATIC",
"This is my title",
WS_VISIBLE|WS_CHILD,
5, 10, 300, 20,
head_panel,
(HMENU)TITLE_PANEL,
hInstance,
NULL
);
// So, I will place the function that gets me all the size and position information here
int window_props(HWND hwnd, int info) {
int value = 0;
GetClientRect(hwnd, &rect);
switch (info) {
case WIDTH:
value = rect.right - rect.left;
break;
case HEIGHT:
value = rect.bottom - rect.top;
break;
case TOP:
value = rect.top;
break;
case LEFT:
value = rect.left;
break;
case BOTTOM:
value = rect.bottom;
break;
case RIGHT:
value = rect.right;
break;
}
return value;
}
|