Click to See Complete Forum and Search --> : How use SubclassDlgItem() function?
June 26th, 1999, 03:14 AM
I`m designing a dialog ,look like DOS dialog ,press RETURN ,DOWN ,UP
arrow ,jump to the next edit control.I don`t known how complete it.
Please help me.
ric
June 26th, 1999, 09:45 AM
I did not underdstand your question, but nevertheless use SubclassDlgItem like this:
1. First derive a class from the class of the control you want to subclass.
2. Override some functions to do whatever you want
3. Subclass the control in the InitDialog() like this:
SubclassDlgItem(IDC_CONTROL, this);
This will make the messages to be routed through your overrided functions.
But if you need just to catch some keys if they are pressed, better try this:
in the PreTranslateMessage() function of your dialog place similar code to the following:
BOOL CMyDialog::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message == WM_KEYDOWN && GetDlgItem(IDC_CONTROL) == GetFocus())
{
switch(pMsg->wParam)
{
case VK_ESCAPE:
case VK_RETURN:
case VK_HOME:
}
}
}
Hope this clears a little.
Regards,
ric
singjie
June 26th, 1999, 10:38 AM
It take me for four days to resolve this problem,
thank you again.
Rail Jon Rogut
June 26th, 1999, 12:55 PM
Alternatively, check out Examples 5 & 14 at my web site (http://home.earthlink.net/~railro/mfc_link.html) to know how to subclass a control.
Rail
Recording Engineer/Software Developer
Rail Jon Rogut Software
railro@earthlink.net
http://home.earthlink.net/~railro/
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.