Thanks for your help !
Frank Keck
-shezan-
Try subclassing the edit control. Then you will be able to process all the
messages for the control.
If your edit control is IDC_EDIT1, and you have a member variable in your
class to handle the edit control...
m_MyDialog.m_MyEdit.SubclassDlgItem(IDC_EDIT1, &m_MyDialog);
This will route all messages from the edit through the dialog class. This
also Attaches the window for the edit control to m_MyDialog.m_MyEdit.
Jim Wuerch
(remove the 'miwax' from my address to reply by email)
Frank Keck wrote:
>
> Hi there,
> I try to create a CEdit control that processes WM_CHAR, VK_RETURN
> message itself ( using VC++ 5.0).
> I tried out message reflection and overwriting the edit's windowproc,
> but it doesn't work.
> Does anybody know, how I can get the VK_RETURN into the edit's OnChar
> function ??
>
> Thanks for your help !
> Frank Keck
--
Girish Bharadwaj [VC++/MVP]
http://members.tripod.com/~GBharadwaj/index.html
Email :gir...@usa.net
The code example at: http//home.earthlink.net/~railro/example5.zip
demonstrates how to subclass the CEdit control to handle the VK_RETURN.
You have to overide
UINT CExampleEdit::OnGetDlgCode()
{
return CEdit::OnGetDlgCode()|DLGC_WANTMESSAGE;
}
but then you also have to handle some normal work of the CEdit control
yourself:
void CExampleEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (nChar == VK_TAB) // Handle the TAB key
{
if (::GetKeyState(VK_SHIFT) < 0)
{
(CDialog *)GetParentOwner()->GetNextDlgTabItem(this,
TRUE)->SetFocus();
}
else
{
(CDialog *)GetParentOwner()->GetNextDlgTabItem(this)->SetFocus();
}
return;
}
if (nChar == VK_RETURN)
{
// Do whatever you want to do here... how about tab to the next
control:
(CDialog *)GetParentOwner()->GetNextDlgTabItem(this)->SetFocus();
return;
}
if (nChar == VK_ESCAPE)
{
// Need to cancel the dialog
(CDialog *)GetParentOwner()->SendMessage(WM_CLOSE);
return;
}
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
BTW, to use the control, all you have to do is include the header file
and create a variable of the new class:
// Dialog Data
//{{AFX_DATA(CExampleDlg)
enum { IDD = IDD_EXAMPLE };
CExampleEdit m_CtrlEdit2;
CExampleEdit m_CtrlEdit1;
CString m_szValue1;
CString m_szValue2;
//}}AFX_DATA
There is no need to use SubclassDlgItem().
*****************
Hope this helps.
Rail
--
Recording Engineer/Software Developer
Rail Jon Rogut Software
http://home.earthlink.net/~railro
mailto:rai...@earthlink.net
You need to process the WM_GETDLGCODE message and return the correct
flags so that the WM_CHAR for return gets routed to you:
int MyDialog::OnGetDlgCode()
{
return CDialog::OnGetDlgCode() | DLGC_WANTRETURN;
}
(My memory is a bit hazy on the return type and parameters, as well as
the DLGC_ code. There are several DLGC_ values, and you may want
other codes as well). Then your subclassing of the CEdit will work (I
just did this last week, you'd think I could remember the codes that
long...)
joe
On Mon, 02 Feb 1998 12:07:33 +0100, Frank Keck <k...@ugs.com> wrote:
>Hi there,
>I try to create a CEdit control that processes WM_CHAR, VK_RETURN
>message itself ( using VC++ 5.0).
>I tried out message reflection and overwriting the edit's windowproc,
>but it doesn't work.
>Does anybody know, how I can get the VK_RETURN into the edit's OnChar
>function ??
>
>Thanks for your help !
>Frank Keck
Joseph M. Newcomer
newc...@flounder.com
http://www3.pgh.net/~newcomer