Solved

Can't get mouse input for CStatic in Dialog

Posted on 2003-11-26
5
339 Views
Last Modified: 2013-11-20
Hi!

I have a CFormView that uses a dialog template. Further I have an own class called "LinkLabel" that is derived from CStatic. I add instances of this class in the OnInitialUpdate() method of CFormView by calling the "Create" method of CStatic (my class is actually a simple label that owns another CStatic displaying a bitmap).

But when I try to get mouse input for my class with the OnLButtonDown-Handler, I do not get any feedback. The WM_LBUTTONDOWN message is obviously not sent to my control.

I thought I could get rid of this by overriding the OnGetDlgCode() method, but this method isn't called by the framework, too!

So what am I doing wrong here?
0
Comment
Question by:hirnsieb
5 Comments
 
LVL 13

Expert Comment

by:SteH
ID: 9824279
The only message I see in the class wizard for a CStatic is the BN_CLICKED. Would this be sufficient? If yes override that handler. Otherwise you need to convince the framework to send other messages to that control.
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 9824294
>> my class is actually a simple label that owns another CStatic displaying a bitmap.

Another CStatic gets WM_LBUTTONDOWN.
0
 
LVL 1

Author Comment

by:hirnsieb
ID: 9824400
Thanks for your suggestions.

@SteH: I think the BN_CLICKED handler refers to the owning dialog object, but I want to handle the mouse event in my CStatic derived class.

@AlexFM: it would be great if my other CStatic would get the message but in fact it doesn't. Maybe I am doing something wrong. What I do is:

1. derive a class from CStatic (called LinkLabel) and implement the OnLButtonDown handler
2. derive another class from CStatic (called LinkBitmap) and implement the OnLButtonDown handler, so I get the mouse message in any case
3. create LinkBitmap from within the "Create" method of LinkLabel (= LinkLabel is the parent)
4. add an instance of LinkLabel to my CFormView object (= CFormView is the parent)

As said before, I do not get any mouse messages in any of my two classes. But I should, shouldn't I? Or is there anything else to do, to receive those messages, i.e. create my class with special window styles, etc.?
0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 125 total points
ID: 9824406
In the reource editor set the 'notify' option to true (styles tab).  Now your static control will receive mouse messages and you can implement the handlers you require.
0
 
LVL 1

Author Comment

by:hirnsieb
ID: 9824438
@AndyAinscow: That's it! Thanx! I had to set the SS_NOTIFY style when creating my CStatic derived class.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Detect CR LF to each line 12 158
Prevent this page from creating additional dialogs. 3 507
isEverywhere  challenge 19 74
JQuery serialize and unserialize 8 77
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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…

813 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

10 Experts available now in Live!

Get 1:1 Help Now