Hi Art,

I got your program and ran it on both my Windows 7 system and on a XP system.  These are 2 different physical machines.

On both systems the dialog looks good, nothing is over-flowed.  To the eye they look the same size.

For the text size print out I get on Windows 7:

Static Text Width, height: 64 16
On my Win7 it was 80:20
On my XP it was 64:16
ListBox Width, height: 496 16
On my Win7 it was 620:20
On my XP is was 496:20

and on XP:

Static Text Width, height: 64 16
On my Win7 it was 80:20
On my XP it was 64:16
ListBox Width, height: 496 16
On my Win7 it was 620:20
On my XP is was 496:20

So on my systems everything is good.

The whole dialog size / font / font size thing is rather complex under the covers.  It is intended to ensure that the same dialog looks okay no matter what physical system it is running on.  It is not intended to make the dialog the exact same pixel size on two different systems.

So, what I would expect, is what I see on my system, the dialog looks okay and everything fits.  What you described, that the text is too wide to fit on your Windows 7 system, is something I wouldn't expect.

What can you do about it?  I'm not sure.  It is not something that ooDialog is doing, all ooDialog does is pass the numbers on to the operating system.

About fonts, fonts are requested from the font mapper.  The font mapper returns a logical font that is the best it can do to match the requested font.  What this means is that you don't necessarily get the exact font you asked for, you get the best the font mapper can come up with.  This allows, for instance, an application to use a font that doesn't actually exist on the current system.

The OS calculates the size and position of all the dialog controls based on the actual font used in dialog.

When you assign a different font to a dialog control than the actual font used by the dialog, this invalidates the OS's calculation for the size and position of the control.

What I suspect is happening is that on your XP system, the font mapper is returning a Courier New font that is very close in size to the System font used by the dialog.  Everything looks the same as you see when you lay out the dialog.

On my Windows 7 and XP systems the font mapper is returning a Courier New font that is the same size as the System font used by the dialog.  On your Windows 7 the font mapper is returning the best it can, but the Courier New font returned is not a good match in size for the System font actually used by the dialog.  

And, it could actually be the returned System font that is different on your Windows 7 and XP systems.

You might try naming Courier New in the .rc file instead of System.  For your simple test example, this would be okay.  But, it means every control in the dialog will use the Courier New font and if you have a lot of controls that might not look good.

There are 2 scenarios here, and I'm not sure which applies. 1.) You just want to fix this on your own XP system, your program is for your use only.  You are distributing your program to a group of end users.

Scenario 1.)  Ensure that the display settings are the same on the two systems.  In particular, check the DPI settings.  I just saw that on my Windows 7 system under custom DPI settings, there is a check box that says Use XP style DPI scaling.  Hmm ...

Ensure that both systems have the same Courier New font installed.

With some extra work, you could resize the controls to fit in initDialog() using the getTextSizePx method.

Scenario 2.)  Test on some of your users systems, maybe there is no problem, their systems behave just like mine.

Same as the last resort for scenario 1.  Calculate the size needed and resize the controls in initDialog().  This could be a lot of work depending on how finicky you are.  To get this right, you might have to resize and move everything.

But, it is doable.  I know one ooDialog user who calculates the size and position of every control and resizes / repositions them all in initDialog().  With dialogs that contain hundreds of controls.

Mark Miesfeld

On Sat, Aug 10, 2013 at 5:53 AM, Art Heimsoth <artstore@artheimsoth.com> wrote:
> On Fri, Aug 9, 2013 at 5:54 PM, Art Heimsoth
>> I have an ooDialog application that I have tested on different
>> systems and
> have found an operational difference that I don't understand.  I
> have several LTEXT controls and some LISTBOX controls built into a
> RC file. I use the LTEXT to build column headings for the detail
> data that is placed in the LISTBOX and the LTEXT static to use
> "Courier New", 10, "BOLD" and the LISTBOX to use "Courier New", 10.
>  When running on an XP system, the LTEXT and LISTBOX both "fit"
> into the main dialog window, but when on a Win7 system (either 32
> or 64 bit), the static text and also the text data added to the
> LISTBOX exceed the width of the containing element. I then added
> getTextSizePx calls for the text that is in each of a sample of the
> static text and the listbox.  On the Win7 system, the sample for
> the static text was a width of 80 while on the XP it is 64 and the
> listbox item is 620 for the width on the Win7 system while it is
> 496 on the XP. That equates to the XP being less pixels by 4/5 of
> the Win7, yet the main dialog appears to be the same size.  
> Hi Art,
> There are a number of different things at play here.  I have
> several speculations, but it is just speculation.  ;-)
> If you had an example program you could send me, I'll run it on my
> Windows 7 system and on my XP.  I can probably give you an answer
> based on facts then.
Hi Mark,
I will see what I can cobble together that will show this problem.

 Art Heimsoth - artstore@artheimsoth.com

Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
Oorexx-users mailing list