Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Controls Are cut in MFC when changing display to 125% in windows 7

I have an MFC application. When running it on Windows 7 I realized that when changing the display percentage to meduium - 125%, I have a TextControl which is cut off (end of sentence doesn't appear.)

How can I fix this?

I could enlarge the size of the control on the dialog, but I'd rather do that via the code. My application is localized and I woudn't want to change all the dialogs on every language.

like image 714
sofr Avatar asked Dec 06 '25 14:12

sofr


1 Answers

In general, the issue is that absolute coordinates are being used for some sizing rather than relative. The framework will initially lay things out correctly in large DPI, it's then up to you to keep things straight through resizes.

You can use a layout framework like this one: Ultimate Toolbox Layout Manager, or you can roll your own.

Here's a common pattern I use:

  1. Define a struct that captures ID, size, location, and layout behavior (anchor top|left|right|bottom) of a control
  2. In the document constructor initialize an array of structs with your desired layout behavior
  3. In OnInitDialog, capture the initial control positions, e.g. for controls set to anchor top left you need to grab the initial distance from the top and left of the parent.
  4. In OnSize, reposition and resize each control according to its layout behavior.
like image 149
Aidan Ryan Avatar answered Dec 09 '25 04:12

Aidan Ryan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!