Solved

How to catch status bar click event

Posted on 2004-04-02
3
477 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 47
Strange date stored 22 100
how do i create updater to My Activex application? 3 74
mapAB Challlenge 35 89
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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. …
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.
This video discusses moving either the default database or any database to a new volume.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now