当前位置: 动力学知识库 > 问答 > 编程问答 >

No event getting generated on button click in MFC

问题描述:

I have a dialog based application. I have one static text control and a button on this, both of which I have made invisible in the beginning. I want to show both the controls on reaching a certain condition. When I click this button, again I want to make both the controls invisible.

However, I am able to show and hide the control and also captured the button click event like this:

ON_BN_CLICKED(IDC_MY_BUTTON, &MyDlg::OnBnClickedMyButton)

and defined OnBnClickedMyButton().

But when I press the button, it is not pressed and the event is also not generated.

Any suggestions?

网友答案:
  • First check if the IDC_MY_BUTTON exists and is valid.
  • Remember to add DECLARE_MESSAGE_MAP() at the header file.
  • Also check at the BEGIN_MESSAGE_MAP(MyClass,MyParentClass) if the class and the parent class you write are right.

I hope this helps.

网友答案:

I think the IDC_MY_BUTTON maybe is invalid or other control has the same ID.

网友答案:

Well, finally I have come to know that though the button was visible but on clicking it was not taking control, hence I used BringWindowToTop() to draw it on top. Now it is being clicked and OnBnClickedMyButton() is also being called.

But now the issue is that after calling BringWindowToTop() the button is not shown. It is shown only when I take the mouse pointer on it. Not able to understand what is the issue.

分享给朋友:
您可能感兴趣的文章:
随机阅读: