News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

New resizer discussion

Started by John Z, November 17, 2025, 12:01:10 PM

Previous topic - Next topic

John Z

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

TimoVJL

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.
May the source be with you

John Z

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

TimoVJL

A simple example of resize difficulties and why it isn't so easy.
May the source be with you

John Z

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

Vortex

Code it... That's all...

John Z

Hi Vortex,

Thanks - I think even though there are still some improvements to make I need to try to make a library now and test that usage.

I still need to test an owner-draw control too.

So far there are just three options that can be set/reset
1) do not shrink smaller than original size
2) do not resize std pushbuttons
3) do not resize the calendar

These can be set or reset anytime in the 'host' program.


John Z

John Z

#7
Hi All,

Well here is the first pass library to try !

I've tested it making three different non-resizable programs, one was Hint_SA, into resizable dialogs, and they all were very successful. Just add three lines of code.

A library and a header file are in the attachment.  Both are needed.
The header file includes instructions and tips on using the library.

One thing I do in vcardz_i is also optionally resize the Font with the dialogs.
Wondering if that would be useful in this Library?

Of course any success or especially failure feedback is very important to the completion of this resizing capability.

John Z