Link to home
Start Free TrialLog in
Avatar of leowlf
leowlf

asked on

CToolBar

VC6.0

I have a floating CToolbar in the CMainframe.  When the user closes the toolbar using the toolbar's [X] button, does the toolbar notifies the parent mainframe?

If yes, how do i catch this notification message?

If no, what should i do so that my Mainframe is aware that the toolbar has been closed by the user?

Avatar of inpras
inpras

Hi
Create UR own class say CMyToolBar
derive it from CToolBar
then chenge UR initial tool bar object to the type of CMyToolBar
Map WM_CLOSE of CMyToolBar U will get the notification
Hope this helps
Avatar of leowlf

ASKER

It doesn't work.  

The CMyToolBar::OnClose() wasn't called when the user closes the CMyToolBar using the toolbar's [x] button.

ASKER CERTIFIED SOLUTION
Avatar of nutsnuts
nutsnuts

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Do as inpras suggested
but map WM_SYSCOMMAND message
in the sys command handler add the following lines

void CMyToolBar::OnSysCommand(UINT nID, LPARAM lParam)
{
      if ((nID/* & 0xFFF0*/) == SC_CLOSE)
      {
// your toolbar is being closed
// notify parent
// say
GetParent()->PostMessage(WM_COMMAND, ID_TOOLBARCLOSING);
      }
      else
      {
            CToolBar::OnSysCommand(nID, lParam);
      }
}

and be sure you have changed
CToolBar m_wndToolBar;
to
CMyToolBar m_wndToolBar;

in your CMainFrame cpp file

Hope this helps
Avatar of leowlf

ASKER

NutsNuts's answer works.

vachooho's suggestion of using WM_SYSCOMMAND doesn't works in my application.  The void CMyToolBar::OnSysCommand(UINT nID, LPARAM lParam) is never called.

Thank you guys.