Given below is what I would call a 'hack' but it works ( you have to check for any undesirable side-affects :=). If you find a better/ ideal solution please post it here.
1. subclass the edit control
.h
==
class CPDEdit: public CEdit
{
public:
DECLARE_MESSAGE_MAP()
afx_msg LRESULT OnKeyDown(WPARAM, LPARAM);
afx_msg LRESULT OnKeyUp(WPARAM, LPARAM);
};
.cpp
====
BEGIN_MESSAGE_MAP(CPDEdit, CEdit)
ON_MESSAGE(WM_KEYDOWN, OnKeyDown)
ON_MESSAGE(WM_KEYUP, OnKeyUp)
END_MESSAGE_MAP()
LRESULT CPDEdit::OnKeyDown(WPARAM w, LPARAM l) {
if ('\t' == w) {
return 0;
}
return DefWindowProc(WM_KEYDOWN, w, l);
}
LRESULT CPDEdit::OnKeyUp(WPARAM w, LPARAM l) {
if ('\t' == w ) {
DWORD s = GetSel();
if (0 != s && LOWORD(s) == HIWORD(s)) {
ReplaceSel(_T("\t"));
return 0;
}
}
return DefWindowProc(WM_KEYUP, w, l);
}
2. Create a member variable for the Edit of control type from the dialog resource editor (right-click the control and select "Add variable ...".
3. Change the type of this variable from CEdit to CPDEdit manually in the dialog header.