flat assembler
Message board for the users of flat assembler.

Index > Windows > [solved] Several dialogues from the resource

Author
Thread Post new topic Reply to topic
FoXx



Joined: 25 Feb 2025
Posts: 8
FoXx 26 Feb 2025, 14:09
Is it possible to create multiple dialogs template resources?
Code:
section '.rsrc' resource data readable
directory RT_DIALOG, Dialog1, RT_DIALOG, Dialog2

resource Dialog1,37,LANG_ENGLISH+SUBLANG_DEFAULT,DialogBox1
resource Dialog2,38,LANG_ENGLISH+SUBLANG_DEFAULT,DialogBox2

dialog DialogBox1,'Dialog 1',70,70,120,40,WS_CAPTION+WS_POPUP+WS_SYSMENU+DS_MODALFRAME
        dialogitem 'BUTTON','Ok',IDOK,8,20,50,20,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON
        dialogitem 'BUTTON','Cancel',IDCANCEL,60,20,50,20,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON
enddialog


dialog DialogBox2,'Dialog 2',70,70,120,40,WS_CAPTION+WS_POPUP+WS_SYSMENU+DS_MODALFRAME
        dialogitem 'BUTTON','Ok',IDOK,8,20,50,20,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON
        dialogitem 'BUTTON','Cancel',IDCANCEL,60,20,50,20,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON
enddialog    
Post 26 Feb 2025, 14:09
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1694
Location: Toronto, Canada
AsmGuru62 26 Feb 2025, 16:21
RT_DIALOG should be mentioned once, not few times. Same for the resource.
Code:
section '.rsrc' resource data readable

 directory RT_GROUP_ICON, GrIcons,  RT_ICON, Icons,  RT_VERSION, \
           Vers, RT_DIALOG, Dialogs, RT_MENU, Menus

 resource  Dialogs, IDR_DIAL1,  LANG_NEUTRAL, find_dlg,\
                    IDR_DIAL2,  LANG_NEUTRAL, replace_dlg
                    
 dialog find_dlg, 'Find Text',60,80,200,86,WS_CAPTION +WS_SYSMENU +DS_MODALFRAME, , ,'Verdana',10
    dialogitem 'button', 'Ok', IDOK, 90, 66, 50, 15, WS_VISIBLE + WS_TABSTOP + BS_DEFPUSHBUTTON
    dialogitem 'button', 'Cancel', IDCANCEL, 145, 66, 50, 15, WS_VISIBLE + WS_TABSTOP
 enddialog
 
 dialog replace_dlg, 'Please verify', 0, 0, 170, 40, WS_CAPTION + WS_SYSMENU + DS_MODALFRAME,,,'Verdana',10
    dialogitem 'static','Do you wish to replace this text?', -1, 5, 5, 120, 10, WS_VISIBLE
    dialogitem 'button','&Replace', IDYES, 5, 20, 50, 15, WS_VISIBLE + WS_TABSTOP + BS_DEFPUSHBUTTON
    dialogitem 'button','&Skip', IDNO, 60, 20, 50, 15, WS_VISIBLE + WS_TABSTOP
    dialogitem 'button','Cancel', IDCANCEL, 115, 20, 50, 15, WS_VISIBLE + WS_TABSTOP
 enddialog
    
Post 26 Feb 2025, 16:21
View user's profile Send private message Send e-mail Reply with quote
FoXx



Joined: 25 Feb 2025
Posts: 8
FoXx 26 Feb 2025, 17:46
AsmGuru62, thanks for the help.
Sorry, but I need to ask again.

1) Is it possible to declare several menu templates?

2) Why does RT_VERSION need the identifier "1"?
Post 26 Feb 2025, 17:46
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1694
Location: Toronto, Canada
AsmGuru62 26 Feb 2025, 19:10
1) I think you can follow the same pattern as with dialogs:
Code:
resource  Menus, IDR_MENU1,  LANG_NEUTRAL, menu1,\
                    IDR_MENU2,  LANG_NEUTRAL, menu2

menu menu1
... items for menu1

menu menu2
... items for menu2
    


2) I am unclear what the question is?
I never use RT_VERSION myself, the code sample was from someone else.
It is possible that Windows wants the "1", just like WM_PAINT is 15 and it cannot be anything other than 15.
RT_VERSION value itself is 16, where is the "1" come from? Did you get an error from FASM?
Post 26 Feb 2025, 19:10
View user's profile Send private message Send e-mail Reply with quote
FoXx



Joined: 25 Feb 2025
Posts: 8
FoXx 26 Feb 2025, 19:46
Dialogue is evoked. The icon is specified when the window is created. Version information is not loaded anywhere into the program. I've tried other ID values. If it is not equal to “1”, then there is no information about the program version in the file properties.
Post 26 Feb 2025, 19:46
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1694
Location: Toronto, Canada
AsmGuru62 26 Feb 2025, 22:37
I see. I never use the Version information, so I am unlikely to answer what is going on.
Microsoft, however, states that ID must be 1:
https://learn.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource
Post 26 Feb 2025, 22:37
View user's profile Send private message Send e-mail Reply with quote
FoXx



Joined: 25 Feb 2025
Posts: 8
FoXx 27 Feb 2025, 07:54
Thanks for your help.
I spent a lot of time and couldn't figure it out. Now I know and I managed to figure it out.
I made a note to myself.
Code:
section '.idata' import data readable writeable

library kernel,'KERNEL32.DLL',\
                advapi,'ADVAPI32.DLL',\
                user,'USER32.DLL',\
                gdi,'GDI32.DLL',\
                comctl,'COMCTL32.DLL',\
                comdlg,'COMDLG32.DLL',\
                shell,'SHELL32.DLL'

import kernel,  GetModuleHandle,'GetModuleHandleA',\
                LoadLibrary,'LoadLibraryA',\
                GetProcAddress,'GetProcAddress',\
                GetCommandLine,'GetCommandLineA',\
;...
                ExitProcess,'ExitProcess'

section '.rsrc' data readable resource from 'myRes.res' 
;...

section '.rsrc' resource data readable

directory       RT_MENU,menus,\
                RT_ACCELERATOR,accelerators,\
                RT_DIALOG,dialogs,\
                RT_GROUP_ICON,group_icons,\
                RT_ICON,icons,\
                RT_STRING,my_strings,\
                RT_MANIFEST,manifests
                RT_BITMAP,bitmaps,\
                RT_VERSION,versions

resource menus,\
                IDM_MAIN,LANG_ENGLISH+SUBLANG_DEFAULT,main_menu,\
                IDM_TAB,LANG_ENGLISH+SUBLANG_DEFAULT,popup_menu

resource accelerators,\
                IDA_MAIN,LANG_ENGLISH+SUBLANG_DEFAULT,main_keys

resource dialogs,\
                IDD_DLG1,LANG_ENGLISH+SUBLANG_DEFAULT,find_dlg,\
                IDD_DLG2,LANG_ENGLISH+SUBLANG_DEFAULT,replace_dlg
                
icon group_icons,icons,'icon.ico'

resource manifests,\
                IDM_THM1,LANG_ENGLISH+SUBLANG_DEFAULT,manifest

bitmap logo,'logo.bmp' 

resource my_strings,\
                IDS_STR1,LANG_NEUTRAL,str_table0,\
                IDS_STR2,LANG_NEUTRAL,str_table1

menu main_menu
        menuitem '&File',0,MFR_POPUP
                menuitem 'Open  &O',IDM_OPEN
                menuseparator
                menuitem '&Save F2',IDM_SAVE,0,MF_DISABLED
                menuitem '&Save As',IDM_SAVE_AS
                menuseparator
                menuitem 'E&xit Esc',IDM_EXIT,MFR_END

        menuitem '&Edit',IDM_THREAD,MFR_POPUP+MFR_END
                menuitem '&Option',IDM_OPTION,MFR_END

        menuitem '&File',0,MFR_POPUP
                menuitem 'Open  &O',IDM_OPEN
                menuseparator
                menuitem '&Save F2',IDM_SAVE,0,MF_DISABLED
                menuitem '&Save As',IDM_SAVE_AS
                menuseparator
                menuitem 'E&xit Esc',IDM_EXIT,MFR_END

menu popup_menu
        menuitem '&Help',IDM_THREAD,MFR_POPUP+MFR_END
                menuitem '&About        F1',IDM_EXIT,MFR_END

dialog find_dlg,'Find Text',60,80,200,86,WS_CAPTION+WS_SYSMENU+DS_MODALFRAME, , ,'Verdana',10
        dialogitem 'button','Ok',IDOK,90,66,50,15,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON
        dialogitem 'button','Cancel',IDCANCEL,145,66,50,15,WS_VISIBLE+WS_TABSTOP
enddialog
 
dialog replace_dlg, 'Please verify',0,0,170,40,WS_CAPTION+WS_SYSMENU+DS_MODALFRAME,,,'Verdana',10
        dialogitem 'static','Do you wish to replace this text?',-1,5,5,120,10,WS_VISIBLE
        dialogitem 'button','&Replace',IDYES,5,20,50,15,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON
        dialogitem 'button','&Skip',IDNO,60,20,50,15,WS_VISIBLE+WS_TABSTOP
        dialogitem 'button','Cancel',IDCANCEL,115,20,50,15,WS_VISIBLE+WS_TABSTOP
enddialog

stringtable str_table0,\                ;       ids 00 - 0F
        IDS_ZERO,"Zero isn't accepted by many APIs!",\
        IDS_1,"1",\
        IDS_2,"2",\
        IDS_3,"3",\
        IDS_4,"4",\
        IDS_5,"5",\
        IDS_6,"6",\
        IDS_7,"7",\
        IDS_8,"8",\
        IDS_9,"9",\
        IDS_a,"A",\
        IDS_b,"B",\
        IDS_c,"C",\
        IDS_d,"D",\
        IDS_e,"E",\
        IDS_f,"F"

stringtable str_table1,\                ;       ids 10 - 1F
        IDS_10,"10",\
        IDS_11,"11",\
        IDS_12,"12",\
        IDS_13,"13",\
        IDS_14,"14",\
        IDS_15,"15"

resdata manifest
        file 'manifest.minimal.xml'
endres

versioninfo versions,VOS__WINDOWS32,VFT_APP,VFT2_UNKNOWN,LANG_ENGLISH+SUBLANG_DEFAULT,0,\
        'Comments,'no comment',\
        'CompanyName,'',\
        'FileDescription,'My Super Proc',\
        'FileVersion,'1.0',\
        'InternalName,'PROC',\
        'LegalCopyright,'X Co. ltd',\
        'LegalTrademarks,'SuperStarX',\
        'OriginalFilename,'PROC.EXE',\
        'PrivateBuild,'101',\
        'ProductName,'SuperProc',\
        'ProductVersion,'1.0.0.1',\
        'SpecialBuild,'1A10'    
Post 27 Feb 2025, 07:54
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.