|
From: Nick Schultz on 7 May 2008 17:13 This is an update to my previous thread "Dynamically creating CDockablePanes" What I want to do is to Create multiple CDockablePane(CDP) that will be destroyed when the user clicks the "X" Button. While it may seem trivial, I have ran into some hiccups When the CDP is docked, clicking the X will trigger an event that can be caught by DockablePane::OnPressCloseButton(). From there, I can then PostMessage(WM_CLOSE); and my CDP will be destroyed correctly The problem is that when you undock the CDP, MFC creates a MiniFrame and places your CDP inside it. Now when the user hits the "X", the OnPressCloseButton() does not get triggered, thus not destroying the CDP correctly, although it disappear and I lose it forever. The question is, how do I catch the event that the MiniFrame is sending when the "X" is pressed? Here are some things I have tried: 1) using spy++ i tried to find the events sent when I pushed the X. I found two, WM_FLOATSTATUS and WM_SHOWWINDOW. So I mapped a message handler within my CDP class that simply displays when showwindow gets sent and whether the param is true or false. When I click the X, I get output that showWindow was sent with a param of FALSE. So it seems like my work is done, HOWEVER, when the window is first created, there are three showWindow events: TRUE, FALSE, TRUE and whenever the user docks/undocks there are two showWindow events FALSE:TRUE. So that rules out wm_showwindow.. wm_floatstatus is the only other message that I found that might work, however it still doesnt look promising.. how do i get my CDP to capture that message? If that doesn't work, do you guys have any other ideas on how to tell when the user clicks the "X" on a floating miniframe containing a CDockablePane? Thanks in advance, Nick
From: Nick Schultz on 7 May 2008 17:57 Well it looks like I found a fix... Here is my message handler for WM_SHOWWINDOW. void CGrapher::OnShowWindow(BOOL bShow, UINT nStatus){ TRACE0("CLOSE PANE?\n"); if(!bShow && !this->IsWindowVisible()) TRACE0("------------------------CLOSED PANE!!!!\n"); } It seems when bShow is false and when the window is not visible, it is then safe to say that the window was "X"ed out. Watching the output window, I only got the closed pane message when I "X"ed the floating window after trying numerous other combinations just to make sure pushing the X is the only way this happens. While its not exactly what I wanted, I think this might suit me well. Nick "Nick Schultz" <nick.schultz(a)flir.com> wrote in message news:u5K1CdIsIHA.420(a)TK2MSFTNGP02.phx.gbl... > This is an update to my previous thread "Dynamically creating > CDockablePanes" > > What I want to do is to Create multiple CDockablePane(CDP) that will be > destroyed when the user clicks the "X" Button. While it may seem trivial, > I have ran into some hiccups > > When the CDP is docked, clicking the X will trigger an event that can be > caught by DockablePane::OnPressCloseButton(). From there, I can then > PostMessage(WM_CLOSE); and my CDP will be destroyed correctly > > > The problem is that when you undock the CDP, MFC creates a MiniFrame and > places your CDP inside it. Now when the user hits the "X", the > OnPressCloseButton() does not get triggered, thus not destroying the CDP > correctly, although it disappear and I lose it forever. The question is, > how do I catch the event that the MiniFrame is sending when the "X" is > pressed? Here are some things I have tried: > > 1) using spy++ i tried to find the events sent when I pushed the X. I > found two, WM_FLOATSTATUS and WM_SHOWWINDOW. > > So I mapped a message handler within my CDP class that simply displays > when showwindow gets sent and whether the param is true or false. When I > click the X, I get output that showWindow was sent with a param of FALSE. > So it seems like my work is done, HOWEVER, when the window is first > created, there are three showWindow events: TRUE, FALSE, TRUE and whenever > the user docks/undocks there are two showWindow events FALSE:TRUE. So > that rules out wm_showwindow.. > > wm_floatstatus is the only other message that I found that might work, > however it still doesnt look promising.. how do i get my CDP to capture > that message? > > > If that doesn't work, do you guys have any other ideas on how to tell when > the user clicks the "X" on a floating miniframe containing a > CDockablePane? > > Thanks in advance, > > Nick >
From: Nick Schultz on 7 May 2008 19:05 There is actually one scenario other than the desired one that will close the pane. It is when you have the CDP tabbed with another CDP, and then make it autohide. this is fixed by checking CDP::IsInFloatingMultiPaneFrameWnd() to make sure it is floating. void CGrapher::OnShowWindow(BOOL bShow, UINT nStatus){ if(!bShow && !IsWindowVisible() && IsInFloatingMultiPaneFrameWnd()) PostMessage(WM_CLOSE); } While this seems to be a clumsy way to go about this, it looks like its the only way to get this done. (although I am a MFC noob, which is why I would like to keep this discussion open ) Thanks, Nick "Nick Schultz" <nick.schultz(a)flir.com> wrote in message news:eVMLb1IsIHA.4848(a)TK2MSFTNGP05.phx.gbl... > Well it looks like I found a fix... > Here is my message handler for WM_SHOWWINDOW. > > > > void CGrapher::OnShowWindow(BOOL bShow, UINT nStatus){ > TRACE0("CLOSE PANE?\n"); > if(!bShow && !this->IsWindowVisible()) > TRACE0("------------------------CLOSED PANE!!!!\n"); > } > > It seems when bShow is false and when the window is not visible, it is > then safe to say that the window was "X"ed out. > > Watching the output window, I only got the closed pane message when I > "X"ed the floating window after trying numerous other combinations just to > make sure pushing the X is the only way this happens. > > > While its not exactly what I wanted, I think this might suit me well. > > Nick > > "Nick Schultz" <nick.schultz(a)flir.com> wrote in message > news:u5K1CdIsIHA.420(a)TK2MSFTNGP02.phx.gbl... >> This is an update to my previous thread "Dynamically creating >> CDockablePanes" >> >> What I want to do is to Create multiple CDockablePane(CDP) that will be >> destroyed when the user clicks the "X" Button. While it may seem >> trivial, I have ran into some hiccups >> >> When the CDP is docked, clicking the X will trigger an event that can be >> caught by DockablePane::OnPressCloseButton(). From there, I can then >> PostMessage(WM_CLOSE); and my CDP will be destroyed correctly >> >> >> The problem is that when you undock the CDP, MFC creates a MiniFrame and >> places your CDP inside it. Now when the user hits the "X", the >> OnPressCloseButton() does not get triggered, thus not destroying the CDP >> correctly, although it disappear and I lose it forever. The question is, >> how do I catch the event that the MiniFrame is sending when the "X" is >> pressed? Here are some things I have tried: >> >> 1) using spy++ i tried to find the events sent when I pushed the X. I >> found two, WM_FLOATSTATUS and WM_SHOWWINDOW. >> >> So I mapped a message handler within my CDP class that simply displays >> when showwindow gets sent and whether the param is true or false. When I >> click the X, I get output that showWindow was sent with a param of FALSE. >> So it seems like my work is done, HOWEVER, when the window is first >> created, there are three showWindow events: TRUE, FALSE, TRUE and >> whenever the user docks/undocks there are two showWindow events >> FALSE:TRUE. So that rules out wm_showwindow.. >> >> wm_floatstatus is the only other message that I found that might work, >> however it still doesnt look promising.. how do i get my CDP to capture >> that message? >> >> >> If that doesn't work, do you guys have any other ideas on how to tell >> when the user clicks the "X" on a floating miniframe containing a >> CDockablePane? >> >> Thanks in advance, >> >> Nick >> > >
|
Pages: 1 Prev: How do I delete a folder through code? Next: Static class member error |