Go Premium for a chance to win a PS4. Enter to Win

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

Getting mouse move events in a derived CStatic control?

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
magnayn
Asked:
magnayn
  • 2
1 Solution
 
mbhaktaCommented:
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
 
RONSLOWCommented:
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
 
magnaynAuthor Commented:
Please send your e-mail and I will mail you whatever samples I have.
0
 
mbhaktaCommented:
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

Technology Partners: 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!

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