thinman
August 15th, 2001, 03:00 PM
Hi all
Why Form never gets WM_CLOSE message? Why when I subclass a Form it crashes my VB IDE if I close that window and I don't set form's window procedure back to the original one before closing?
Thanks in advance!!
sotoasty
August 15th, 2001, 03:26 PM
I'm not sure why a form would never get a WM_CLOSE message, however I suspect that it has something to do with your subclassing. As for why the VB IDE crashes whenever you close your window, this is definately caused by the subclassing. I suspect you might need to modify you Subclassing procedure just a bit. Basically, here is what is happening. When you subclass a window, ALL messages to that window are passed to you WindowProc routine instead of being sent to your window. If you use the CallWindowProc function at the end of your WindowProc routine, then your window will receive those messages (I suspect this might be why you are not getting the WM_CLOSE message). If you don't un-subclass then window before it gets closed, Windows will try to keep sending messages to you WindowProc routine, and since it is no longer in memory, this is why your VB IDE crashes. Here are a few general rules for sublcassing that have really helped me out.
1. When In the VB IDE, NEVER EVER hit the stop button, this will always cause the IDE to crash when you have a window subclassed.
2. In your code, NEVER use the END statement. Same reason as above.
3. Make sure that before the window you have subclassed is destroyed, that you un-subclass the window. If not, VB IDE CRASH.
4. Always call the "CallWindowProc" function at the end of your WindowProc, unless there is a very specific reason you don't want to pass a particular message onto the subclassed window.
Hope this helps you and if you need some more help, post some of your code and I will try to help you out.
thinman
August 18th, 2001, 11:05 AM
Thanks for answering! I used Spy++ program, and Forms do not get WM_CLOSE message neither do they recieve WM_DRAWITEM and WM_MEASUREITEM message. I'm not able to find a solution for neither of these messages.
thinman
thinman
August 18th, 2001, 11:09 AM
Hi again!
It is my opinion, that messages WM_CLOSE and WM_DRAWITEM... are processed internaliy by visual basis in his message pump!
Thanks, thinman