Getting DBLCLK Messages
-
I have a dialog box, with a few sliders/trackbars on them. Some of them are going to be used to represent a +/- variance, so they'll start off in the middle, and go - to the left, + to the right. Everything fine so far. But what I want to be able to allow is to double click on the thumb-thingie and have the slider reset to it's middle or zero position. To that end, I've made a little subclassing class, in the ctor, I do the following:
ZSlider( HWND hParentWnd, int iItemID )
: hParentWnd_( hParentWnd )
,iItemID_( iItemID )
{
hWnd_ = ::GetDlgItem( hParentWnd_, iItemID_ );bValid\_ = ::SetWindowSubclass( hWnd\_, &ZSlider::StaticWndProc, (UINT\_PTR)WM\_APP\_SLIDER\_DBLCLK, (DWORD\_PTR)this );
}
...
static LRESULT CALLBACK StaticWndProc( HWND hWnd,
UINT uiMsg,
WPARAM wParam,
LPARAM lParam,
UINT_PTR puiID,
DWORD_PTR pdwRefData )
{
reinterpret_cast< ZSlider* >( pdwRefData )->WndProc( hWnd, uiMsg, wParam, lParam );return ::DefSubclassProc( hWnd, uiMsg, wParam, lParam );
}
This all seems to work great, I get the
WM_LMOUSEDOWN
messages, but I never receive a DBLCLK message. I think I'm passing the messages on fine, so I dug deeper and found that windows need to be created with theCS_DBLCLKS
style to receive the messages, so in the ctor I added:::SetWindowLong( hWnd\_, GWL\_EXSTYLE, ::GetWindowLong( hWnd\_, GWL\_EXSTYLE ) | CS\_DBLCLKS );
With both
GWL_EXSTYLE
andGWL_STYLE
. But neither seemed to make any difference. Is theCS_DBLCLKS
add-able at runtime, and if so, how? Or, am I not forwarding the messages properly so the DBLCLK just never gets registered? Or, in typical fashion, are these controls/windows just 'unique' and I'll need to implement some kind of custom double click handling. Any advice greatly appreciated. Thanks, CraigL -
I have a dialog box, with a few sliders/trackbars on them. Some of them are going to be used to represent a +/- variance, so they'll start off in the middle, and go - to the left, + to the right. Everything fine so far. But what I want to be able to allow is to double click on the thumb-thingie and have the slider reset to it's middle or zero position. To that end, I've made a little subclassing class, in the ctor, I do the following:
ZSlider( HWND hParentWnd, int iItemID )
: hParentWnd_( hParentWnd )
,iItemID_( iItemID )
{
hWnd_ = ::GetDlgItem( hParentWnd_, iItemID_ );bValid\_ = ::SetWindowSubclass( hWnd\_, &ZSlider::StaticWndProc, (UINT\_PTR)WM\_APP\_SLIDER\_DBLCLK, (DWORD\_PTR)this );
}
...
static LRESULT CALLBACK StaticWndProc( HWND hWnd,
UINT uiMsg,
WPARAM wParam,
LPARAM lParam,
UINT_PTR puiID,
DWORD_PTR pdwRefData )
{
reinterpret_cast< ZSlider* >( pdwRefData )->WndProc( hWnd, uiMsg, wParam, lParam );return ::DefSubclassProc( hWnd, uiMsg, wParam, lParam );
}
This all seems to work great, I get the
WM_LMOUSEDOWN
messages, but I never receive a DBLCLK message. I think I'm passing the messages on fine, so I dug deeper and found that windows need to be created with theCS_DBLCLKS
style to receive the messages, so in the ctor I added:::SetWindowLong( hWnd\_, GWL\_EXSTYLE, ::GetWindowLong( hWnd\_, GWL\_EXSTYLE ) | CS\_DBLCLKS );
With both
GWL_EXSTYLE
andGWL_STYLE
. But neither seemed to make any difference. Is theCS_DBLCLKS
add-able at runtime, and if so, how? Or, am I not forwarding the messages properly so the DBLCLK just never gets registered? Or, in typical fashion, are these controls/windows just 'unique' and I'll need to implement some kind of custom double click handling. Any advice greatly appreciated. Thanks, CraigLCS_DBLCLKS
cannot be added to window style it should be added to the class style use this method to change the class style on runtimeSetClassLongPtr(hWnd, // Handle to dialog
GCL_STYLE)//the style of class
GetClassLongPtr(hWnd,GCL_STYLE) | CS_DBLCLKS //get the old style and add the new flag to it
); -
CS_DBLCLKS
cannot be added to window style it should be added to the class style use this method to change the class style on runtimeSetClassLongPtr(hWnd, // Handle to dialog
GCL_STYLE)//the style of class
GetClassLongPtr(hWnd,GCL_STYLE) | CS_DBLCLKS //get the old style and add the new flag to it
);Ah... excellent, thank you. I will try that, even though I did end up emulating double click. I thought there was likely an issue with trying to set a CS_XXX when all the others seemed to be WS_XXX or WS_EX_XXX, but somehow never tracked down the
SetClassLongPtr
functions. Thanks, CraigL