[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 544
  • Last Modified:

Left mouse button up over a CStatic control

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
vencese
Asked:
vencese
  • 3
1 Solution
 
chensuCommented:
Did you apply the SS_NOTIFY style to the CStatic control?
0
 
chensuCommented:
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
 
venceseAuthor Commented:
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
 
chensuCommented:
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now