News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

DIALOGEX to SDI and size windows in % of the screen

Started by TouEnMasm, May 26, 2013, 04:44:41 AM

Previous topic - Next topic

TouEnMasm

Create a dialog box with resed,only one by rc file.
Open the rc file with dialog_sdi,give it a short friendly name.
Choose if you want it in pixel or in percentage of the screen and in % of the mother window.
In percentage units, the screen is 100*100 and a mother window is 100*100.
The code pcCreateWindowEx can be get in the help menu.
Only CONTROL (resed use only those ones) are read.

The resource is compiled and used to made an exe.This one do only one thing,read the sizes of the windows and write them in rapport.txt.
This grant a perfect result in any cases.Just run readsize_dialogex.exe when you see it in the shell window.closed the shell window,you have the code in the editor.
Take care not to modify the ID (1000 to x) given by resed.
The readsize_dialogex.exe made just a loop threw this number to find the windows handles.

REad the comment in the created code,he will give you the one line you need to use it.

********* With screen in % ,the size of the windows don't change with the resolution of the screen, 800*600 same look as in 1280*1024*********


Quote
   HIWORD MACRO ParamFen,register:REQ
      mov register,ParamFen
      shr register,16
   ENDM
   LOWORD MACRO ParamFen,register:REQ
      mov register,ParamFen
      and register,0FFFFh
   ENDM

   PuPo MACRO M1, M2
   push M2
   pop  M1
   ENDM
Fa is a musical note to play with CL

MichaelW

Quote
For correct sizes use the defaut font,FONT 8,"MS Sans Serif",0,0,0.

On both of my Windows XP systems, I must specify a point size of 10 for the size calculated from GetDialogBaseUnits to match the size calculated from MapDialogRect and the size calculated from GetClientRect.

So far I have not found any way to use the API to positively identify the system font name, although I have found away to get the size. Without the font name, the only reliable method I can see to get the system font is to not specify the font in the dialog template.
Well Microsoft, here's another nice mess you've gotten us into.

dedndave

it should come up in SystemParametersInfo, SPI_GETNONCLIENTMETRICS

TouEnMasm


Quote
On both of my Windows XP systems, I must specify a point size of 10 for the size calculated from GetDialogBaseUnits to match the size calculated from MapDialogRect and the size calculated from GetClientRect.
Why use GetDialogBaseUnits ?
I just get the size of the control in:
CONTROL "Haut", IDC_DIR, "button", BS_.., 106, 38, 32, 12
I fill the rect with those values,I call:
invoke SendMessage,Hbox,WM_COMMAND   ;invoke MapDialogRect,Hbox,addr rect
and the rect is fill with the correct values in pixel units
Only condition is same font for the two resource dialog
here the resource called for measurement:
Quote
IDD_INVISIBLE DIALOGEX 10,10,100,100
CAPTION "User font"
FONT 8,"MS Sans Serif",0,0,0
STYLE WS_POPUP
BEGIN
END




Fa is a musical note to play with CL

TouEnMasm

The GetDialogBaseUnits works only if the dialog box use a system font.

windows help extract:
Quote
The GetDialogBaseUnits function retrieves the system's dialog base units, which are the average width and height of characters in the system font. For dialog boxes that use the system font, you can use these values to convert between dialog template units, as specified in dialog box templates, and pixels. For dialog boxes that do not use the system font, the conversion from dialog template units to pixels depends on the font used by the dialog box.

For either type of dialog box, it is easier to use the MapDialogRect function to perform the conversion
Fa is a musical note to play with CL

MichaelW

Quoteit should come up in SystemParametersInfo, SPI_GETNONCLIENTMETRICS

AFAIK the dialog window size is a function of the font and font size for the client area of the dialog and the controls in the dialog. I did find the name in the GetStockObject documentation for the fnObject parameter SYSTEM_FONT:
Quote
By default, the system uses the system font to draw menus, dialog box controls, and text.
Windows 95/98 and Windows NT: The system font is MS Sans Serif.
Windows 2000/XP: The system font is Tahoma

And this code:

            invoke SystemParametersInfo, SPI_GETNONCLIENTMETRICS,
                                         SIZEOF NONCLIENTMETRICS, ADDR ncm, 0
            printf("%d\n",eax)

            printf("%s\n",ADDR ncm.lfCaptionFont.LOGFONT.lfFaceName)

            ;--------------------------------------------
            ; This to correct for a windows.inc problem:
            ;--------------------------------------------
            ; printf("%s\n",ADDR ncm.lfSmCaptionFont.LOGFONT.lfFaceName)
            printf("%s\n",ADDR ncm.lfSMCaptionFont.LOGFONT.lfFaceName)

            printf("%s\n",ADDR ncm.lfMenuFont.LOGFONT.lfFaceName)
            printf("%s\n",ADDR ncm.lfStatusFont.LOGFONT.lfFaceName)
            printf("%s\n\n",ADDR ncm.lfMessageFont.LOGFONT.lfFaceName)

Does show Tahoma for most of the relevant members:

1
Trebuchet MS
Tahoma
Tahoma
Tahoma
Tahoma


But so far I have not been able to verify that the font for the client area of the dialog and the controls in the dialog is Tahoma. For example, GetTextFace when passed a DC for the client area of the dialog or a control in the dialog returns "System" and GetTextMetrics when passed the same DC returns values that don't vary with the dialog font I specify in the resource definition. And by comparing the return values of GetStockObject, SYSTEM_FONT and a subsequent SelectObject I can verify that the system font was selected into the control DC, while the control is obviously displaying the font that I specified in the resource definition.

QuoteThe GetDialogBaseUnits works only if the dialog box use a system font.

Yes, I'm aware of that, but it's not a system font it's the system font.

QuoteFor correct sizes use the defaut font,FONT 8,"MS Sans Serif",0,0,0.

I reported my test results to show that the above statement is not necessarily correct.

Well Microsoft, here's another nice mess you've gotten us into.

TouEnMasm

Quote
I reported my test results to show that the above statement is not necessarily correct.
It is perfectly correct (with the same two fonts ) if you use only MapDialogRect,don't mix with GetDialogBaseUnits.
Fa is a musical note to play with CL

TouEnMasm

Fa is a musical note to play with CL

TouEnMasm

Changed the method to have a perfect result in any cases.
The dialog can have any fonts,there is no problem.

The resource is compiled and used to made an exe.This one do only one thing,read the sizes of the windows and write them in rapport.txt.
This grant a perfect result in any cases.Just run readsize_dialogex.exe when you see it in the shell window.closed the shell window,you have the code in the editor.
Take care not to modify the ID (1000 to x) given by resed.
The readsize_dialogex.exe made just a loop threw this number to find the windows handles.

see first post for download
Fa is a musical note to play with CL

TouEnMasm

 :icon_mrgreen:
corrected a mistake who made it load allways the same rc file.
Fa is a musical note to play with CL

TouEnMasm

#10
Here a sample of use
This one show two same windows with the same size in a screen resolution of 800*600.close the windows,Change the resolution of the screen,run new, and see the result.

The tool who create pourcent.inc is in the first post
Fa is a musical note to play with CL

TouEnMasm


Try to made it more simple to use (there is a "How to proceed")
and modify a little the code.
Download is in first post

Fa is a musical note to play with CL