Pelles C forum

C language => Work in progress => Topic started by: John Z on November 17, 2025, 12:01:10 PM

Title: New resizer discussion
Post by: John Z on November 17, 2025, 12:01:10 PM
Resizing can be quite tedious -
I developed this resizing method for my Vcardz_i program https://forum.pellesc.de/index.php?topic=10191.0  which is resizing over 40 ontrols smoothly but that was hand coded control by control. 

Now I've taken the concept and made it generic and 'automatic' suitable for a library and a header file or just two source files.

Attached are three small test files comparing the existing resizer and the new zsizer (temp name  :) )
Test demos for the existing resizer and the developing one:
resizerP_move.exe -> existing resizer.lib and header (all set to 'move',except toolbar to resize)
resizerP_resize.exe -> existing resizer.lib and header (all set to 'resize')
Zsizer_new.exe  -> every thing resizes. however for demo one can set pushbuttons to move only, using the 'Toggle Button Size' as a demo.
This new resizer allows smaller than original which the existing resizer does not - to emulate original use the 'toggle Min Size' button as a demo.

So far the new method adds 9k to the exe (no optimization used yet) compared to the existing resizer.

This is not complete nor perfect so I'm looking for any inputs -
Right now there are three commands, I've not made it into a library yet -
extern int Init_Resizer(HANDLE win, int n);
extern void Form_Resize(HANDLE hwinmain, int num_window);
extern void Free_zsizer(void);

It does not access the control properties for Resizable Dialogs as I don't know how to get those settings.

Using it just involves two files zsizer.h, zresizer.c or one file and a library
Nothing is subclassed, but might need to. The resize method and calculation method would still work within the existing resizer framework I believe. (it's only math  ;D )

Not every control is happy re-sizing - I don't know if it will work with 'Owner draw' controls yet either.

John Z
Title: Re: New resizer discussion
Post by: TimoVJL on November 17, 2025, 12:26:41 PM
One idea is to put resizable control id list under first id
and collect startsize to an array of rects.
When window size change, count new coefficient and size controls with it.
This method might work with DWM too.
That idea have been used with control / button grids, like games.
Title: Re: New resizer discussion
Post by: John Z on November 17, 2025, 12:39:53 PM
Hi Timo,

That is basically what it does. Given the 'main' window handle it enumerates the controls, stores base values and the 'main' window size. Then upon WM_Size it uses that data and the percent change of the 'main' form applied to each control position/size parameters for a 'move' command.  Nothing is stored upon a resize event so little overhead, only stored when init_resizer is used under WM_INITDIALOG.

John Z
Title: Re: New resizer discussion
Post by: TimoVJL on November 17, 2025, 09:37:45 PM
A simple example of resize difficulties and why it isn't so easy.
Title: Re: New resizer discussion
Post by: John Z on November 19, 2025, 11:21:17 AM
Here is a next iteration.  The zsizer can now also resize Child dialogs.
Still using just the three functions  -
Init_Resizer. Form_Resize, and Free_zsizer.

Click the 'Next Dialog' button to invoke the child dialog.

Child form also tests more control types being resized too.


John Z