News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Dialog units vs. screen units

Started by NoCforMe, April 19, 2025, 09:08:02 AM

Previous topic - Next topic

zedd151

#15
Quote from: zedd151 on April 19, 2025, 10:24:38 AMAs a test, along with calling MapDialogRect, I'll try GetClientRect with the handle of the dialog box. If my assumptions are correct, the results should be identical... I'll test that when I'm back at my computer...  :biggrin:
Sorry for the delay.

The top entries are after calling MapDialogRect to do the conversion.
left
top
right
bottom


:biggrin:  :biggrin:  :biggrin:

Well it does actually do a conversion, but calling GetClientRect gives the same exact results.
Make of it what you will.  :cool:

Actually I was expecting MapDialogRect to return the screen coordinates of the entire dialog box, its position on the screen and by extension, its size in the left,top,right,bottom members of the structure.  :biggrin:

NoCforMe

Quote from: zedd151 on April 19, 2025, 03:23:09 PMWell it does actually do a conversion, but calling GetClientRect gives the same exact results.
Make of it what you will.  :cool:
Well, Larry, that's the whole point.
The conversion takes dialog units and gives you screen units.
GetClientRect( just confirms this by giving you those same screen units, which shows that the whole thing worked correctly.
Assembly language programming should be fun. That's why I do it.

zedd151

Quote from: NoCforMe on April 20, 2025, 03:56:12 AMWell, Larry, that's the whole point.
The conversion takes dialog units and gives you screen units.
GetClientRect( just confirms this by giving you those same screen units, which shows that the whole thing worked correctly.

Quote from: zedd151 on April 19, 2025, 03:23:09 PMActually I was expecting MapDialogRect to return the screen coordinates of the entire dialog box, its position on the screen and by extension, its size in the left,top,right,bottom members of the structure.  :biggrin:
I was not expecting the client RECT.  :biggrin:  but the Window RECT

NoCforMe

Well, keep in mind that GetClientRect() returns the approximately the same dimensions (width & height) as GetWindowRect(), but with the .top and .left elements set to zero. (Obviously GetWindowRect() includes the window's non-client areas as well, like the border, menu bar, etc.)

GetWindowRect() gives you the location of the window in relation to the "real world" (i.e., the desktop), while GetClientRect() just gives you the size of the client area with no location information.
Assembly language programming should be fun. That's why I do it.

zedd151

Quote from: NoCforMe on April 20, 2025, 05:54:07 AMGetWindowRect() gives you the location of the window in relation to the "real world" (i.e., the desktop)...

For some reason that is what I originally thought that MapDialogRect was supposed to do. I don't remember reading anywhere that it fills in the RECT structure with the client area... if it is the MS docs, I had missed it.

NoCforMe

Quote from: zedd151 on April 20, 2025, 05:58:48 AM
Quote from: NoCforMe on April 20, 2025, 05:54:07 AMGetWindowRect() gives you the location of the window in relation to the "real world" (i.e., the desktop)...

For some reason that is what I originally thought that MapDialogRect was supposed to do. I don't remember reading anywhere that it fills in the RECT structure with the client area... if it is the MS docs, I had missed it.
It doesn't do that.
All it does is convert the dialog's coordinates in dialog units to screen units. These can give you the size[1] of the dialog by subtracting .top from .bottom and .left from .right.

QuoteConverts the specified dialog box units to screen units (pixels). The function replaces the coordinates in the specified RECT structure with the converted coordinates, which allows the structure to be used to create a dialog box or position a control within a dialog box.

[1] Which I assume is the window size, not the client size.
Assembly language programming should be fun. That's why I do it.

zedd151

Quote from: NoCforMe on April 20, 2025, 06:08:07 AM[1] Which I assume is the window size, not the client size.
Exactly - Sounds ambiguous.

NoCforMe

Quote from: zedd151 on April 20, 2025, 06:11:19 AM
Quote from: NoCforMe on April 20, 2025, 06:08:07 AM[1] Which I assume is the window size, not the client size.
Exactly - Sounds ambiguous.
Easy enough to find out which it is--just use WinSpy.
Assembly language programming should be fun. That's why I do it.

zedd151

Quote from: NoCforMe on April 20, 2025, 06:15:31 AM
Quote from: zedd151 on April 20, 2025, 06:11:19 AM
Quote from: NoCforMe on April 20, 2025, 06:08:07 AM[1] Which I assume is the window size, not the client size.
Exactly - Sounds ambiguous.
Easy enough to find out which it is--just use WinSpy.

No need. I have run my tests.

Why RECT structures anyway? (Rhetorical question) Some functions need x,y,width,height. Which to me is more immediately useful information. Why not a structure for x, y, width, height instead? (Another Rhetorical question btw, no reply needed)

Using a RECT, you'd have to fiddle  :eusa_boohoo:  around to get the width and height. I guess it's pronounced "wrecked" for a reason.  :joking:

NoCforMe

I think the RECT structure fit the purposes of most of those early Windows functions the best.
(In other words, Micro$oft's programmers weren't stupid.)
Assembly language programming should be fun. That's why I do it.