Author Topic: A question on dialogs.inc  (Read 2292 times)

clamicun

• Member
• Posts: 254
A question on dialogs.inc
« on: February 22, 2015, 09:02:19 PM »
This is the syntax of Dialog.

Dialog MACRO quoted_text_title,quoted_font,fsize,dstyle,ctlcnt,tx,ty,wd,ht,bsize

e.g.

DlgEdit   ...
DlgButton ...
DlgGroup  ...

CallModalDialog xxx,xxx,dlg_xxx,0
;-------------

Now - how to do this ?

.const
MS_Font1     TCHAR 'Verdana',0
MS_Font2     TCHAR 'MS Sans Serif',0
dlg_title_de TCHAR 'Titel',0
dlg_title_en TCHAR 'Title',0
dlg_title_pt TCHAR 'Titulo',0

.data
dlg_fontsize dw 10
dlg_xpos     dw 50
dlg_ypos     dw 50
dlg_width    dw 145
dlg_height   dw 65

Dialog MACRO offset dlg_title_pt,offset MS_Font1,dlg_fontsize,WS_VISIBLE+WS_SYSMENU,3, \
dlg_xpos,dlg_ypos,dlg_width,dlg_height,1024

"
"
"
Call ...
;-------------

Is this somehow possible ?
I don't imagine that multilanguage software uses 25 different dialogboxes.

dedndave

• Member
• Posts: 8751
• Still using Abacus 2.0
Re: A question on dialogs.inc
« Reply #1 on: February 23, 2015, 07:17:07 PM »
i don't know if the macro can do that

the easy way - don't use the macro
there are many examples in the masm32\examples folders

clamicun

• Member
• Posts: 254
Re: A question on dialogs.inc
« Reply #2 on: February 24, 2015, 02:17:37 AM »
Thank you dedndave,
but I think you did not get me - or I did not express myself correctly.

I am asking if it is somehow possible to use variables in a dialogbox.

I know how to use resource files.
It is not the easy way in this case  because it seems to be simply impossible to insert variables - resource or macro - into a dialogbox. I tried for hours.

I asked the same question in the FASM forum without an answer.
But there must be a method, because otherwise any multilanguage programmer had to write 25 dialogboxes on 25 languages because of totally different fonts, different wordsize and more.

Have a good monday.

dedndave

• Member
• Posts: 8751
• Still using Abacus 2.0
Re: A question on dialogs.inc
« Reply #3 on: February 24, 2015, 03:17:37 AM »
what you may want to do is to examine the contents of the \masm32\include\dialogs.inc file
it's a plain text file

Code: [Select]
`    ; ------------------------------------------------    ; write unicode string at current location in EDI    ; ------------------------------------------------      ustring MACRO quoted_text        LOCAL asc_txt      .data        asc_txt db quoted_text,0      .code        invoke MultiByteToWideChar,CP_ACP,MB_PRECOMPOSED,               ADDR asc_txt,-1,edi,LENGTHOF asc_txt        add edi, LENGTHOF asc_txt*2      ENDM    ; --------------    ; dialog window    ; --------------      Dialog MACRO quoted_text_title,quoted_font,fsize,dstyle,ctlcnt,tx,ty,wd,ht,bsize        push esi        push edi        invoke GlobalAlloc,GMEM_FIXED or GMEM_ZEROINIT,bsize        mov esi, eax        mov edi, esi        mov DWORD PTR [edi+0],  DS_SETFONT or dstyle        mov WORD  PTR [edi+8],  ctlcnt        mov WORD  PTR [edi+10], tx        mov WORD  PTR [edi+12], ty        mov WORD  PTR [edi+14], wd        mov WORD  PTR [edi+16], ht        add edi, 22        ustring quoted_text_title        mov WORD PTR [edi], fsize        add edi, 2        ustring quoted_font      ENDM    ; ------------------------------------    ; create a modal dialog from the data    ; written to the memory template.    ; ------------------------------------      CallModalDialog MACRO Instance,Parent,DlgProc,lpExtra        invoke DialogBoxIndirectParam,Instance,esi,Parent,                                      ADDR DlgProc,lpExtra        push eax                ;; preserve return value        invoke GlobalFree,esi   ;; free memory        pop eax                 ;; restore return value        pop edi        pop esi      ENDM`
you can see that variables may be used, if you write your own code, rather than using the macros
creating a dialog with DialogBoxIndirectParam is a painful process

but, i think it's a good exercise that everyone should try once

dedndave

• Member
• Posts: 8751
• Still using Abacus 2.0
Re: A question on dialogs.inc
« Reply #4 on: February 24, 2015, 03:27:49 AM »
here is a thread in the old forum, where i was playing with it
i created the structures on the stack using PUSH (i.e. everything is reverse order)

http://www.masmforum.com/board/index.php?topic=17254.msg144816#msg144816

that thread is 5 pages long

https://msdn.microsoft.com/en-us/library/windows/desktop/ms645461%28v=vs.85%29.aspx

clamicun

• Member
• Posts: 254
Re: A question on dialogs.inc
« Reply #5 on: February 24, 2015, 04:41:17 AM »
Very nice dedndave,
I'll check this out. As I said -  there must be asolution, because there is always a solution.

dedndave

• Member
• Posts: 8751
• Still using Abacus 2.0
Re: A question on dialogs.inc
« Reply #6 on: February 24, 2015, 05:48:04 AM »
it's been a while, but as i recall, selecting fonts is a little tricky

and, fitting variable text into a window can be very difficult
if you have fixed text, it's not a problem

jj2007

• Member
• Posts: 8005
• Assembler is fun ;-)
Re: A question on dialogs.inc
« Reply #7 on: February 24, 2015, 07:16:38 AM »
It is certainly possible, see attachment, but it's not trivial. You need to intercept messages, which is possible with MasmBasic dialogs, but I doubt there is a simple solution for standard Masm32 dialogs. Hutch may correct me on this.

hutch--

• Member
• Posts: 5102
• Mnemonic Driven API Grinder
Re: A question on dialogs.inc
« Reply #8 on: February 24, 2015, 09:16:42 AM »
Its usually the case if you want multi-lingual support in an OS specified dialog that you set the text dynamically at runtime. The system of building dialog templates in memory only differs from an RC script dialog in the way its loaded into memory. Both are basically a static template that is filled out first then loaded into memory.

If you need to alter the text for the title bar, text boxes or any other control that handles text, then you need to set it dynamically. This involves using the API GetDlgItem() to get the window handle of the control then you use SetWindowText() or WM_SETTEXT to change the text to what you require. This gets a bit more complicated with UNICODE in that you must store it somewhere and use the UNICODE API function to access the text.
hutch at movsd dot com
http://www.masm32.com

clamicun

• Member
• Posts: 254
Re: A question on dialogs.inc
« Reply #9 on: February 26, 2015, 01:32:41 AM »
JJ,
somehow I don't see DlgMultiLanguage.asm, or you don't want us to see it?

http://masm32.com/board/index.php?action=dlattach;topic=4051.0;attach=3826

jj2007

• Member
• Posts: 8005
• Assembler is fun ;-)
Re: A question on dialogs.inc
« Reply #10 on: February 26, 2015, 02:18:26 AM »
JJ,
somehow I don't see DlgMultiLanguage.asm, or you don't want us to see it?

http://masm32.com/board/index.php?action=dlattach;topic=4051.0;attach=3826

Just open the *.asc file in WordPad or MS Word. They recognise RTF. Even better is \Masm32\MasmBasic\RichMasm.exe because it will create the rc file in the moment when you hit the F6 key, i.e. asm source and rc file are integrated and can be edited in one source file.