开发者

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

I have an MFC application. Whe开发者_StackOverflow社区n 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.


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.


I'm not exactly sure if it helps in your case but the ResizableLib works pretty well for me. You can also skip creating a library and just use the files in your project.
There is a separate article for CResizableDialog which explains in a few easy steps how to implement this for existing dialogs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜