Pelles C forum
C language => Windows questions => Topic started by: tdc on January 12, 2016, 10:31:02 PM
-
I created a window and added an edit box with associated button as child window.
How can I get the child window to resize when the parent window is resized with dragging a corner or edge or with the maximize button?
-
The easy way to do it is by using the resizer library provided by Pelles C.
(The problem being that this library is only available on Pelles C.)
How to:
- Project options -> Linker -> Library and object files (add resizer.lib to the list)
- in your program code: add #include <resizer.h>
- in your program code: replace call to CreateDialog() with CreateResizableDialog()
- in your program resources: set each control Properties for "Vert resizing" and "Horz resizing"
For more details see the Pelles C help file, Appendix -> Resizable dialogs.
The hard (and portable way) is probably more work than it's worth, so you're on your own...
-
Thank you very much
-
Handle EDIT-window position in WM_SIZE message
Example dialog with grip.#define WIN32_LEAN_AND_MEAN
#include <windows.h>
LRESULT CALLBACK MainDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
int __cdecl WinMainCRTStartup(void)
{
ExitProcess(DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(1001), NULL, (DLGPROC)MainDlgProc, 0));
}
LRESULT CALLBACK MainDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static HWND hGrip, hEdit;
switch (uMsg)
{
case WM_SIZE:
MoveWindow(hGrip, LOWORD(lParam)-20, HIWORD(lParam)-20, 20, 20, TRUE);
MoveWindow(hEdit, 4, 40, LOWORD(lParam)-8, HIWORD(lParam)-50, TRUE);
return TRUE;
case WM_INITDIALOG:
hGrip = GetDlgItem(hwndDlg, 4001);
hEdit = GetDlgItem(hwndDlg, 4002);
SetWindowPos(hwndDlg,0,0,0,250,200,SWP_NOMOVE);
return TRUE;
case WM_CLOSE:
EndDialog(hwndDlg, 0);
return TRUE;
}
return FALSE;
}
#include <windows.h>
LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US
1001 DIALOGEX DISCARDABLE 6, 18, 210, 146
STYLE DS_SHELLFONT|WS_POPUP|DS_MODALFRAME|DS_3DLOOK|DS_NOFAILCREATE|DS_CENTER|WS_THICKFRAME|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_VISIBLE
CAPTION "Dialog"
FONT 8, "Tahoma", 0, 0, 1
{
CONTROL "OK", IDOK, "Button", WS_TABSTOP, 4, 4, 45, 15
CONTROL "Cancel", IDCANCEL, "Button", WS_TABSTOP, 52, 4, 45, 15
CONTROL "", 4001, "ScrollBar", SBS_HORZ|0x00000014, 200, 132, 18, 18
CONTROL "Edit", 4002, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 4, 24, 204, 108
}
-
Thank you - this is very helpful. I appreciate