If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Code reuse by handling CEdit ON_WM_SETFOCUS handler

In my application I need to to bring up a keyboard dialog when a user clicks any of the edit boxes in the application. Therefore I have OnSetFocus() implemented in all over the application (dialogs) which brings up the keybaord in each of them (which is just another dialog).

I would rather subclass the CEdit control and implement SetFocus() in it and use this class to lend this behavior automatically to all the edit boxes I am using in the application. The problem is that the keyboard dialog is really part of the end dialog, more accurately part of the base class of the end dialog which has the following class hierarchy.

Code:

CDialog
CDialogEx - it implements ShowKeyboard()
CMyDialog - it calls the base ShowKeyboard() to bring up the dialog in OnSetFocus()

The problem is how can I access the ShowKeyboard() function from the underlying dialog while overriding CEdit::OnSetFocus()? Thanks.

Re: Code reuse by handling CEdit ON_WM_SETFOCUS handler

First of all: do not subclass your control using CEdit class. Derive your own from CEdit and then subclass the control.
Secondly, CDialogEx does not implement ShowKeyboard function unless you are using older VS version.
MFC starting with VS 2008 already have CDialogEx, so I assume you are working with VS 2005 or earlier.

Another thing: since this requirement is edit control specific, why don’t you implement ShowKeyboard in your from CEdit derived class and use this class in all projects you need this functionality. Your dialog class does not event have to know about a need for showing a keyboard.

There are only 10 types of people in the world:Those who understand binary and those who do not.

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.