Solved

How to catch status bar click event

Posted on 2004-04-02
3
519 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
[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
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Host to IP 7 84
substring method in java 1 141
Window placement 17 99
Bartender label printing - switch on and off graphics 3 92
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…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.

738 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