Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dialog F1 help gives two method calls per press

Status
Not open for further replies.

lardyboy

Technical User
Apr 19, 2004
19
0
0
GB
I am learning MS Visual C#.net (2003), converting from MS (MFC) C++.

I have a single dialog application where I have double clicked on the dialog box HelpRequested property entry to get an application_HelpRequested method. This is called by pressing F1. I then display a message box [ MessageBox.Show(…) ]. This all works as expected. My problem is that I seem to get two message boxes. Specifically when I OK one, another appears. If I move the first one there isn’t another underneath it. The second one seems to appear only after the first one is closed.

I thought I could trap it by using a bool variable around the MessageBox.Show(…), setting a “homemade” visibility flag. If the method was being called a second time before the first one had completed only one box would have appeared. That didn’t work. It looks like the framework is making two method calls for one F1 push.

This is not the end of the world, but I hate programs doing what they want rather than what I want!

Any insights welcomed.
 
The missing line is:

hlpevent.Handled=true;

Apparently if you don't mark the event as handled it is dealt with by a parent class which then re-calls the child!

In short, problem solved.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top