PDA

View Full Version : 2 text controls on one screen?


mroskothen
03-11-2002, 04:23 PM
Hi,
what is the trick with having 2 text controls on the same screen. One always makes the other disappear.
Thanks, Markus

torija
03-11-2002, 09:46 PM
first, draw 2 text controls.

And then, call 2 ITEXTCTL_SetActive functions.

You can find 2 text controls.

Murray Bonner
03-12-2002, 11:34 AM
Whenever you make changes to an ITextCtl object, you also need to call ITEXTCTL_Redraw(). See the ITextCtl interface section of the API reference for more about this function.

As for ITEXTCTL_SetActive(), this function cost me some hair. Where there are multiple text ctls. in a dialog, you need to deactivate a text control when a user has finished with it, in order to keep that control from receiving subsequent key events. Then call IDIALOG_SetFocus() to move the focus to the next text control in the dialog. Next, you need to activate (call ITEXTCTL_SetActive(pctrl, TRUE)) the control that will receive the user's next input -- only an active control can receive events.

To manage control navigation, I've found it useful to maintain interface-specific member-pointers to each of the control objects in the dialog. Then, by keeping one additional IControl member-pointer (a base class pointer) synchronized with the control that has the focus, you'll always know where you are in the user interface simply by testing for equality between the focus-pointer and each of the I*Ctl pointers. Obviously, you need to cast each of the I*Ctl pointers to an IControl * in the test for equality.

Lastly, don't forget to cascade the event by calling ITEXTCTL_HandleEvent().

I could be wrong about the need to call IDIALOG_SetFocus() (perhaps calling I*CTL_SetActive() moves the focus as well). It is clearly irrelevant if you're not using a dialog as a container for the controls. Anyhew, this is how I got it to work reliably and I hope this helps you. Now prepare for the others to correct me :).

Have fun!
Regards,
MB