?
Solved

Can't get mouse input for CStatic in Dialog

Posted on 2003-11-26
5
Medium Priority
?
349 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
[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
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 500 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month11 days, 18 hours left to enroll

752 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