Welcome! Log In Create A New Profile

Advanced

How to resize fonts at runtime

Posted by Brian 
Brian
How to resize fonts at runtime
June 25, 2009 11:31PM
Hello,

Is there a way to at runtime change font size for a browse / window and have that window automatically resize?

I am using Windev 12 or 14.

Cheers

Brian
Brian
Re: How to resize fonts at runtime
July 06, 2009 08:13PM
So the lack of response to my post means it can not be done?

Brian
Al
Re: How to resize fonts at runtime
July 06, 2009 11:42PM
Hello Brian

The fonts can be changed but I could find nothing in the doco about resizing the window because of it, which seemed to be the critical part of your question, although the GUI option in the window editor "Resizes to fit the content" may work for you.
The font change could be done with the ..font command wrapped up in if/else or case structure, but would have to be done for each control and static etc.

Regards
Al
Jimbo
Re: How to resize fonts at runtime
July 07, 2009 07:23AM
Brian, of course, it can be done. Each control has properties, the relevant ones for control size (windows too!) are
..height
..width

In order to change font size, the property
..size
will do.

Guenter
Brian
Re: How to resize fonts at runtime
July 07, 2009 02:25PM
Thanks for the responses.

I am a newbie and coming from Clarion. I thought maybe there was a Project setting that would globally apply this feature. In Clarion I used a template called AnyFont by CapeSoft which made this possible globally.

Cheers

Brian
Fabrice Harari
Re: How to resize fonts at runtime
July 07, 2009 06:20PM
Hi Brian...

I'm not sure it's waht youa re looking for, but there is an available setting in the details of each window saying that if WINDOWS is set to use 'large fonts' then the window should expand (not by default)

Best regards

Jimbo
Re: How to resize fonts at runtime
July 07, 2009 07:18PM
Hi Al, I had such a question once. The guy had bad eyes and wanted to have our standard product - but only with big font, not Verdana 9pt bold as it is right now. I stated that the product is as it is because he'd have pay a lot for a re-do of the user interface (about 150 windows). But I've been thinking a lot about that since then. This would involve to reposition and resize most controls, set fonts & sizes and so on. Easier to have two otherwise identical products, means one would have to have the code separated from the GUI in order to be able to maintain just one copy of the code and two copies of the GUI.
Kind regards,
Guenter
Chris L
Re: How to resize fonts at runtime
July 12, 2009 04:20PM
Brian

I notice you've already had a number of postings on this so you may already have your answer. Just in case you're looking at something further, here are a few of my ideas, some of which I have used in applications of my own, others I have just tested following your post.

FONT SIZE

1. Changing font size.

You can change the font size on virtually any control. That includes static text and buttons of course but also edit fields, tables, list boxes, and so on. The property ..FontSize is what is required here. So you can have something like
ControlName..FontSize = 12
But you can also have
ControlName..FontSize = nNewFontSize
where nNewFontSize is a variable determined however you want. And even something like
ControlName..FontSize = ControlName..FontSize * 1.2
or
ControlName..FontSize = ControlName..FontSize * nResizeFactor

2. Grouping controls

This procedure is fine if you just have one or two controls but it becomes very tedious if you want to change the font size on a heap of controls. One way of doing this is by grouping controls. This is often done with buttons so that they can be treated as one unit for some purposes but there's nothing stopping you from creating a group from say all your edit fields. In this case, you can use the ..FontSize property on the group which will then change the font sizes of all the controls in the group.
GR_EditControls..FontSize = 12
That has the restriction that grouped controls will all have the same font size.

3. Looping through controls

Another way of changing the font size (or other characteristics such as font colour) on a number of controls is simply to loop through all the controls on a window. There is a function EnumControl which makes fairly easy work of this. (Look up 'Enumerate controls' in the Help file.) This approach has several advantages. Firstly, you can handle hundreds of controls with the same ease as you would handle just a few. Secondly, you can work on just one type of control, or applying different settings to different types of controls. And thirdly, you can resize controls with different font sizes proportionately.


WINDOW SIZE

When I first read your post, I took it that you wanted to resize a window and have the fonts change proportionately.

4. Control behaviour

I find the more I delve into WinDev, the more I find I can do. The ability to specify how controls react, ie whether they move or remain anchored, whether they expand or stay the same size, when you resize a window has been in WinDev for some time but the options seem to be increasing with each new version of WinDev. For the current application I'm working on I've chosen a basic screen size of 1024 x 768, figuring this is probably the minimum anyone would use nowadays. But I'm also conscious that many people are using screens with much higher resolutions. When I recently demonstrated a prototype of my current application, the user maximised the window and I was rather embarrassed to see what happened when the 1024x768 window was expanded to 1920x1200! Everything was clustered in the top left quadrant of the screen with acres of empty background everywhere else. I promptly set about specifying the anchoring characteristics of each control, a somewhat laborious process but with a much more pleasing result.

But resizing proportionately doesn't always work. OK it works functionally but it doesn't always look the best or provide the most useful functionality. In my example, I'm almost doubling the width if I expand to fill a 1920x1200 screen but doubling the width of a table leaves a heap of white space, or alternatively ridiculously wide columns. I wanted the table to widen a little bit but not by the same amount as the screen. And hey presto! in version 14 (and maybe in previous versions - I've only just discovered this) you can specify exactly what percentage you want your controls to expand or move. So my main table I want to move 100% with the resizing of the window so it always goes down the length of the window but it will only expand by 20%. That's nifty! It gives you very useful control of the resizing of controls and enables you to produce windows which look good at any size.

5. Determining the size

More properties, this time of windows.

To determine the current width and height of a window, there are the obvious properties of ..Width and ..Height. If you want the dimensions of the window you're in, MyWindow..width and MyWindow..height give you these dimensions.

As you'll see in a moment, it's also useful to know the original width and height of your window. ..InitialWidth and ..InitialHeight provide this.

So if you want to work out by what factor your window has changed size:
nResizeFactor = MyWindow..Width/MyWindow..InitialWidth
(you can of course use height if this is more useful).

You can now link this with the font size as in point 1 above.

But where do you put this code?

This is one of those extra events which isn't listed specifically in the code window. However, it's very easy to access. Simply click on the ellipsis (...) at the bottom of the page, to the right of the various mouse options, and you'll get 'More processes', a list of events. Scroll down and you'll find 'Resizing (WM_SIZE)', click the check box and you'll now have a new code point. This is where you can put your code such as
nResizeFactor = MyWindow..Width/MyWindow..InitialWidth
ControlName..FontSize = ControlName..FontSize * nResizeFactor
(In practice, you may want to add another factor so that the font size increases at a greater rate than the window size.)

6. Resizing the window by programming

After reading through some of the responses to your post and re-reading your original post, it seems that you may wish to resize a window by programming. Simply done again. Just use the ..width and ..height properties to set instead of read these numbers. Thus
MyWindow..width = 1600
MyWindow..height = 1200
Alternatively, you can use the WinSize command which also allows you to specify the position, should you wish.
WinSize(MyWindow,1600,1200)
If you want to know the size of the screen the application is running on, the WinScreenRectangle will supply this information which you can then use. But if you simply want to maximise the screen, use the WinSize command again.
WinSize(MyWindow,MaxSize)


I don't know whether any of this helps you in your situation but perhaps it may give you a few ideas.

Best of luck

Chris L
Melbourne, Oz

Brian
Re: How to resize fonts at runtime
July 13, 2009 02:23PM
Thanks for the detailed reply/s.

I will try the suggestions mentioned.

I think I was a little spoiled. With AnyFont from CapeSoft (Using Clarion) you just drop in the template and you can then at runtime call up a window dynamically and adjust font type, size, colour etc. Then the next time you open a window/form the fonts are larger or smaller and the window / controls are resized accordinally.

Thought PCSoft would have had something like this already.

Thanks for all the help thought.

Cheers

Brian
Chris L
Re: How to resize fonts at runtime
July 13, 2009 03:00PM
Brian

Like many people in this forum, I was a long-time user of Clarion, well over a decade, and like most Clarionistas, I used my fair share of add-on templates. I met Bruce Johnson from Capesoft several times and bought Insight Graphing when it first came out in beta in mid 2000. By the time it finally went gold 5½ years later, I'd long given up Clarion and moved onto WinDev which provided all the graphing capabilities of Capesoft's Insight Graphing plus more, all integrated with the basic package. Ditto for Bruce's FileManager. I am not familiar with Capesoft's AnyFont so I can't make a comparison. It seems that WinDev has the tools to resize windows, controls and fonts but not necessarily all automatically as you suggest with the Clarion package.

However, WinDev has such a history of innovation with a host of new or extended features in each new version, and a history of listening to and working with developers, that it wouldn't surprise me to see such a feature in a forthcoming version.

Cheers

Chris
Ola
Re: How to resize fonts at runtime
July 13, 2009 03:51PM
Chris,

Many thanks for the very educational article you wrote!

Best regards
Ola
heinz kübler
Re: How to resize fonts at runtime
July 13, 2009 11:35PM
hi all,

with the techniqe that chris described, i was able to change the font of an edit control, but not the fontsize of the caption.

By trying around i found one more interesting option:

the "changetemplate " lets you change by programming (=during runtime) the template of a single control or of a window. you just have to prepare and deliver the appropriate template(s) with your software

it behaves similar as the apply template in the Windev IDE

regards, heinz
Chris L
Re: How to resize fonts at runtime
July 14, 2009 03:06AM
Ola

After many years of teaching at both secondary and tertiary level, and many years doing @#$%& training, I find it hard to get out of the 'educational' mode. I'm regularly told off by my friends for this habit!

Chris


Chris L
Re: How to resize fonts at runtime
July 14, 2009 03:10AM
Heinz

Like you, I also discovered that you can't change the font size or other characteristics of captions at runtime, an annoying omission given that you can do so many other things with a control.

I must admit that I haven't explored templates - that could certainly be an option.

My solution is to change the caption to a static, ie set the caption on an edit control to blank and put the static in the place where the caption would be. This is nowhere near as neat as having the caption as part of the control but it does mean that I can re-size this 'pseudo' caption and change its characteristics, font size, colour, etc.

Chris
Jimbo
Re: How to resize fonts at runtime
July 14, 2009 07:27AM
Hi Chris, I believe that the debate over font size alone is definitely not enough.

Resizing fonts of an edit control involves adjusting its size too. In width and in height. This again means that all of the controls below of that edit control will have to be *repositioned* and, of course, resized later on. Doing such an operation automatically for 5 windows may be OK, but doing it for 50 or even 500 windows will inevitably produce a very UGLY application. Additionally, there are limits to making font sizes bigger - at a very early point many windows of an application will become too big for standard screen sizes or tables / combos will not show enough information, making the application unusable. The solution would be to re-arrange controls into tabs or put them onto secondary windows. Nothing automatic anymore.

So, a cost efficient real world application for visually challenged users would involve separate windows for each of those extra font sizes. As an MDI-application I could imagine that the main window would need a resize of the font size for the main menu only plus resizing it and adjusting its initial width & height. Depending on the chosen font size the called windows would be diffently named like AForm_CUSTOMER, BForm_CUSTOMER and CForm_Customer.

The crucial question: What would have to be done to to keep the code of those three windows the same? Or nearly the same?

Just my 2 cents ..
Kind regards,
Guenter


Ola
Re: How to resize fonts at runtime
July 14, 2009 09:53AM
Hi Guenter

I have noted the same problem: it simply is not possible to control the font sized well and easily enough, so I haven't gone into it. I use fontsize only to enlarge some special headers.

I am waiting for WD to get some Opera browser type properties: with a simple keypress you can change the size of the whole window and everything in it in the same proportion. That's the way to do it.

The reason for this size problem is not only elderly people's weakening eye sight (like myself: I have noted that I need separate glasses for reading books and for reading screens). The very high resolution of current display screens is an equally "bad" factor: the higher the resolution, the smaller the windows and the fonts.

So other, more global solutions would be to get better glasses :-), use large fonts in Windows and lower the resolution of the display screen.

I use large fonts in Windows, but this brings problems too. Not all windows are optimized for using large fonts, and then some of the information may get lost into invisibility or require more scrolling. For instance Windev has problems in many of its own windows in this respect, in addition to the sad fact that many of its windows cannot be used without mouse (which in the long run breaks/wears the mouse hand's shoulder).

regards
Ola
Alexandre Leclerc
Re: How to resize fonts at runtime
July 14, 2009 02:18PM
Hi,

This, is not answering challenge for a software approach to bigger fonts, but it gives an hardware solution. smiling smiley

The easiest and simplest solution I could ever think is getting a 22" - 24" monitor for the one user that needs it and set the resolution to 1024x768. It becomes artificially very big and easy to read, and no software changes are required.

Today we can afford that more than ever. Usually the monitor is cheaper than the cost for modifying the software. (Even for couple needy users.)

Regards!
DW
Re: How to resize fonts at runtime
July 14, 2009 02:58PM
Hello All,

One other cheap solution is a example supplied with Windev WD Magnifier. I know it is not what you are looking for but I had to use it and it did help the user.

Dennis W
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: