Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top