Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Selecting Edit Field Text upon Click
#1
I can't figure this out on my own but I looked many places in forum. When user clicks on edit field, any text in there should become selected, so the user can make choice of just typing to replace or copy, paste etc. This is like behaviour when clicking on url field in IE. I can't seem to make this work in my dialogs. Why did this not work? What is best way?
Thanks so much!!!
S

Function Dialog8
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
out

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;3 Edit 0x54030080 0x200 24 14 96 14 ""
;4 Edit 0x54030080 0x200 24 38 96 14 ""
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030605 "" "" "" ""

str controls = "3 4"
str e3 e4
e3 = "hello"
e4 = "goodbye"
if(!ShowDialog("Dialog8" &Dialog8 &controls)) ret

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_CTLCOLOREDIT    
,,ifk((1))
,,,out GetDlgCtrlID(child(mouse))
,,,_i = GetDlgCtrlID(child(mouse))
,,,SendMessage _i EM_SETSEL 0 -1
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#2
Hi,

got it working by using


Code:
Copy      Help
,,,SendMessage id(_i hDlg) EM_SETSEL 0 -1

instead of

Function Dialog8
Code:
Copy      Help
,,,SendMessage _i EM_SETSEL 0 -1

HTH..
#3
Thanks! ! ! !
I have never quite gotten the hang of lParam, wParam, and how they are used in SendMessage statements. It's like the borderland between QM world and MSDN/C#. I just try to reverse engineer Gintaras' examples and try to vary them with stuff from MSDN. I think if I could master all the various case WM_ messages, I would be a lot farther along. Do you know if any good resources?
Thanks again,
S
#4
When I actually tried this, I got bad RT error that closes the dialog:

Exception 0xC00000FD. A new guard page for the stack cannot be created. In ntdll.dll at 0x76EFE04E (0x76ED0000+0x2E04E). ?

But then I saw that this exact issue was already addressed in forum:
http://www.quickmacros.com/forum/showthr...p?tid=1644

Quote:Edit box receives mouse button message after EN_SETFOCUS. You can PostMessage hDlg WM_APP 0 0, and on WM_APP (which must be in the first sel) set selection. Posted message arrives after the control receives mouse button message.

Easier way - use simple combo instead.

So, as suggested using Simple ComboBox this would be the easier and more effective way of getting this exact functionality (it turns out the internet url acts like a simple combo box too, so very appropriate suggestion by Gintaras from this other thread post. If I need to to do it for rich edit, I will set up the WM_APP asynchronous method, but this works for most of my dialogs very easily - and easy to setwintext/getwintext strings from simple combo box field without having to use CB_ functions.

Function Dialog8
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
out

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;3 ComboBox 0x54230641 0x0 24 14 96 14 ""
;4 ComboBox 0x54230641 0x0 24 38 96 14 ""
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030605 "" "" "" ""

str controls = "3 4"
str cb3 cb4
if(!ShowDialog("Dialog8" &Dialog8 &controls)) ret
ret
;messages
sel message
,case WM_INITDIALOG
,,_s = "hello";_s.setwintext(id(3 hDlg))
,,_s = "goodbye";_s.setwintext(id(4 hDlg))        
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

Thanks all!
S


Forum Jump:


Users browsing this thread: 1 Guest(s)