Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CToolBar

Posted on 2000-03-08
5
Medium Priority
?
356 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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…

715 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