flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
coconut 10 May 2005, 00:36
give it the BS_DEFPUSHBUTTON style?
|
|||
![]() |
|
flaith 10 May 2005, 11:02
Where ? Into the Resource section ?
_________________ Je suis sur de 'rien', mais je ne suis pas sur du 'tout'. |
|||
![]() |
|
coconut 10 May 2005, 11:29
yes give it that style, make sure the other button is a BS_PUSHBUTTON. that is a half solution though, i tried your code and dont see why it doesnt work. perhaps dialogs are updated/drawn differently
if youre using fasm's resource macros it would be something like Code: dialogitem 'BUTTON','OK',IDOK,85,150,45,15,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON dialogitem 'BUTTON','C&ancel',IDCANCEL,135,150,45,15,WS_VISIBLE+WS_TABSTOP+BS_PUSHBUTTON |
|||
![]() |
|
flaith 10 May 2005, 11:53
thanks to have responded
![]() here's the src : Code: format PE GUI 4.0 entry start include '%fasminc%\win32a.inc' ; ***************************************************************************** ; ***** Const ; ***************************************************************************** ID_DIALOG = 10 ID_GROUP_BOX = 100 ID_LABEL_DATE = 101 ID_LABEL_TIME = 102 ID_LOCAL_TIME = 103 ID_EDIT_DATE = 104 ID_EDIT_TIME = 105 ID_EDIT_LOCAL = 106 ID_BUTTON_TIME = 107 ID_BUTTON_QUIT = 108 ; ***************************************************************************** ; ***** Datas ; ***************************************************************************** section '.data' data readable writeable hinstance dd ? IsError dd ? lpSystemTime SYSTEMTIME ; API struct _format_date db '%02d/%02d/%4d',0 _buffer_date rb 11 ; 11 bytes reserved (xx/xx/xxxx0) _format_time db '%02d:%02d:%02d',0 _buffer_time rb 9 ; 9 bytes reserved (xx:xx:xx0) _buffer_loc_time rb 9 ; ***************************************************************************** ; ***** Code ; ***************************************************************************** section '.code' code readable executable start: invoke GetModuleHandle,0 mov [hinstance],eax invoke DialogBoxParam,[hinstance],ID_DIALOG,HWND_DESKTOP,DialogProc,0 invoke ExitProcess,0 ; ***** Procedures proc DialogProc,hwnddlg,msg,wparam,lparam push ebx esi edi cmp [msg],WM_INITDIALOG je wminitdialog ; called before dialog box is displayed cmp [msg],WM_COMMAND je wmcommand cmp [msg],WM_CLOSE je wmclose xor eax,eax ; eax = 0 jmp finish wminitdialog: ; invoke GetDlgItem,[hwnddlg],ID_BUTTON_QUIT ; invoke SetFocus,eax ; invoke UpdateWindow,[hwnddlg] ; or ; invoke SendMessage,\ ; ID_BUTTON_QUIT, BM_SETSTATE, TRUE, NULL ; [wparam], 0 stdcall sys_time,[hwnddlg] stdcall loc_time,[hwnddlg] stdcall sys_date,[hwnddlg] jmp processed wmcommand: cmp [wparam],ID_BUTTON_QUIT ; BN_CLICKED shl 16 + ID_BUTTON_QUIT je wmclose ; goto close if click on Cancel cmp [wparam],ID_BUTTON_TIME ; BN_CLICKED shl 16 + ID_BUTTON_TIME jne processed ; <> Ok stdcall sys_time,[hwnddlg] ; Called when clicked on button 'Time' stdcall loc_time,[hwnddlg] jmp processed wmclose: invoke EndDialog,[hwnddlg],0 processed: mov eax,1 finish: pop edi esi ebx return endp proc sys_time,_hwnddlg invoke GetSystemTime,lpSystemTime movsx eax,[lpSystemTime.wHour] ; movsx (ou movzx) permet de movsx ebx,[lpSystemTime.wMinute] ; convertir en DWORD signed (ou unsigned) movsx edi,[lpSystemTime.wSecond] ; car wsprintf ne demande que du DWORD cinvoke wsprintf,_buffer_time,_format_time,eax,ebx,edi invoke SetDlgItemText,[_hwnddlg],ID_EDIT_TIME,_buffer_time return endp proc loc_time,_hwnddlg invoke GetLocalTime,lpSystemTime movsx eax,[lpSystemTime.wHour] movsx ebx,[lpSystemTime.wMinute] movsx edi,[lpSystemTime.wSecond] cinvoke wsprintf,_buffer_loc_time,_format_time,eax,ebx,edi invoke SetDlgItemText,[_hwnddlg],ID_EDIT_LOCAL,_buffer_loc_time return endp proc sys_date,_hwnddlg movsx eax,[lpSystemTime.wDay] movsx ebx,[lpSystemTime.wMonth] movsx edi,[lpSystemTime.wYear] cinvoke wsprintf,_buffer_date,_format_date,eax,ebx,edi invoke SetDlgItemText,[_hwnddlg],ID_EDIT_DATE,_buffer_date return endp ; ***************************************************************************** ; ***** Data Import ; ***************************************************************************** section '.idata' import data readable writeable library kernel,'KERNEL32.DLL',\ user,'USER32.DLL' import kernel,\ GetModuleHandle,'GetModuleHandleA',\ GetSystemTime, 'GetSystemTime',\ GetLocalTime, 'GetLocalTime',\ ExitProcess,'ExitProcess' import user,\ DialogBoxParam,'DialogBoxParamA',\ UpdateWindow,'UpdateWindow',\ SendMessage,'SendMessageA',\ SetDlgItemText,'SetDlgItemTextA',\ ; on peut aussi mettre SetDlgItemInt GetDlgItem,'GetDlgItem',\ SetFocus,'SetFocus',\ MessageBox,'MessageBoxA',\ wsprintf,'wsprintfA',\ EndDialog,'EndDialog' ; ***************************************************************************** ; ***** Resources ; ***************************************************************************** section '.rsrc' resource data readable directory RT_DIALOG,dialogs resource dialogs,\ ID_DIALOG,LANG_NEUTRAL+SUBLANG_DEFAULT,datesysteme dialog datesysteme,"System Date & Time", 70, 70, 150, 110, DS_CENTER+DS_MODALFRAME+WS_POPUP+WS_VISIBLE+WS_CAPTION+WS_SYSMENU dialogitem 'STATIC','System date :', ID_LABEL_DATE , 10, 10, 45, 14, SS_RIGHT + SS_CENTERIMAGE + WS_CHILD + WS_VISIBLE + WS_GROUP, 0x00000000 dialogitem 'STATIC','System Time :', ID_LABEL_TIME , 10, 30, 45, 14, SS_RIGHT + SS_CENTERIMAGE + WS_CHILD + WS_VISIBLE + WS_GROUP, 0x00000000 dialogitem 'STATIC','Local Time :' , ID_LOCAL_TIME , 10, 50, 45, 14, SS_RIGHT + SS_CENTERIMAGE + WS_CHILD + WS_VISIBLE + WS_GROUP, 0x00000000 dialogitem 'BUTTON','' , ID_GROUP_BOX , 60, 0, 85, 70, BS_GROUPBOX + WS_CHILD + WS_VISIBLE, 0x00000000 dialogitem 'STATIC','__/__/____' , ID_EDIT_DATE , 70, 10, 65, 14, SS_CENTER + SS_CENTERIMAGE + WS_CHILD + WS_VISIBLE + WS_GROUP, 0x00000204 dialogitem 'STATIC','__:__:__' , ID_EDIT_TIME , 70, 30, 65, 14, SS_CENTER + SS_CENTERIMAGE + WS_CHILD + WS_VISIBLE + WS_GROUP, 0x00000204 dialogitem 'STATIC','__:__:__' , ID_EDIT_LOCAL , 70, 50, 65, 14, SS_CENTER + SS_CENTERIMAGE + WS_CHILD + WS_VISIBLE + WS_GROUP, 0x00000204 dialogitem 'BUTTON','&Time' , ID_BUTTON_TIME, 10, 80, 60, 28, WS_VISIBLE+WS_TABSTOP+BS_PUSHBUTTON;BS_PUSHBUTTON + BS_VCENTER + BS_CENTER + WS_CHILD + WS_VISIBLE + WS_TABSTOP dialogitem 'BUTTON','&Quit' , ID_BUTTON_QUIT, 80, 80, 60, 28, WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON;BS_PUSHBUTTON + BS_VCENTER + BS_CENTER + WS_CHILD + WS_VISIBLE + WS_TABSTOP enddialog I want the 'Quit' Button to be focused, but it's the 'time' button which is focused ![]() _________________ Je suis sur de 'rien', mais je ne suis pas sur du 'tout'. |
|||
![]() |
|
Frank 10 May 2005, 13:50
Swap the order of buttons in the resource section -- it works if the "Quit" button is declared before the "Time" button.
|
|||
![]() |
|
flaith 10 May 2005, 13:54
yes, that's right thx
![]() in fact i'm looking to always set focus on the Quit button, even if i clicked on another one ! _________________ Je suis sur de 'rien', mais je ne suis pas sur du 'tout'. |
|||
![]() |
|
Frank 10 May 2005, 14:50
That's just a question of putting the available bits and pieces together.
Code: ; Changes to the code section: wmcommand: cmp [wparam],ID_BUTTON_QUIT ; BN_CLICKED shl 16 + ID_BUTTON_QUIT je wmclose ; goto close if click on Cancel invoke GetDlgItem,[hwnddlg],ID_BUTTON_QUIT invoke SetFocus,eax cmp [wparam],ID_BUTTON_TIME ; BN_CLICKED shl 16 + ID_BUTTON_TIME jne processed ; <> Ok ; Changes to the resource section: dialogitem 'BUTTON','&Quit' , ID_BUTTON_QUIT, 80, 80, 60, 28, WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON dialogitem 'BUTTON','&Time' , ID_BUTTON_TIME, 10, 80, 60, 28, WS_VISIBLE+WS_TABSTOP+BS_PUSHBUTTON |
|||
![]() |
|
flaith 10 May 2005, 15:02
![]() ![]() _________________ Je suis sur de 'rien', mais je ne suis pas sur du 'tout'. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.