Resize a dynamic dialog - Updating font size of text controls

Started by cssyphus, January 11, 2022, 07:45:27 AM

Previous topic - Next topic

cssyphus

I have allowed users to resize and reposition a dynamic dialog. I would like to adjust the font size of the STATICTEXT/VARYTEXT controls as the dialog is resized, so that words do not disappear as borders change. When I use a variable in the dialog definition, thus:

TestWin003=`008,042,200,080,STATICTEXT,"SuPb_St01",DEFAULT,%vt_AdjustWin%,DEFAULT,500,DEFAULT,"Microsoft Sans Serif|%_dlgFontSize%|40|34","%t_DlgTextColor%",DEFAULT`

the text size does not change during the resize activity. So how can I do this?  My second thought was that there might be a DialogControlSet() setting for that, but I am not seeing one that affects the font settings of a STATICTEXT or VARYTEXT control.

I also tried setting:
   DialogProcOptions(tw2_Hnd, @dpoDisable, 3)
before changing the _dlgFontSize value, and then
   DialogProcOptions(tw2_Hnd, @dpoDisable, 0)
after changing the _dlgFontSize variable value (thinking that might force the dialog to redraw), but no joy.

There must be a way to do this since there is a resize event and one can watch the values of the dialog's width/height change in tiny increments... surely there must be a way to change the size and position of the text in the dialog as its dimensions change..?

td

As is often the case with previously plowed subjects, there are numerous examples of dialog control moving and resizing in the Tech Database. Below is a randomly selected link to one of them:

https://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/Dialog~Editor/Dialog~Editor~version~6.2/Samples+Resize~Dialog~and~Controls~Dynamically.txt

Perform a Tech Database search to find more examples.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

cssyphus

Tony, I'm sorry to be obtuse, but I don't see anything in that example - or in any of the other dynamic dialog examples in that folder - about the font size of STATICTEXT/VARYTEXT controls.

I see that one can show/hide controls, get the new dimensions of the dialog, change the positioning in the dialog of the controls -- but nothing about changing the font size. 

Is it necessary to use DEFAULT in the font field in order for the text to dynamically resize, or does STATIC/VARY text font-size simply not resize until the dialog is closed/reopened?

If I've missed something right in front of my face (a distinct possibility with my nystagmus condition), would you mind pointing it out?

td

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

cssyphus

With respect Tony, plowed territory to you and the mavens but not to me... first time I'd even imagined such a question.

Thank you very much for pointing me to this specific article and to the exact place in the article that answers my question. I now understand how to proceed.

td

Quote from: cssyphus on January 11, 2022, 01:06:10 PM
With respect Tony, plowed territory to you and the mavens but not to me... first time I'd even imagined such a question.


The point is to have some consideration of those that take the time to answer posts. Perform a thorough search of the available resources before asking a question. Sometimes you need to take a few stabs with different terms when searching the Tech Database before you find an answer.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

Admittedly, the Tech Database search engine is a bit rudimentary by today's Web search engine standards. It takes a little getting used to, patience, and some creativity but good information can usually be found. We are always looking for a better search approach that doesn't also compromise WinBatch user privacy. We just haven't found one that meets our standards yet.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

archimede

Hallo.
I have a similar problem.
WinBatch engineer told me WinBatch no supports font resize.
I made a very complex system to obtain it: it no works fo a continuous resize, bu only, for example, for zooming full screen or resize normal.
Are you interested?
I tell you it is a very complex system...

Archimede

cssyphus

Hi Archimede,

Yes, I am interested to see your solution, thank you for offering to share.

If you have solved that problem, then maybe you also know the answer to my most current problem re translating dialog units to screen units. Are you willing to look at that problem also? You might already know the answer "off the top of your head"... If so, then I will open a new question to describe that other problem. (I've been "banging my head against the wall" re that problem for a few days now...)

Again, many thanks for your kind offer.

td

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

archimede

Hallo.
Like I told you before, the solution is no simple, is hard; and after this, it no works if you no exit and re-enter in the Dialog managing with Dialog (...) function.
Before all you must declare all varialbles that defines Dialo like global.
I made a subroutine to make that, but it is all Italian commented (yes, I am Italian and you?): is it right for you?

archimede

Hallo.
If you need to know translation from dialog unit to screen pixels to right calculate the new font dimension, with my method it is no necessary to know it.

cssyphus

Yes, I am interested to see your solution. Thank you Archimede.

archimede

I am sorry for my bad English.
Now I am far to my computer, then I can tell some things; tomorrow I will begin to send you some function.
The trick is to modify the variables that defines the dialog (that are at the common level in the program) from the internal of the function that manages all dialog event: is necessary to modify a dialog from the internal of the dialog!
Before all, at the common level (I think you define the dialog at the common level) you must declare global all variables that defines the dialog.
From the internal of the function that manages dialog event you must declare a persistent pointer for every global variable.
After that you can use the persistent pointer to modify a variable that defines the dialog (that is at upper level, but from the internal of a function is possible to modify an external variable by the pointer to that variable): in that mode you can define a new font and a new dimension font for the variable that defines dialog.
After that you have no finished: the dialog variables was red before, then the new changes have no effect: now you must exit from the dialog and re-enter with Dialog (...) function: now the Dialog (...) function read new values of the dialog define variables, with the new font definitions.
I explained you all now to help you to understand all futures functions that I can send (when I will near to my computer).