flat assembler
Message board for the users of flat assembler.

Index > Windows > SetDlgItemText

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji

I use "SetDlgItemText" with an "EditBox" ...
but the text is highlighted in blue.
I don't manage to solve this problem ! Confused
A little help would be welcome.
thank you all

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 03 Jun 2011, 17:28
View user's profile Send private message Send e-mail Reply with quote
Enko



Joined: 03 Apr 2007
Posts: 678
Location: Mar del Plata
Enko
You want to highlight the text in blue? or the text is highighted?

I think you could try SetWindowText
Post 03 Jun 2011, 19:56
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji

the text is highighted (and I don't want that)

SetWindowText ?
I already tried, It doesn't work. The text is still highlighted !


_________________
I am not young enough to know everything (Oscar Wilde)- Image


Last edited by ouadji on 03 Jun 2011, 21:16; edited 2 times in total
Post 03 Jun 2011, 20:23
View user's profile Send private message Send e-mail Reply with quote
Enko



Joined: 03 Apr 2007
Posts: 678
Location: Mar del Plata
Enko
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
Post 03 Jun 2011, 20:26
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji

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 Shocked )

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 03 Jun 2011, 20:38
View user's profile Send private message Send e-mail Reply with quote
Enko



Joined: 03 Apr 2007
Posts: 678
Location: Mar del Plata
Enko
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.
Post 03 Jun 2011, 20:54
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji

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
    


Image


_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 03 Jun 2011, 21:14
View user's profile Send private message Send e-mail Reply with quote
Enko



Joined: 03 Apr 2007
Posts: 678
Location: Mar del Plata
Enko
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]
Post 03 Jun 2011, 21:54
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji

there is a similar problem with FASMW, with "serach/position(row)"
... but not with "column" !!

Image

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
    


_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 03 Jun 2011, 22:29
View user's profile Send private message Send e-mail Reply with quote
ctl3d32



Joined: 30 Dec 2009
Posts: 204
Location: Brazil
ctl3d32
go to cmd and type "format c:", reinstall windows and it will get fixed.
Post 03 Jun 2011, 23:08
View user's profile Send private message Reply with quote
Alphonso



Joined: 16 Jan 2007
Posts: 294
Alphonso
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
...    
Post 04 Jun 2011, 00:08
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji

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. Crying or Very sad

@Alphonso : if I get rid of the WS_TABSTOP,
I have no longer the cursor ... and "SetFocus" doesn't change anything

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 04 Jun 2011, 08:06
View user's profile Send private message Send e-mail Reply with quote
ctl3d32



Joined: 30 Dec 2009
Posts: 204
Location: Brazil
ctl3d32
Run your program inside a virtual machine to see if you get the same problem.
Post 04 Jun 2011, 13:01
View user's profile Send private message Reply with quote
dancho



Joined: 06 Mar 2011
Posts: 74
dancho
@ouadji
check for WM_CTLCOLORSTATIC and WM_CTLCOLOREDIT in psdk,
I think it may help you...
Post 04 Jun 2011, 14:37
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji
Image

_________________
I am not young enough to know everything (Oscar Wilde)- Image


Last edited by ouadji on 04 Jun 2011, 14:59; edited 2 times in total
Post 04 Jun 2011, 14:47
View user's profile Send private message Send e-mail Reply with quote
ctl3d32



Joined: 30 Dec 2009
Posts: 204
Location: Brazil
ctl3d32
@ouadji,

ImageShack images doesn't show in this forum for many members, including me.
Post 04 Jun 2011, 14:49
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
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.
Post 04 Jun 2011, 14:53
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
dancho



Joined: 06 Mar 2011
Posts: 74
dancho
@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...
Post 04 Jun 2011, 14:56
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji

amazing, but I got no result with EM_SETSEL
Quote:
from MSDN (+JohnFound, +dancho)

.... If the start is –1, any current selection is deselected ...
In this case, EM_SETSEL doesn't work. The highlighting is not removed!
it's really disappointing that there is no way to remove this highlighting easily.

That said, thank you all for your help

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 05 Jun 2011, 10:05
View user's profile Send private message Send e-mail Reply with quote
dancho



Joined: 06 Mar 2011
Posts: 74
dancho
@ouadji
try to check first if EN_CHANGE notification message is sent and then use EM_SETSEL ...
Post 05 Jun 2011, 11:20
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< 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-2020, Tomasz Grysztar.

Powered by rwasa.