假设我有一个CDialog,当用户点击按钮时动态创建控件。它可能像这样:
// We don't know which is the first id for the new buttons until runtime (!)
MyDialog::MyDialog(/*whatever parameters needed*/, first_id)
: next_id_(first_id)
{ /*...*/ }
BOOL MyDialog::OnSomeButtonClicked()
{
CButton* new_button = new CButton;
new_button->Create("Caption", WS_CHILD | WS_VISIBLE, this->new_button_rect_,
this, this->next_id_++);
}
我的问题是:我该如何处理来自这个按钮的消息?是否可以使用MFC消息映射功能?
解决方案应该适用于vs6和vs2005。
谢谢!