WM_QueryEndSession use WndProc not DefWndProc

Published 10 August 5 8:59 PM | Ramon Smits

Well this could become the most emberrasing thing this month I think. I added a handler for the WM_QUERYENDSESSION message. I override the DefWndProc method and the WM_QUERYENDSESSION message was never received. I thought it had something to do with the window not being the top window so I tried to hunt down the 'evil' code. The problem was there wasn't bad code at all.

After a few hours and removing/commenting out code the only executing code remaining was my message loop override and I still was amazed that I didn't get the WM_QUERYENDSESSION message. So I decided to create a new test project and added an override for WndProc and all worked as it should. Then I compared both source files and *finally* saw that I had overriden DefWndProc. I really don't know why I did that.. I think it is because I used intellisense, scrolled down and when I read DefWndProc I just smashed the tab key.

So watch out that you override WndProc and not DefWndProc when intercepting system messages!

Please leave a comment that I'm a complete dickhead. Thank you!

Filed under: ,

Comments

# Elias said on August 11, 2005 11:57 PM:

DickHead!

# Manfred said on November 8, 2005 3:07 AM:

Grudingly I oblige,...

Your are a complete dickhead.

I do hope you feel better now :-)

# recall00 said on June 27, 2006 12:41 PM:

I am currently fighting this issue as I move some apps to vb.net.  Its enough to make anyone feel ***-headed.

as I am new, how can I see your code?

# Phil Winant said on April 13, 2007 9:52 AM:

Don't feel bad. I just did the EXACT SAME THING!!! I only found your website because I was trying to figure out what the difference between the two methods was. :-)