flat assembler
Message board for the users of flat assembler.
Index
> Windows > SetDlgItemText Goto page 1, 2 Next |
Author |
|
Enko 03 Jun 2011, 19:56
You want to highlight the text in blue? or the text is highighted?
I think you could try SetWindowText |
|||
03 Jun 2011, 19:56 |
|
ouadji 03 Jun 2011, 20:23
the text is highighted (and I don't want that) SetWindowText ? I already tried, It doesn't work. The text is still highlighted ! Last edited by ouadji on 03 Jun 2011, 21:16; edited 2 times in total |
|||
03 Jun 2011, 20:23 |
|
Enko 03 Jun 2011, 20:26
does this help?
http://msdn.microsoft.com/en-us/library/bb775460(v=vs.85).aspx#changing_fonts WM_SETFONT SendMessage (hBtnButton1, WM_SETFONT, WPARAM (hFont), TRUE); if you create a font or SendMessage (hBtnButton1, WM_SETFONT, NULL, TRUE); for the default font |
|||
03 Jun 2011, 20:26 |
|
ouadji 03 Jun 2011, 20:38
Code: invoke SetDlgItemText,[hwnd_dlg],ID_CMDLINE,my_buffer ;+ invoke GetDlgItem,[hwnd_dlg],ID_CMDLINE invoke SendMessage,eax,WM_SETFONT,0,1 no result, the text is still highlighted (it drives me mad ) |
|||
03 Jun 2011, 20:38 |
|
Enko 03 Jun 2011, 20:54
There must be a problem somwhere else.....
Here is the example dialog from fasm: Code: ; DialogBox example format PE GUI 4.0 entry start include 'win32a.inc' ID_CAPTION = 101 ID_MESSAGE = 102 ID_ICONERROR = 201 ID_ICONINFORMATION = 202 ID_ICONQUESTION = 203 ID_ICONWARNING = 204 ID_TOPMOST = 301 section '.text' 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 invoke SetDlgItemText,[hwnddlg],ID_TOPMOST,szString jmp .processed .wmcommand: cmp [wparam],BN_CLICKED shl 16 + IDCANCEL je .wmclose cmp [wparam],BN_CLICKED shl 16 + IDOK 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 ret endp section '.bss' readable writeable szString db "hello hello", 0 flags dd ? caption rb 40h message rb 100h 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',\ SetDlgItemText, 'SetDlgItemTextA' 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',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 enddialog this line works fine for me invoke SetDlgItemText,[hwnddlg],ID_TOPMOST,szString the text is normal. |
|||
03 Jun 2011, 20:54 |
|
ouadji 03 Jun 2011, 21:14
here is my code Code: proc CommandLine hwnd_dlg,msg,wparam,lparam push ebx esi edi cmp [msg],WM_INITDIALOG je .initdialog cmp [msg],WM_COMMAND je .command cmp [msg],WM_CLOSE je .close .notprocessed: xor eax,eax jmp .finish .initdialog: ;int3 mov esi,only_cmd_line invoke SetDlgItemText,[hwnd_dlg],ID_CMDLINE,esi ;<-------------- here jmp .processed .command: cmp [wparam],IDCANCEL je .close cmp [wparam],IDCLEAR_cmdline je .clear_cmdline cmp [wparam],IDOK jne .finish mov esi,only_cmd_line invoke GetDlgItemText,[hwnd_dlg],ID_CMDLINE,esi,0xFF0 lea edi,[esi+eax] xor al,al stosb ;int3 invoke EndDialog,[hwnd_dlg],TRUE jmp .finish .clear_cmdline: mov esi,only_cmd_line xor eax,eax xchg [esi],eax mov [memo_cmdline],eax invoke SetDlgItemText,[hwnd_dlg],ID_CMDLINE,esi invoke SetFocus,[hwnd_dlg] jmp .processed .close: mov eax,[memo_cmdline] mov dword[only_cmd_line],eax invoke EndDialog,[hwnd_dlg],FALSE .processed: mov eax,1 .finish: pop edi esi ebx ret endp Code: dialog comdline_setup_dialog,' C o m m a n d L i n e E d i t o r',\ 50,30,350,45,WS_CAPTION+WS_POPUP+WS_SYSMENU+DS_MODALFRAME dialogitem 'EDIT','',ID_CMDLINE,8,8,334,12, \ WS_VISIBLE+WS_BORDER+ES_AUTOHSCROLL+WS_TABSTOP dialogitem 'BUTTON','OK',IDOK,131,28,40,12,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON dialogitem 'BUTTON','Cancel',IDCANCEL,179,28,40,12,WS_VISIBLE+WS_TABSTOP+BS_PUSHBUTTON dialogitem 'BUTTON','Clear',IDCLEAR_cmdline,294,28,40,12,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON enddialog |
|||
03 Jun 2011, 21:14 |
|
Enko 03 Jun 2011, 21:54
Code: ; DialogBox example format PE GUI 4.0 entry start include 'win32a.inc' ID_CAPTION = 101 ID_MESSAGE = 102 ID_ICONERROR = 201 ID_ICONINFORMATION = 202 ID_ICONQUESTION = 203 IDCLEAR = 204 ID_CMDLINE = 301 IDCLEAR_cmdline = 55 section '.text' 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 .initdialog cmp [msg],WM_COMMAND je .command cmp [msg],WM_CLOSE je .close .notprocessed: xor eax,eax jmp .finish .initdialog: ;int3 mov esi,only_cmd_line invoke SetDlgItemText,[hwnd_dlg],ID_CMDLINE,esi ;<-------------- here jmp .processed .command: cmp [wparam],IDCANCEL je .close cmp [wparam],IDCLEAR_cmdline je .clear_cmdline cmp [wparam],IDOK jne .finish mov esi,only_cmd_line invoke GetDlgItemText,[hwnd_dlg],ID_CMDLINE,esi,0xFF0 lea edi,[esi+eax] xor al,al stosb ;int3 invoke EndDialog,[hwnd_dlg],TRUE jmp .finish .clear_cmdline: mov esi,only_cmd_line xor eax,eax xchg [esi],eax mov [memo_cmdline],eax invoke SetDlgItemText,[hwnd_dlg],ID_CMDLINE,esi jmp .processed .close: mov eax,[memo_cmdline] mov dword[only_cmd_line],eax invoke EndDialog,[hwnd_dlg],FALSE .processed: mov eax,1 .finish: pop edi esi ebx ret endp section '.bss' readable writeable szString db "hello hello", 0 only_cmd_line db "hola hola hola",0 flags dd ? hwnd_dlg dd 0 caption rb 40h message rb 100h memo_cmdline dd 0 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',\ SetDlgItemText, 'SetDlgItemTextA' section '.rsrc' resource data readable directory RT_DIALOG,dialogs resource dialogs,\ 37,LANG_ENGLISH+SUBLANG_DEFAULT,comdline_setup_dialog dialog comdline_setup_dialog,' C o m m a n d L i n e E d i t o r',\ 50,30,350,45,WS_CAPTION+WS_POPUP+WS_SYSMENU+DS_MODALFRAME dialogitem 'EDIT','',ID_CMDLINE,8,8,334,12, \ WS_VISIBLE+WS_BORDER+ES_AUTOHSCROLL+WS_TABSTOP dialogitem 'BUTTON','OK',IDOK,131,28,40,12,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON dialogitem 'BUTTON','Cancel',IDCANCEL,179,28,40,12,WS_VISIBLE+WS_TABSTOP+BS_PUSHBUTTON dialogitem 'BUTTON','Clear',IDCLEAR_cmdline,294,28,40,12,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON enddialog your dlg proc a guess it works... no blue text. so as I sad, the problem is not there[/quote] |
|||
03 Jun 2011, 21:54 |
|
ouadji 03 Jun 2011, 22:29
there is a similar problem with FASMW, with "serach/position(row)" ... but not with "column" !! Code: proc PositionDialog hwnd_dlg,msg,wparam,lparam push ebx esi edi cmp [msg],WM_INITDIALOG je .initdialog cmp [msg],WM_COMMAND je .command cmp [msg],WM_CLOSE je .close xor eax,eax jmp .finish .initdialog: invoke SendMessage,[hwnd_asmedit],AEM_GETPOS,aepos,0 cinvoke wsprintf,string_buffer,_value,[aepos.caretLine] invoke SetDlgItemText,[hwnd_dlg],ID_ROW,string_buffer ;<------------ here cinvoke wsprintf,string_buffer,_value,[aepos.caretPosition] invoke SetDlgItemText,[hwnd_dlg],ID_COLUMN,string_buffer jmp .processed |
|||
03 Jun 2011, 22:29 |
|
ctl3d32 03 Jun 2011, 23:08
go to cmd and type "format c:", reinstall windows and it will get fixed.
|
|||
03 Jun 2011, 23:08 |
|
Alphonso 04 Jun 2011, 00:08
This is focus for keyboard. What if you get rid of the WS_TABSTOP ? or maybe set the tab focus to somewhere else if you want the TAB function.
Enko, in the fasm example the reason is there is no text in the box to be highlighted. Try adding some text to the default TAB focus in the .wminitdialog: section. Code: .wminitdialog: ... invoke SetDlgItemText,[hwnddlg],ID_CAPTION,szString ... |
|||
04 Jun 2011, 00:08 |
|
ouadji 04 Jun 2011, 08:06
I tried everything, It is impossible to remove the highlighting while keeping the cursor. It is really disappointing that there is no option to do that. @Alphonso : if I get rid of the WS_TABSTOP, I have no longer the cursor ... and "SetFocus" doesn't change anything |
|||
04 Jun 2011, 08:06 |
|
ctl3d32 04 Jun 2011, 13:01
Run your program inside a virtual machine to see if you get the same problem.
|
|||
04 Jun 2011, 13:01 |
|
dancho 04 Jun 2011, 14:37
@ouadji
check for WM_CTLCOLORSTATIC and WM_CTLCOLOREDIT in psdk, I think it may help you... |
|||
04 Jun 2011, 14:37 |
|
ouadji 04 Jun 2011, 14:47
Last edited by ouadji on 04 Jun 2011, 14:59; edited 2 times in total |
|||
04 Jun 2011, 14:47 |
|
ctl3d32 04 Jun 2011, 14:49
@ouadji,
ImageShack images doesn't show in this forum for many members, including me. |
|||
04 Jun 2011, 14:49 |
|
JohnFound 04 Jun 2011, 14:53
Try to send EM_SETSEL with wparam = -1 and lparam = -1 - it should remove the selection from the edit control. You should send this message in WM_SETFOCUS handler of the edit control.
The single line edit control selects the whole text when it receives the focus. And this behavior is good IMHO. |
|||
04 Jun 2011, 14:53 |
|
dancho 04 Jun 2011, 14:56
@ouadji
well,another trick ( simplest one ) is to use EM_SETSEL with wParam=-1 and lParam=0 to deselected characters in edit control... edit ah John was faster... |
|||
04 Jun 2011, 14:56 |
|
ouadji 05 Jun 2011, 10:05
amazing, but I got no result with EM_SETSEL Quote: from MSDN (+JohnFound, +dancho) it's really disappointing that there is no way to remove this highlighting easily. That said, thank you all for your help |
|||
05 Jun 2011, 10:05 |
|
dancho 05 Jun 2011, 11:20
@ouadji
try to check first if EN_CHANGE notification message is sent and then use EM_SETSEL ... |
|||
05 Jun 2011, 11:20 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.