Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

CToolBar

Posted on 2000-03-08
5
Medium Priority
?
357 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 200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

971 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