Reputation: 137
I have a CDialog
contains many CEdit
objects. They all have to do similar operations when kill focus (for example: when focus is killed the edit box text's is changed).
I can define the dialog's message map this way:
ON_EN_KILLFOCUS(ID1, kf1)
ON_EN_KILLFOCUS(ID2, kf2)
ON_EN_KILLFOCUS(ID3, kf3)
ON_EN_KILLFOCUS(ID4, kf4)
and all kf
function will call a common function:
CommonFunction(CEdit* editBox)
But is there a way to transfer the edit box in the kf
function itself? I mean to define it this way:
ON_EN_KILLFOCUS(ID1, kf(ID1))
ON_EN_KILLFOCUS(ID2, kf(ID2))
ON_EN_KILLFOCUS(ID3, kf(ID3))
ON_EN_KILLFOCUS(ID4, kf(ID4))
or another way.
NOTE: I use Visual C++ 6.0 ('98 edition)
Upvotes: 0
Views: 563
Reputation: 10415
You can use ON_CONTROL_RANGE in the message map to dispatch all of the messages to the same function. To do this it is necessary to assure that the IDs are in a continuous range. (Edit resource.h if necessary.)
ON_CONTROL_RANGE(BN_CLICKED, IDC_RADIO_DRAWALL, IDC_RADIO_DRAWBEST, OnRadioBtnDraw)
void CVisualPPView::OnRadioBtnDraw(UINT nID)
{
}
Upvotes: 1