65.9K
CodeProject is changing. Read more.
Home

Know When CDialogBar is Closed

starIconstarIconstarIconstarIconstarIcon

5.00/5 (2 votes)

Mar 24, 2016

CPOL
viewsIcon

10215

downloadIcon

99

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!