OpenDCL Forums

OpenDCL => Studio/Dialog Editor => Topic started by: krunch on August 11, 2009, 05:30:21 AM

Title: Active cursor instead of focus ?
Post by: krunch on August 11, 2009, 05:30:21 AM
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 ??
Title: Re: Active cursor instead of focus ?
Post by: owenwengerd on August 11, 2009, 11:29:27 AM
If your question is about plain DCL, you should ask it here:
http://www.theswamp.org/index.php?board=38.0 (http://www.theswamp.org/index.php?board=38.0)
Title: Re: Active cursor instead of focus ?
Post by: krunch on August 11, 2009, 12:54:21 PM
sorry it was for a standart .dcl..

But can you do that with a TextBox, when a Modal Dialog opens ?
Title: Re: Active cursor instead of focus ?
Post by: owenwengerd on August 11, 2009, 04:52:54 PM
Yes, I believe you can do that with an OpenDCL TextBox by using (dcl_TextBox_SetSel) and a zero-length selection range.
Title: Re: Active cursor instead of focus ?
Post by: krunch on August 12, 2009, 04:00:58 AM
Thanks, I tried but I didn't find..

Code (autolisp) Select

(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..
Title: Re: Active cursor instead of focus ?
Post by: owenwengerd on August 12, 2009, 07:49:39 AM
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.
Title: Re: Active cursor instead of focus ?
Post by: krunch on August 12, 2009, 10:26:20 AM
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 ?
Title: Re: Active cursor instead of focus ?
Post by: owenwengerd on August 12, 2009, 12:40:21 PM
You should change the tab order at design time in OpenDCL Studio (see the Tab/Z Order pane):
http://www.opendcl.com/HelpFiles/index.php?page=Usage/Studio.htm (http://www.opendcl.com/HelpFiles/index.php?page=Usage/Studio.htm)
Title: Re: Active cursor instead of focus ?
Post by: krunch on August 12, 2009, 03:00:41 PM
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
Title: Re: Active cursor instead of focus ?
Post by: owenwengerd on August 12, 2009, 07:08:33 PM
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.
Title: Re: Active cursor instead of focus ?
Post by: krunch on August 13, 2009, 03:06:04 AM
Yes it works too ! And picture can be not visible with the same background color

Thank you very much