views:

39

answers:

1

Hi, I think I'm missing something fundamental. Please tell me what it is, if you can.

I have developed a little C++ WinForms app using VS2008. So it is built using .NET 3.5 SP1. My development box is Win7, if that matters.

The default value of UseCompatibleTextRendering property in WinForms controls is false in this version of VStudio. And this should not matter to me, I don't think. I don't have any custom-drawn text or controls.

The app looks good running on my Win7 box.

If I package it up (dragging along .NET 3.5) and install it on one of our WinXP desktops, the buttons and labels don't look good; the text is chopped off in them.

If I set UseCompatibleTextRendering to true and then run it on the XP boxes, the text fits into the buttons and labels.

My question is: Why? The installation puts .Net 3.5 on the XP boxes, so the app should be able to find and use the right version of WinForms, right?

I should note that before I put my app + .NET 3.5 on these boxes, they have no .NET at all. They do not get automatic Microsoft updates; our IT guy gates the patches and upgrades.

[ This sort of thing has happened before with apps I create.. they look/work great on the Engineering machines, because we maintain those and they mostly have up-to-date stuff. When they are run on the corporate boxes, they usually don't run and need the VCredist installed. ]

Back to the question at hand: The text looks better with the UseCompatibleTextRendering set to false, so I'd rather keep it that way, if I can. I'd like to understand what might be missing on those XP boxes that is making the text not fit.

Thanks

S

+1  A: 

It is probably a scaling problem, the XP machine may have a different video adapter DPI setting or a different system font size. Scaling is affected by the form's AutoScaleMode and whether or not they "inherit" the container control's Font property. Which it does if the Font property isn't bold in the Properties window.

One quick way to check if scaling works property in your Form:

protected:
    virtual void OnLoad(EventArgs^ e) override {
        this->Font = gcnew System::Drawing::Font(this->Font->FontFamily, 
            this->Font->SizeInPoints * 125 / 96);
    }

That scales it up. It probably gets scaled down on the XP machine, use 96/125.

Hans Passant
Well that is an interesting point. The controls that are affected do not have the same font size as the form. The font is bigger.As an experiment I just tried changing the form's default font to the bigger size.. the whole thing got bigger (yuck) but the button/label text did not get chopped off on XP.Trying your suggestion now..
HotOil
On the development box, manually scaling the form up with your code produces a scaled up form, with a side effect. The controls with the chopped off text are in a panel on the form.. after scaling the form, the panel isn't appearing.. not sure where it is, need to debug that further. Aside from that. The AutoScaleMode is set to "Font" on the form. I changed it to "DPI" and now it looks good on the XP boxes.. This is good news.. but I am uncertain that is the final solution? What if there is a system font size issue on some other box? It seems that there is no one-size-fits-all fix?
HotOil
Well, no, scaling is an imperfect art. That's why there are *two* values for AutoScaleMode. it is not supposed to make a difference, changing DPI is also supposed to change the base font size. Except on the boxes that you are using. Sigh. Let's all buy 600 DPI monitors.
Hans Passant