Messages of CEdit in visual C++6.0

筅森魡賤 提交于 2019-12-12 02:18:13

问题


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)


回答1:


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)
{
}


来源:https://stackoverflow.com/questions/17206564/messages-of-cedit-in-visual-c6-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!