mfc - How to disallow tab key to switch focus between edit control and button within dialog box? -
i have dialog box having buttons , edit box.
when edit control have focus if press tab key moves , focus button.
wanted tab key work in such way not switch focus instead should work tab input inside edit control i.e. input edit box keys.
the solution simple, , consists of handling wm_getdlgcode message. allows control implementation fine-tune keyboard handling (among other things).
in mfc means:
- derive custom control class cedit.
- add on_wm_getdlgcode message handler macro message map.
- implement ongetdlgcode member function, adds
dlgc_wanttab
flag return value. - subclass dialog's control, e.g. using ddx_control function.
header file:
class myedit : public cedit { protected: declare_message_map() public: afx_msg uint ongetdlgcode(); };
implementation file:
begin_message_map(myedit, cedit) on_wm_getdlgcode() end_message_map uint myedit::ongetdlgcode() { uint value{ cedit::ongetdlgcore() }; value |= dlgc_wanttab; return value; }
Comments
Post a Comment