Click here to Skip to main content
15,881,588 members
Articles / Desktop Programming / MFC
Tip/Trick

Know When CDialogBar is Closed

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
23 Mar 2016CPOL 10K   96   3  
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:

C++
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:

C++
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Romania Romania
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --