Solved

Left mouse button up over a CStatic control

Posted on 1997-11-25
4
517 Views
Last Modified: 2013-11-20
I have a CStatic control (precisely an icon) in a CFormView and I'd like to perform some tasks when the user release the left mouse button over that icon.
I tried putting
ON_NOTIFY(WM_LBUTTONUP, IDC_STATIC, OnMouse Release)
in my CFormView code and implementing my tasks in a function called OnMouseRelease, but nothing happened.
Many thanks in advance!

vencese
0
Comment
Question by:vencese
[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
  • 3
4 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 170 total points
ID: 1310822
Did you apply the SS_NOTIFY style to the CStatic control?
0
 
LVL 23

Expert Comment

by:chensu
ID: 1310823
When a static control receives WM_LBUTTONDOWN message, it sends the parent window an STN_CLICKED notification message if the control style is SS_NOTIFY. When WM_LBUTTONDBLCLK, it sends the parent window an STN_DBLCLK notification message if the control style is SS_NOTIFY. For WM_LBUTTONUP, it does not send a notification message. Therefore, subclass the static control and override CStatic::OnLButtonUp().
 
0
 

Author Comment

by:vencese
ID: 1310824
The left button up has to perform the deleting of selected items in a CListBox contained in the same CFormView. If I subclass the static control and override CStatic::OnLButtonUp I can't get a pointer to MyFormView in order to handle the CListBox items ...
... (I tried to include MyFormView.h, but I got an error in CMyDoc *GetDocument ...!)
I hope you can help me!

Many thanks for your time!!

vencese

0
 
LVL 23

Expert Comment

by:chensu
ID: 1310825
The better way to do it is to send a message to MyFormView instead of handling it directly. Define your own message (WM_MYMESSAGE), in the overriden CStatic::OnLButtonUp(),

CWnd *pWndParent = this->GetParent();
if (pWndParent != NULL)
    pWndParent->PostMessage(WM_MYMESSAGE);

When MyFormView receives the message, delete the selected items in the CListBox.
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

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…
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.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

691 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