Boards /
Studio/Dialog Editor /
Topic 870
Active cursor instead of focus ?
Started by krunch ·
2009-08-11 12:30 UTC ·
10 replies · SMF topic #870
krunch
2009-08-11 12:30 UTC
Hello everybody
When my dialog box opens I'd want to get the cursor actived in a TextBox, just after the default value (instead of focus wich highlight it)..
Do you think it's possible ??
owenwengerd
2009-08-11 18:29 UTC
If your question is about plain DCL, you should ask it here:
{2}
krunch
2009-08-11 19:54 UTC
sorry it was for a standart .dcl..
But can you do that with a TextBox, when a Modal Dialog opens ?
owenwengerd
2009-08-11 23:52 UTC
Yes, I believe you can do that with an OpenDCL TextBox by using (dcl_TextBox_SetSel) and a zero-length selection range.
krunch
2009-08-12 11:00 UTC
Thanks, I tried but I didn't find..
(defun c:TRY_MBox_OnInitialize (/)
;;; (dcl_Control_ZOrder TRY_MBox_TextButton1 1)
(dcl_Control_SetProperty TRY_MBox_TextBox1 "Text" "default")
(dcl_TextBox_SetSel TRY_MBox_TextBox1 7 7)
)
The content of the TextBox is still highlighted, even with other start/end values for dcl_TextBox_SetSel (like -1), in fact the cursor stays in the end of the TextBox even without dcl_TextBox_SetSel.
And if another control is MovedToTop the TextBox loose the cursor..
owenwengerd
2009-08-12 14:49 UTC
You'll need to do that later in the startup sequence. After OnInitialize returns and the dialog is displayed, input focus is moved to the first control in the tab order, causing any of your attempts in OnInitialize to be ignored. You might try it from the OnSetFocus event of the text box, or simply change your tab order so the text box is not at the top.
krunch
2009-08-12 17:26 UTC
Ok, it works when dcl_TextBox_SetSel is called by the OnSetFocus event of another control (the first in the tab order). It don't works when called by himself (by the TextBox OnSetFocus).
In fact I added a control because I don't know how to change the tab order...
How do you do ? dcl_Control_SetFocus ?
owenwengerd
2009-08-12 19:40 UTC
You should change the tab order at design time in OpenDCL Studio (see the Tab/Z Order pane):
{2}
krunch
2009-08-12 22:00 UTC
Yes.. sorry I read too fast and what I was looking for was right under my nose.
Finally, to do what I want, I need a control (must be visible) that support a SetFocus event and that call dcl_TextBox_SetSel ?
May be there is not simpler solution ?
otherwise thank a lot.. nice tool anyway
owenwengerd
2009-08-13 02:08 UTC
I don't see any good solution. Perhaps you could put a PictureBox on the form, then call the SetSel from its OnPaint event handler. You would need to set a flag to make sure that SetSel is only called once.
krunch
2009-08-13 10:06 UTC
Yes it works too ! And picture can be not visible with the same background color
Thank you very much