c++ - How to implement the event handler for a MFC CEdit ON_EN_SETFOCUS? -


i'm maintaining mfc c++ code , have screen many cedit objects.

i want implement onfocus event of write 1 method treat event.

to need know cedit id fired event looks implementation of onfocus event in mfc not have parameter (compared other events onctlcolor has cwnd* object parameter).

i refuse believe have implement small method each single cedit passing id main method want!. if that's solution, shame on mfc!

on_control_range macro exists allow mapping single handlers same event on multiple controls.

first need ensure control ids sequential. in header need declare handler takes control id parameter:

afx_msg void onsetfocusmulti(uint ctrlid); 

this allows distinguish sender control in handler if need it.

now need add message map, instead of bunch of on_en_setfocus(idc_edit1, &cmydlg::onsetfocus):

on_control_range(en_setfocus, idc_edit1, idc_edit_x, onensetfocusmulti)                       ^           ^          ^             ^ //       notification code | first ctrl | last ctrl |   handler 

other message map macros documented here


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -