|
-
September 3rd, 2009, 05:54 PM
#1
An override method to release wm_mousewheel message from cslider control
Hello beautifull goys !
the mouse message WM_MOUSEWHEEL is strongly linked with the slider movement.
In order to release the mouse message WM_MOUSEWHEEL from the CSlider control I tryed the following solution (overriding):
1) I make a CSliderCtrl derived class (CMySliderCtrl) and add member variable and function :
private:
bool m_allowMouseActivation;
//
public:
void SetMouseActivation(bool activate);
2) initialized the variable in the constructor
CMySliderCtrl::CMySliderCtrl()
{
m_allowMouseActivation = true;
}
3) in the derived class I overrided the message WM_MOUSEWHEEL :
BOOL CMySliderCtrl::OnMouseWheel(UINT nFlags, short zDelta, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if (m_allowMouseActivation)
CSliderCtrl::OnMouseWheel(nFlags, zDelta, point);
}
4) code for function to change mouse activation
void CMySliderCtrl::SetMouseActivation(bool activate)
{
m_allowMouseActivation = activate;
}
5) then to set the mouse activation, , I added lines like this in CMyProgramDlg:
BOOL CMyProgramDlg::OnMouseWheel(UINT nFlags, short zDelta, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_slider.SetMouseActivation(false);
CSliderCtrl::OnMouseWheel(nFlags, zDelta, point);
}
QUESTION : why this way to overriding the message doesn't work ?
Please can you help me in find the error ?
Thank very much
-
September 4th, 2009, 07:50 AM
#2
Re: An override method to release wm_mousewheel message from cslider control
WM_MOUSEWHEEL is a windows message. If you handle it yourself, you need to tell the windows default handler that you took care of it and it doesn't need to bother. You do this by returning TRUE from the handler. I don't see that in your handler which is odd because the defaults for the compiler should error out if you have a function declared to return a value and don't do so.
Code:
BOOL CMySliderCtrl::OnMouseWheel(UINT nFlags, short zDelta, CPoint point)
{
if (m_allowMouseActivation){
return CSliderCtrl::OnMouseWheel(nFlags, zDelta, point);
}
return TRUE;
}
-
September 4th, 2009, 09:07 AM
#3
Re: An override method to release wm_mousewheel message from cslider control
Hi !
thanks for this reply ...
i can be more precise ... i compile the program without errors ... and it runs also ...
however the problem is another and precisely the fact that the MouseWheel function declared in the derived class CMySliderCtrl doesn't called after the mousewheel event ... the program calls the MouseWheel function declared in the CMyProgramDlg.
This is very strange for me ... and i don't understand why
thanks very much
-
September 4th, 2009, 09:15 AM
#4
Re: An override method to release wm_mousewheel message from cslider control
I try to be more detailed.
In CMyProgramDlg i have declared the MOUSEWHEEL message (from wizard) and fill the function MouseWheel with these lines
BOOL CMyProgramDlg::OnMouseWheel(UINT nFlags, short zDelta, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_slider.SetMouseActivation(false);
CSliderCtrl::OnMouseWheel(nFlags, zDelta, point);
}
After that i Ihave created the derived class as explained in the previous post.
PROBLEM : the MouseWheel function in the derived class, maked to override the original ones declared in CMyProgramDlg, is not called after the whhel event of the mouse .... instead is called the MouseWheel function of the CMyProgramDlg
Best Regards
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|