In JS.h, I have
//{{AFX_MSG(JS)
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
//}}AFX_MSG
and in JS.cpp, I have
BEGIN_MESSAGE_MAP(JS, CButton)
//{{AFX_MSG_MAP(JS)
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
The callback function is defined as this:
void JS::OnMouseMove(UINT nFlags, CPoint point)
{
SetWindowText("move");
return;
}
The JS element gets created from the CDialog object like this:
js->Create("Joystick", WS_CHILD|WS_VISIBLE|BS_NOTIFY, CRect(px,py, 0,
0), this, 0);
Am I missing something here?
I believe the BS_GROUPBOX returns HTTRANSPARENT in response to WM_NCHITTEST.
--
Jeff Partch
>I have a CDialog with a custom control JS in it that inherits from
> CButton. (It's a groupbox button with some other child controls in
> it). I'd like to catch the WM_MOUSEMOVE event for this control.
> However, nothing happens when the mouse moves over the control.
Two possibilities:
1. The controls within your group box are probably higher in the z-order
(after it in the tab order). If the mouse moves over them, then they will
be getting the WM_MOUSEMOVE
2. It may be worth calling InvalidateRect( NULL ) after the
SetWindowText() - I can never remember if this is necessary, but it probably
doesn't do any harm.
(If this *is* the problem and it causes flicker, then you can always
GetWindowText and only change it if it is necessary.)
Dave
--
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mozartists/mailinglist.htm
I have also tried catching the message with a PreTranslateMessage
function:
BOOL JS::PreTranslateMessage(MSG* pMsg)
{
switch(pMsg->message) {
case WM_MOUSEMOVE:
this->OnMouseMove(pMsg->wParam, pMsg->pt);
break;
}
return CButton::PreTranslateMessage(pMsg);
}
Then, OnMouseMove gets called when the mouse is over one of the sub-
buttons of the control, but not when it is elsewhere within the JS
groupbox. Why?
I tried calling this->BringWindowToTop() in the object's Create
method, which I guess should bring it to the topmost z-order. That
didn't change anything.
> 2. It may be worth calling InvalidateRect( NULL ) after the
> SetWindowText() - I can never remember if this is necessary, but it probably
> doesn't do any harm.
That didn't do anything either.
Thanks for your suggestions.
Does that mean that it's simply impossible to catch mouse movements in
a CButton-derived class with the BS_GROUPBOX style?
OK, I think I've got it now. I added an OnNcHitTest method using
ClassWizard, and there I return HTCLIENT. Now I can catch mouse
movements within the whole control.
Thank you very much.