Need to control when a control gets the focus on a dialog 
Author Message
 Need to control when a control gets the focus on a dialog

I have a dialog box (a property page, actually) with a RichEdit control on
it.  When the RichEdit control is tabbed to, it scrolls to the end of th
etext and highlights everything.  I'd like to stop this automatic behavior.
The text is long (it's an XML file) and it's frustrating to have to undo the
select all and scroll back to the top every time.  Is there a way I can work
around this?

Thanks in advance,
Bill Bonetti



Thu, 01 Jan 2004 08:50:34 GMT  
 Need to control when a control gets the focus on a dialog
I have not used Rich Edit Control but you can override OnSetFocus and not
call the base class for default behavior. Simply put the cursor whereever
you want and exit the function.

--
Ajay Kalra [MVP - VC++]

Note: Please post all replies to newsgroup only.


Quote:
> I have a dialog box (a property page, actually) with a RichEdit control on
> it.  When the RichEdit control is tabbed to, it scrolls to the end of th
> etext and highlights everything.  I'd like to stop this automatic
behavior.
> The text is long (it's an XML file) and it's frustrating to have to undo
the
> select all and scroll back to the top every time.  Is there a way I can
work
> around this?

> Thanks in advance,
> Bill Bonetti



Thu, 01 Jan 2004 15:40:54 GMT  
 Need to control when a control gets the focus on a dialog
What Ajay took as an assumption was that you know how to
subclass...his answer is correct, but if you've not done this before
it might be confusing to you. What you do is go to the ClassWizard,
create a new class, give its base class as CRichEditCtrl, and then
create in that subclass a WM_SETFOCUS handler. Then you have to make
sure you have a control variable for your rich edit class in the
parent dialog; you can read my essay on Avoiding GetDlgItem for how to
do this. If you already have such a variable, just change its type
from CRichEditCtrl to CMyRichEditCtrl (or whatever you called your
class) and you are done.
                        joe



Quote:
>I have not used Rich Edit Control but you can override OnSetFocus and not
>call the base class for default behavior. Simply put the cursor whereever
>you want and exit the function.

Joseph M. Newcomer [MVP]

Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm


Fri, 02 Jan 2004 00:43:15 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Getting the focus onto dialog's Activex controls

2. Controls on property page not getting focus - help

3. C# Focus Issues - Touch Screen - User Controls - Button Control - TextBox

4. Pass control-focus to control from a manager class

5. CListCtrl: The List Control de-highlights when the control loses focus

6. Dialog Control Focus

7. changing focus from tab control to main dialog

8. How do I set focus to Edit Box control in Dialog app

9. Dialog Control Focus

10. Own Dialog box control focus

11. Finding last focused control in a dialog

12. changing control focus withing a dialog

 

 
Powered by phpBB® Forum Software