This must be simple but i am loosing it somewhere...

I use this code to give focus to a editbox in a dialog after the defaultpushbutton is pressed:

; clear the edit text
Call SetDlgItemText,hDlg,710,offset sz_null

; and give him focus again
Call SendDlgItemMessage,hDlg,780,WM_KILLFOCUS,0,0
Call SendDlgItemMessage,hDlg,710,WM_SETFOCUS,0,0

what i want is that the focus returns to the edit box field after the button was pressed.

Strange things happen:
-if i press Enter everything is ok, but if i press the button all actions are done ok but next time i try to enter something in the edittext field i get a "ding" sound and i cant eneter text in there anymore...

Any ideeas?

710 is the ID of the editbox
780 is the ID of the default button "save and reenter"
Posted on 2002-05-21 17:56:22 by BogdanOntanu
hi BogdanOntanu,

i dont ever use dialog boxes so im not sure if you can process certain messages. have you tryed using the api SetFocus instead? ive tested your problem and can reproduce it using your method but with SetFocus it works like it should.

also if you send WM_ACTIVATE instead of WM_SETFOCUS it should work.
Posted on 2002-05-21 18:10:37 by smurf
Thx man!

I actually works ok like this

Call GetDlgItem,[hDlg],710
Call SetFocus,eax

Cant figure out why my original code did not worked but who cares anymore?

Posted on 2002-05-21 18:53:03 by BogdanOntanu
To continue the :stupid: series ...

is there a edittext style equivalent to C++ Auto_HSCROLL feature?

i mean cand i easy auto scroll the text in an edit box if there is more input than the box length ?
Posted on 2002-05-21 19:19:55 by BogdanOntanu

This is taken from Svin's LBClass.exe tool for style information on controls:
Automatically scrolls text to the right
by 10 characters when the user types
a character at the end of the line.
When the user presses the ENTER key,
the control scrolls all text back to position zero
Posted on 2002-05-21 20:23:57 by NaN
Thx Nan

But it looks like my res compiler (aka brc32) knows nothing about ES_AUTOSCROLL :(
Posted on 2002-05-21 21:34:44 by BogdanOntanu
I just noticed i forgot to type the "H" in autoscroll, sorry. If your were wise enough to catch this, and still had no luck, here are their hex definitions:


Good Luck,
Posted on 2002-05-21 22:23:49 by NaN
Thx man

even if the style worked in res compiler (ie no errors reported)
it is still not working in practice... the editbox just beeps when i reach at right margin... no scrolling is done...

I guess i must handle this by hand?
Posted on 2002-05-22 15:25:53 by BogdanOntanu
hi BogdanOntanu,

using these styles below you shouldnt have any problems with horizontal scrolling when the text exceeds the size of the editbox. using the keyboard, mouse or whatever there should be no beeping.

Posted on 2002-05-22 15:48:18 by smurf
yup it works now,
thx guys

i still cant figure out why my original code did not work but since i have a good working versions now... that is it ;)
Posted on 2002-05-23 00:14:09 by BogdanOntanu