Solved

CToolBar

Posted on 2000-03-08
5
349 Views
Last Modified: 2013-11-20
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?

0
Comment
Question by:leowlf
5 Comments
 
LVL 4

Expert Comment

by:inpras
ID: 2599108
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
0
 

Author Comment

by:leowlf
ID: 2599405
It doesn't work.  

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

0
 
LVL 1

Accepted Solution

by:
nutsnuts earned 50 total points
ID: 2600937
Just implement the CMyToolBar as inpras has mentioned. But override the OnWindowPosChanged(WINDOWPOS FAR* lpwndpos) function. Write some codes like this:

      if (lpwndpos->flags & SWP_HIDEWINDOW)
      {
            //Here is your notification code;
      }

0
 
LVL 5

Expert Comment

by:vachooho
ID: 2602682
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
0
 

Author Comment

by:leowlf
ID: 2604049
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.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa‚Ķ
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question