Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Know When CDialogBar is Closed

0.00/5 (No votes)
24 Mar 2016 1  
A way to know when a floating CDialogBar is closed

Introduction

I saw several times that there are people who want to know when a CDialogBar is closed, but only the case when CDialogBar is in a floating state. I reveal below a simple method and illustrate it in a test application sample.

Using the Code

In order to accomplish this task, we only need to map ON_WM_WINDOWPOSCHANGED message, and write condition to know when dialog bar has been closed. See the below example:

class CMyDlgBar : public CDialogBar
{

........

 // Generated message map functions
 //{{AFX_MSG(CMyDlgBar)
 afx_msg void OnWindowPosChanged(WINDOWPOS FAR* lpwndpos);
 //}}AFX_MSG
 DECLARE_MESSAGE_MAP()
};

and implementation:

void CMyDlgBar::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos)
{
 CDialogBar::OnWindowPosChanged(lpwndpos);

 // TODO: Add your message handler code here

 if(SWP_HIDEWINDOW & lpwndpos->flags && SWP_NOREDRAW & lpwndpos->flags)
  TRACE("The dialogbar has been closed\n");
}

You can find more details in the sample project file. I hope it helps!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here