NO

Author Topic: windows  (Read 938 times)

tdc

  • Guest
windows
« 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?

Snowman

  • Guest
Re: windows
« Reply #1 on: January 12, 2016, 11:17:47 PM »
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...

tdc

  • Guest
Re: windows
« Reply #2 on: January 13, 2016, 12:48:02 AM »
Thank you very much

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1596
Re: windows
« Reply #3 on: January 13, 2016, 08:55:25 AM »
Handle EDIT-window position in WM_SIZE message
Example dialog with grip.
Code: [Select]
#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;
}
Code: [Select]
#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
}
« Last Edit: January 13, 2016, 09:15:27 AM by TimoVJL »
May the source be with you

tdc

  • Guest
Re: windows
« Reply #4 on: January 13, 2016, 09:49:04 PM »
Thank you - this is very helpful. I appreciate