Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows API
  4. Getting DBLCLK Messages

Getting DBLCLK Messages

Scheduled Pinned Locked Moved Windows API
question
3 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Craig Longman
    wrote on last edited by
    #1

    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 the CS_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 and GWL_STYLE. But neither seemed to make any difference. Is the CS_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

    H 1 Reply Last reply
    0
    • C Craig Longman

      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 the CS_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 and GWL_STYLE. But neither seemed to make any difference. Is the CS_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

      H Offline
      H Offline
      Hosam Ershedat
      wrote on last edited by
      #2

      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 runtime

      SetClassLongPtr(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
      );

      C 1 Reply Last reply
      0
      • H Hosam Ershedat

        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 runtime

        SetClassLongPtr(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
        );

        C Offline
        C Offline
        Craig Longman
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups