Solved

Getting mouse move events in a derived CStatic control?

Posted on 1997-05-12
4
707 Views
Last Modified: 2013-11-20
Hello people:

I am writing something that I want to look like the colour selector in the windows NT(95) control panel - you know the one, a button with a colour on, and when you click on it, a little dialog drops down, allowing you to select the colour you want.

I have the button working (Owner Draw CButton), but the dialog is giving some problems. By examining desk.cpl in NT, I see the dialog uses an owner-draw text (CStatic) control. Fine, I thought, I'll just do the same.

My problem is that I need to trap mouse-clicks and mouse-moves. Clicks don't seem to get through (unlike CButton controls), and neither CButton nor CStatic send through mousemoves. I need these to highlight the colour and to select the colour, in the same way they do it in Control Panel.

Spy++ shows that the control gets WM_NCIHITTEST messages, but trapping OnNcHittest() doesn't ever seem to get called.

Help! - Am I doing something wrong / do MS do something Mystic to get this to work? I *really* don't want to go through the hassle of creating a custom control for this...

// Nigel
0
Comment
Question by:magnayn
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
mbhakta earned 70 total points
ID: 1301471
What is the ID of your static control. If it is IDC_STATIC (predefined = -1) then change it to some othe value IDC_XYZ = 3000 or something. The Static control should get WM_MOUSExxx messages like any other window.

Also, how are you attaching your control to the derived class ? I suggest using SubclassDlgItem().

If you still have trouble, reply back I might send you some sample.
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1301472
Yes, I want to trap mouse moves..I have found some example code that subclasses a CComboBox control, but I can't seem to apply it to anything more generic - I've tried making my colour control a CWnd, then subclassing that into the dialog control and it seems to half work.Example code would be appreciated..
0
 

Author Comment

by:magnayn
ID: 1301473
Please send your e-mail and I will mail you whatever samples I have.
0
 
LVL 4

Expert Comment

by:mbhakta
ID: 1301474
It's okay, I've solved it a different way. I created a
static, then moved a CWnd generated at runtime over the top
of it.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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: 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 I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

920 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

15 Experts available now in Live!

Get 1:1 Help Now