hii
i have subclassed an edit control.
and i want to select all text when it gets focus

i tried several ways




; on WM_SETFOCUS
invoke CallWindowProc,PtrEditProc,hwnd,EM_SETSEL,0,-1


and have tried on Parent window

on WM_COMMAND ,EN_SETFOCUS
the same code as above .. but still doesnt work .

any ideas ?

bye
thanks
eko
Posted on 2004-10-10 13:26:39 by eko
eko,

Look at EM_SETSEL

hth

farrier
Posted on 2004-10-10 15:54:07 by farrier
Try this:

invoke SendMessage,hEdit,EM_SETSEL,0,-1


And download MSDN or PSDK - these are very useful references for things like this.



/siddhartha
Posted on 2004-10-10 16:11:04 by siddhartha
An application sends an EM_SETSEL message to select a range of characters in an edit control.

EM_SETSEL
wParam = (WPARAM) (INT) nStart; // starting position
lParam = (LPARAM) (INT) nEnd; // ending position


Parameters

nStart

Value of wParam. Specifies the starting character position of the selection.

nEnd

Specifies the ending character position of the selection.

Return Values

This message does not return a value.

Remarks

In a rich edit control, if the selection is not entirely contained in the first 64K, use the message EM_EXSETSEL.
If the nStart parameter is 0 and the nEnd parameter is -1, all the text in the edit control is selected. If nStart is -1, any current selection is removed. The caret is placed at the end of the selection indicated by the greater of the two values nEnd and nStart
.
In previous versions of Windows, the wParam parameter is a flag that is set to FALSE to scroll the caret into view or set to TRUE to omit the scrolling. A Win32-based application should use the EM_SCROLLCARET message to scroll the caret into view.

In earlier versions of Windows, the starting and ending positions of the selection are indicated by the low- and high-order words, respectively, of the lParam parameter.


just what i did . still nothing .
any ideas?
bye
thanks
eko
Posted on 2004-10-11 15:53:52 by eko
eko,

Give us a look at what you did, maybe something easy to fix. Show us the relavent parts of your code.

farrier
Posted on 2004-10-12 00:17:17 by farrier
i have wrote what i did . .
subclassed the editwindow (invoke SetWindowLong,somehwnd,GWL_WNDPROC,offset someproc)

and captured the WM_SETFOCUS then send message the to orginal window's proc with EM_SETSEL - this doesnt work ...


i tried also - capture WM_COMMAND ,EN_SETFOCUS then send EM_SETSEL to the orignal windows proc .and still - doesntwork .

anyideas?

bye
thanks
eko
Posted on 2004-10-12 08:01:05 by eko
no reply ..... ;[

anyone knows how to get editbox selectalll when it gets focus?


thanks
bye

eko
Posted on 2004-10-15 08:13:49 by eko
It will be a lot easier for us if you show some code. It's hard to trace errors without looking at the source.



/siddhartha
Posted on 2004-10-15 21:27:14 by siddhartha
i dont have a code .
i just dont know how to select all when editbox getfocous.
i tried select all on WM_SETFOCUS like i wrote above . and this doesnt work
Posted on 2004-10-16 13:34:04 by eko
Hi
What about

Invoke SendMessage,hEdit,WM_GETTEXTLENGTH,0,0

Invoke SendMessage,hEdit,EM_SETSEL,0,EAX


Antonis
Posted on 2004-10-16 16:54:37 by akyprian
thanks for reply

i just notice the main problem . it does a selectall both ways .

but it flicks for a less than a sec and the selection gone . (NOT the text)


any ideas?
Posted on 2004-10-16 19:00:48 by eko
I'll try one more time :)

eko,

Reply with an attachment showing us the relevant assembly code segments for your edit control. Maybe we will see something you have missed. You keep asking for help with your program, but we can't see it and therefore can't offer anything more than the correct suggestions you have already received.

i dont have a code .


What do you mean by this?

farrier
Posted on 2004-10-16 20:06:10 by farrier
firsttry



;subclassed the editproc (setwindowlong - )
Editproc proc hwnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD

invoke CallWindowProc,PtrEditProc,hwnd,uMsg,wParam,lParam

cmp uMsg,WM_SETFOCUS
jnz _out
invoke CallWindowProc,PtrEditProc,hwnd,EM_SETSEL,0,-1

_out:
ret
Editproc endp

2nd try




;subclassed the editproc (setwindowlong - )
Editproc proc hwnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
cmp uMsg,WM_SETFOCUS
jnz @F
invoke CallWindowProc,PtrEditProc,hwnd,EM_SETSEL,0,-1
;once with xoreax,eax and ret
;and once with outit
@@:

invoke CallWindowProc,PtrEditProc,hwnd,uMsg,wParam,lParam

_out:
ret
Editproc endp


3rd try



this time i subclassed the parent window of the editcontrol
PartentWindow hwnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
cmp uMsg,WM_COMMAND
jnz @F

mov eax,wParam
shr eax,16

cmp eax,EN_SETFOCUS
jnz @F
mov ecx,lParam
cmp ecx,edithwnd
jnz @F

invoke CallWindowProc,PtrEditProc,edithwnd,EM_SETSEL,0,-1
;once with xoreax,eax and ret
; once with outit
; and one after the callwindowproc
@@:

invoke CallWindowProc,PtrPartentWindow,hwnd,uMsg,wParam,lParam

_out:
ret
PartentWindow endp


all these methods make the editcontrolblink when it gets focus

any ideas/soultions ?

bye
thanks

eko
Posted on 2004-10-16 20:30:41 by eko
Well, I've just tried without subclassing - everything worked OK.
Then do nothing in sublass proc about it, just use SendMessage from parent.
Posted on 2004-10-20 16:21:56 by The Svin
eko, try to call original window code then execute your sub-classed code.
Posted on 2004-10-20 18:26:51 by bitRAKE
Hi,

Attached is a working demo of both a multiline and a single line edit control.

I hope it helps

Antonis
Posted on 2004-10-21 04:16:30 by akyprian
bitrake: have tired it , didnt work for me
svin,akyprian that's work THANKS

my problem was that after i proccess EN_SETFOCUS (under wm_command)

i let orginal proc proccess the msg, (forgot the ret)

thanks alot !

bye

eko
Posted on 2004-10-22 09:41:12 by eko