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.
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.