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
Solved

Left mouse button up over a CStatic control

Posted on 1997-11-25
4
510 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
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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying 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

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 …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.

808 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