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?
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?
ASKER
It doesn't work.
The CMyToolBar::OnClose() wasn't called when the user closes the CMyToolBar using the toolbar's [x] button.
The CMyToolBar::OnClose() wasn't called when the user closes the CMyToolBar using the toolbar's [x] button.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Do as inpras suggested
but map WM_SYSCOMMAND message
in the sys command handler add the following lines
void CMyToolBar::OnSysCommand(U INT nID, LPARAM lParam)
{
if ((nID/* & 0xFFF0*/) == SC_CLOSE)
{
// your toolbar is being closed
// notify parent
// say
GetParent()->PostMessage(W M_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
but map WM_SYSCOMMAND message
in the sys command handler add the following lines
void CMyToolBar::OnSysCommand(U
{
if ((nID/* & 0xFFF0*/) == SC_CLOSE)
{
// your toolbar is being closed
// notify parent
// say
GetParent()->PostMessage(W
}
else
{
CToolBar::OnSysCommand(nID
}
}
and be sure you have changed
CToolBar m_wndToolBar;
to
CMyToolBar m_wndToolBar;
in your CMainFrame cpp file
Hope this helps
ASKER
NutsNuts's answer works.
vachooho's suggestion of using WM_SYSCOMMAND doesn't works in my application. The void CMyToolBar::OnSysCommand(U INT nID, LPARAM lParam) is never called.
Thank you guys.
vachooho's suggestion of using WM_SYSCOMMAND doesn't works in my application. The void CMyToolBar::OnSysCommand(U
Thank you guys.
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