flat assembler
Message board for the users of flat assembler.
Index
> Windows > Dialog |
Author |
|
coconut 28 Apr 2004, 04:03
ozzy, download the fasmw gui package - theres an excellent example in there:
Code: ; DialogBox example format PE GUI 4.0 entry start include '%fasminc%\win32a.inc' ID_OK = 101 ID_CANCEL = 102 ID_CAPTION = 201 ID_MESSAGE = 202 ID_ICONERROR = 301 ID_ICONINFORMATION = 302 ID_ICONQUESTION = 303 ID_ICONWARNING = 304 ID_TOPMOST = 401 section '.data' data readable writeable flags dd ? caption rb 40h message rb 100h section '.code' code readable executable start: invoke GetModuleHandle,0 invoke DialogBoxParam,eax,37,HWND_DESKTOP,DialogProc,0 or eax,eax jz exit invoke MessageBox,HWND_DESKTOP,message,caption,[flags] exit: invoke ExitProcess,0 proc DialogProc,hwnddlg,msg,wparam,lparam push ebx esi edi cmp [msg],WM_INITDIALOG je wminitdialog cmp [msg],WM_COMMAND je wmcommand cmp [msg],WM_CLOSE je wmclose xor eax,eax jmp finish wminitdialog: invoke CheckRadioButton,[hwnddlg],ID_ICONERROR,ID_ICONWARNING,ID_ICONINFORMATION jmp processed wmcommand: cmp [wparam],BN_CLICKED shl 16 + ID_CANCEL je wmclose cmp [wparam],BN_CLICKED shl 16 + ID_OK jne processed invoke GetDlgItemText,[hwnddlg],ID_CAPTION,caption,40h invoke GetDlgItemText,[hwnddlg],ID_MESSAGE,message,100h mov [flags],MB_OK invoke IsDlgButtonChecked,[hwnddlg],ID_ICONERROR cmp eax,BST_CHECKED jne iconerror_ok or [flags],MB_ICONERROR iconerror_ok: invoke IsDlgButtonChecked,[hwnddlg],ID_ICONINFORMATION cmp eax,BST_CHECKED jne iconinformation_ok or [flags],MB_ICONINFORMATION iconinformation_ok: invoke IsDlgButtonChecked,[hwnddlg],ID_ICONQUESTION cmp eax,BST_CHECKED jne iconquestion_ok or [flags],MB_ICONQUESTION iconquestion_ok: invoke IsDlgButtonChecked,[hwnddlg],ID_ICONWARNING cmp eax,BST_CHECKED jne iconwarning_ok or [flags],MB_ICONWARNING iconwarning_ok: invoke IsDlgButtonChecked,[hwnddlg],ID_TOPMOST cmp eax,BST_CHECKED jne topmost_ok or [flags],MB_TOPMOST topmost_ok: invoke EndDialog,[hwnddlg],1 jmp processed wmclose: invoke EndDialog,[hwnddlg],0 processed: mov eax,1 finish: pop edi esi ebx return endp section '.idata' import data readable writeable library kernel,'KERNEL32.DLL',\ user,'USER32.DLL' import kernel,\ GetModuleHandle,'GetModuleHandleA',\ ExitProcess,'ExitProcess' import user,\ DialogBoxParam,'DialogBoxParamA',\ CheckRadioButton,'CheckRadioButton',\ GetDlgItemText,'GetDlgItemTextA',\ IsDlgButtonChecked,'IsDlgButtonChecked',\ MessageBox,'MessageBoxA',\ EndDialog,'EndDialog' section '.rsrc' resource data readable directory RT_DIALOG,dialogs resource dialogs,\ 37,LANG_ENGLISH+SUBLANG_DEFAULT,demonstration dialog demonstration,'Create message box',70,70,190,175,WS_CAPTION+WS_POPUP+WS_SYSMENU+DS_MODALFRAME dialogitem 'STATIC','&Caption:',-1,10,10,70,8,WS_VISIBLE dialogitem 'EDIT','',ID_CAPTION,10,20,170,13,WS_VISIBLE+WS_BORDER+WS_TABSTOP dialogitem 'STATIC','&Message:',-1,10,40,70,8,WS_VISIBLE dialogitem 'EDIT','',ID_MESSAGE,10,50,170,13,WS_VISIBLE+WS_BORDER+WS_TABSTOP+ES_AUTOHSCROLL dialogitem 'BUTTON','&Icon',-1,10,70,80,70,WS_VISIBLE+BS_GROUPBOX dialogitem 'BUTTON','&Error',ID_ICONERROR,20,82,60,13,WS_VISIBLE+BS_AUTORADIOBUTTON+WS_TABSTOP+WS_GROUP dialogitem 'BUTTON','I&nformation',ID_ICONINFORMATION,20,95,60,13,WS_VISIBLE+BS_AUTORADIOBUTTON dialogitem 'BUTTON','&Question',ID_ICONQUESTION,20,108,60,13,WS_VISIBLE+BS_AUTORADIOBUTTON dialogitem 'BUTTON','&Warning',ID_ICONWARNING,20,121,60,13,WS_VISIBLE+BS_AUTORADIOBUTTON dialogitem 'BUTTON','&Style',-1,100,70,80,70,WS_VISIBLE+BS_GROUPBOX dialogitem 'BUTTON','&Top most',ID_TOPMOST,110,82,60,13,WS_VISIBLE+WS_TABSTOP+BS_AUTOCHECKBOX dialogitem 'BUTTON','OK',ID_OK,85,150,45,15,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON dialogitem 'BUTTON','C&ancel',ID_CANCEL,135,150,45,15,WS_VISIBLE+WS_TABSTOP+BS_PUSHBUTTON enddialog |
|||
28 Apr 2004, 04:03 |
|
OzzY 28 Apr 2004, 23:18
I have Fasmw, but this example looks too much confusing to me, I can't understand the ".idata" part and the ".rsrc" part too....
|
|||
28 Apr 2004, 23:18 |
|
coconut 29 Apr 2004, 03:46
just sections that organize the code in memory. 'idata' is api imports your program will use. just like in visual basic you would do
Code: Private Declare Function FindWindow lib "user32" Alias "FindWindowA" (szclass as string, szcaption as string") as long you do the same in fasm; otherwise windows will have no idea what you mean when calling the api function. the '.rsrc' section is where you defines your resources, like menus and dialogs. fasm has macros to do this in that syntax used in the code, or optionally you can use a resource compiler and create a .res file. again an example of using an external res file is here: http://board.flatassembler.net/topic.php?t=1399&highlight=resource+file |
|||
29 Apr 2004, 03:46 |
|
OzzY 29 Apr 2004, 19:28
But where can I download a resource compiler, and could you post a complete and simple example of how to display a dialog with a button on it and how to handle the clicks on the button?
Thanks |
|||
29 Apr 2004, 19:28 |
|
coconut 01 May 2004, 04:54
most good resource compilers cost money, like http://www.sicomponents.com/rbldr.html there are some freeware ones out there, youd have to search around.
that dialog example may seem a bit confusing, but it does exactly what youre describing. it creates a dialog with some radio/option buttons, static labels, text boxes, and command buttons (yes i come from a vb background ) the example creates a msgbox depending on the options you select, and the text/caption you write. the code begins by calling DialogBoxParam, which loads the dialog created in the '.rsrc' section. messages sent by windows (mouse clicks, keystrokes, etc) are sent to the DialogProc procedure. the procedure checks to see which message is sent, and performs an action accordingly. when a button is clicked, windows sends a WM_COMMAND message to the DialogProc procedure, which then checks to see which of the 2 buttons was pressed. if cancel was pressed, the program exits. if ok was pressed the program then determines which radio button was pressed, grabs the text from the 2 edit fields, and creates the message box. |
|||
01 May 2004, 04:54 |
|
coconut 02 May 2004, 21:50
ozzy check out http://board.flatassembler.net/topic.php?t=1521 this example, it uses a dialog and handles some messages
|
|||
02 May 2004, 21:50 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.