Solved

Can't get mouse input for CStatic in Dialog

Posted on 2003-11-26
5
333 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

746 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