Thursday, April 15, 2004

Windows Form Handle Changing

I wrote an application recently that installs a Windows Form as an application bar with the Windows shell.  It was working all right until the client asked for some functionality that would minimize it to an icon.  At that point all hell broke loose.  It appeared after doing some tracing in the WndProc that at a certain point in time the window receives a WM_DESTROY and then at some point a WM_CREATE.  This was weird since I wasn't really ever destroying the window.  Took me a good day to figure out that when I was minimizing I was also doing a this.ShowInTaskBar=true;  Then when restoring I was doing a this.ShowInTaskBar=false;  Guess what?  This property essentially changes the WS_EX_APPWINDOW extended window style and to do this it creates and destroys the window!  This was wreaking havoc with my registration with the shell.

A side effect of this is that when it happens OnHandleCreated() and OnHandleDestroyed aren't called!  Seems totally counterintuitive since a handle was just destroyed and recreated.  The only way I could figure to track this was to wait for the WM_CREATE message in the WndProc.

Footnote: Some have asked what an application bar is.  It is something very similar to the windows taskbar yet application specific.

Thursday, April 15, 2004 12:26:01 PM (Pacific Standard Time, UTC-08:00)   #      Comments [1]  
 


Administration
Sign In