Home > Software design >  How to get scale ratio between design window size (in VS forms designer) and real size?
How to get scale ratio between design window size (in VS forms designer) and real size?

Time:11-29

I have a standard WinApi Dialog window, created in form designer of Visual Studio. Design size is eg. 500x600 in pixels. But if I run application and get size of window (GetWindowSize()), the size is different, almost bigger, dependent of the monitor resolution.

According to this ratio I must adjust also font size, and child window possition and size... Where I get this ratio?

Thank for help. Majkl

CodePudding user response:

According to the documentation VS resiurce editor dialog

Than I run an application and in eg. OnInitDialog I use GetWindowRect(), and real size of the widow is (value of returned RECT structure):

  • on my laptop display - 578x447
  • more bigger value on big monitor, if I have laptop in dockstation

And on this resizing ratio depends possition of other icons and texts, etc. in client area of window.

I of course can get current GetWindowRect of the current window and get ratio from design ratio: Xratio = (rect.right - rect.left)/320..... but it will not be usable for other window....

I need get this ratio for current ressolution (for current display). Thanks.

  • Related