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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subclassing : After MsgBox Display

Status
Not open for further replies.

jiqjaq

Programmer
Oct 10, 2002
180
0
0
US
I subclassed a window and displayed a MsgBox to warn the user when the X was used to close it, rather than the provided Close button. The problem is that the MsgBox only displays the first time this happens.

Subsequent times the message seems to be captured and ignored, just no MsgBox. What do I have to set/reset or call to get the MsgBox to display again. I've only been checking for the WM_Close message in the WindowProc routine.

Thanks.
 
hi jiqjaq,

It's difficult to determine what is wrong without actually seeing your implementation of the WindowProc but there's a couple general things you can check. The obvious one is what message is being sent on your subsequent calls to the WindowProc since you're only checking for WM_CLOSE. Secondly, since its common to "unsubclass" the window when closing, is there perhaps a code path which leads to this happening prior to your subsequent attempts at capturing this message?

I personally use a subclassing library from Monte Hansen which can be downloaded from his site at Its free, well-written, and perhaps the biggest advantage is it allows you to stop your application from within the IDE without crashing. This significantly improves your ability to troubleshoot problems like you're experiencing.

Also, I thought maybe I'd mention that if the only reason you're subclassing is to capture an "X" button click, you can check the parameter UnloadMode in the QueryUnload event for the form. If its a 0, then either the "X" button or the form's close menu was pressed.

Vince
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top