MFC中如何在按钮控件的BN_CLICK消息响应函数中获取控件ID

RT~
2025-01-01 09:32:37
推荐回答(2个)
回答1:

CWnd::GetCurrentMessage static const MSG* PASCAL GetCurrentMessage( );Return ValueReturns a pointer to the MSG structure that contains the message the window is currently processing. Should only be called when in an OnMessage handler. 你应该是多个按钮共享Clicked事件的处理函数吧?调用下面语句获取当前响应ON_CLICKED消息的控件ID:WORD id=LOWORD(GetCurrentMessage()->wParam);

回答2:

ID = (int) LOWORD(wParam)