Solved

Left mouse button up over a CStatic control

Posted on 1997-11-25
4
515 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

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
Turn a spreadsheet into a vba executable. 2 103
How to know only "File created" with EventLog 3 35
while loop over for loop 7 119
withoutTen challenge 14 140
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. …
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…
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.

739 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