Solved

How to catch status bar click event

Posted on 2004-04-02
3
501 Views
Last Modified: 2013-11-20
I need to minimize the program on status bar click event in MFC.
How do I do that?
0
Comment
Question by:jd9288
  • 2
3 Comments
 
LVL 30

Accepted Solution

by:
SteveGTR earned 500 total points
ID: 10741833
Do this:

Override the PreTranslateMessage using the MFC Classwizard for your CMainFrame class (MAINFRM.CPP). Code the handler as follows:

BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
  if (pMsg->message == WM_LBUTTONDOWN)
    {
    CRect rect;
    CPoint point((DWORD)pMsg->lParam);

    m_wndStatusBar.GetClientRect(rect);

    if (rect.PtInRect(point))
      ActivateFrame(SW_MINIMIZE);
    }
      
  return CMDIFrameWnd::PreTranslateMessage(pMsg);
}

This code assumes that the application is MDI. Change the return statement to call your base classes PreTranslateMessage() function.

Good Luck,
Steve
0
 

Author Comment

by:jd9288
ID: 10758544
Actually, this doesn't work. Or, rather, it works if you click on ANY button or drop-down list, not just on
the status bar. Any ideas?
0
 
LVL 30

Expert Comment

by:SteveGTR
ID: 10759311
Try this:

BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
  if (pMsg->message == WM_LBUTTONDOWN && pMsg->hwnd == m_wndStatusBar.m_hWnd)
    ActivateFrame(SW_MINIMIZE);
     
  return CMDIFrameWnd::PreTranslateMessage(pMsg);
}

Good Luck,
Steve
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

776 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