The MASM Forum

General => The Campus => Topic started by: Mikl__ on July 25, 2018, 03:02:44 PM

Title: Mismatch of height and width of dialogs
Post by: Mikl__ on July 25, 2018, 03:02:44 PM
I went experimentally, created a dialog and a window 276x147, the size of the window is 1 in 1, the size of the dialog is 430x279 (approximately), the correction factor for width is x1.56, the correction factor for height is x1.89. Somewhere in msdn should be, but did not find.
Title: Re: Mismatch of height and width of dialogs
Post by: zedd151 on July 25, 2018, 03:12:02 PM
Wht OS are you running, and 32 or 64 bit? Dialog boxes are a strange beast. They are not quite windows, where you can set the dimensions exactly to the pixel. But as for a 1:1 ratio, that doesn't necessarily mean the dialog box will be square. (1:1 ratio)

I think on every OS the 'correction factor' as you call it, may be different.  Dialog boxes are measured in Dialog Units IIRC. No direct correlation to size in pixels. I did my own tests years ago, and found the best solution is to make your own dialog box lib, using a regular CreateWindow call in the lib. - this way you can set the size exactly to your required dimensions.

Dialog boxes are supposed to be quicker and easier to use, using an IDE that supports drag n drop placement of controls on the dialog box for instance (or Ketil o's ResEd) but if you need exact dimensions, a window is the way to go.
Title: Re: Mismatch of height and width of dialogs
Post by: jj2007 on July 25, 2018, 05:14:57 PM
See Raymond Chen on GetDialogBaseUnits (https://blogs.msdn.microsoft.com/oldnewthing/20040217-00/?p=40573) (where the author actually recommends MapDialogRect ;)). In fact, both are really messy.
Title: Re: Mismatch of height and width of dialogs
Post by: Mikl__ on July 25, 2018, 09:41:39 PM
Hi, zedd151!
I have windows seven x64
Ciao, jj2007!
Thanks for the link to Raymond Chen's work...  :t
Title: Re: Mismatch of height and width of dialogs
Post by: hutch-- on July 25, 2018, 10:13:00 PM
The recommendation long ago was to not create dialogs that had components too close to the border of the dialog window and it was evident from Win9x to Win2k and later. They appear to be of reasonably consistent size from Win2k upwards but the usual caution is advised, don't try and put components too close to the edges of another Windows version may cause some clipping of the components.
Title: Re: Mismatch of height and width of dialogs
Post by: dedndave on July 26, 2018, 01:17:19 AM
one of the reasons i don't use dialog boxes much - lol
when i do use them, i generally size the window and controls at creation - using pixels as units  :biggrin:
Title: Re: Mismatch of height and width of dialogs
Post by: jj2007 on July 26, 2018, 02:36:01 AM
Quote from: dedndave on July 26, 2018, 01:17:19 AMi generally size the window and controls at creation - using pixels as units  :biggrin:

Yes, WM_INITDIALOG and GetDlgItem are really useful ;-)
Title: Re: Mismatch of height and width of dialogs
Post by: Mikl__ on July 26, 2018, 09:33:01 AM
Hi, hutch--, dedndave, jj2007!
Thank very mutch to all (https://wasm.in/styles/smiles_s/yes3.gif)