Solved

Left mouse button up over a CStatic control

Posted on 1997-11-25
4
500 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
  • 3
4 Comments
 
LVL 23

Accepted Solution

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

Expert Comment

by:chensu
Comment Utility
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
Comment Utility
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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

772 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

11 Experts available now in Live!

Get 1:1 Help Now