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. C / C++ / MFC
  4. WM_LBUTTONDOWN not working with CListCtrl class!!

WM_LBUTTONDOWN not working with CListCtrl class!!

Scheduled Pinned Locked Moved C / C++ / MFC
c++visual-studiohelpquestion
22 Posts 3 Posters 0 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.
  • S SanjaySMK

    Sorry if I haven't answered your last question. The thing is, that subclassing is used in case of CListCtrl-derived class, the reason why I don't see its varible entries inside DoDataExchange, hence the problem. That means the requirement is that of making LBUTTONDOWN and LBUTTONDBLCLK work with subclassed windows of CListCtrl-derived class. Can you help me out with this? Thanks in advance.

    Software Developer Sanjay Khapre

    M Offline
    M Offline
    Mark Salsbery
    wrote on last edited by
    #13

    You have to add the entries to DoDataExchange if they are not there. If the listview controls are in the dialog resource, you can use the wizard to add a control variable. It will add an entry like DDX_Control(pDX, IDC_LIST1, m_ListCtrl); Change m_ListCtrl's type to your derived type in the header file. Then the control will be subclassed. From my previous working sample code:

    // In the dialog class
    CReflectedListCtrl m_ListCtrl;

    // The dialog class' DoDataExchange() override
    void CMyDialog::DoDataExchange(CDataExchange* pDX)
    {
    CDialog::DoDataExchange(pDX);
    DDX_Control(pDX, IDC_LIST1, m_ListCtrl);
    }

    Mark Salsbery Microsoft MVP - Visual C++ :java:

    modified on Wednesday, January 7, 2009 2:40 AM

    S 1 Reply Last reply
    0
    • M Mark Salsbery

      You have to add the entries to DoDataExchange if they are not there. If the listview controls are in the dialog resource, you can use the wizard to add a control variable. It will add an entry like DDX_Control(pDX, IDC_LIST1, m_ListCtrl); Change m_ListCtrl's type to your derived type in the header file. Then the control will be subclassed. From my previous working sample code:

      // In the dialog class
      CReflectedListCtrl m_ListCtrl;

      // The dialog class' DoDataExchange() override
      void CMyDialog::DoDataExchange(CDataExchange* pDX)
      {
      CDialog::DoDataExchange(pDX);
      DDX_Control(pDX, IDC_LIST1, m_ListCtrl);
      }

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      modified on Wednesday, January 7, 2009 2:40 AM

      S Offline
      S Offline
      SanjaySMK
      wrote on last edited by
      #14

      In which case CWnd::SubclassWindow(HWND DocumentList) fails? Even though, the variable HWND DocumentList which I am using as its parameter is locally declared and initialized where I am calling SubclassWindow, still SubclassWindow is failing(Debug Assertion Failure!). What is its remedy? Could u please suggest? DocumentList parameter is declared and initialized some lines before calling SubclassWindow, as following: HWND DocumentList = CreateDocumentList(parenthandle, rect.left, rect.top, rect.Width(), rect.Height(), someflag) ; Line 1 Line 2 Line 3 SubclassWindow(DocumentList) ; // which fails here, why?

      Software Developer Sanjay Khapre

      modified on Thursday, January 8, 2009 5:24 AM

      S M 2 Replies Last reply
      0
      • S SanjaySMK

        In which case CWnd::SubclassWindow(HWND DocumentList) fails? Even though, the variable HWND DocumentList which I am using as its parameter is locally declared and initialized where I am calling SubclassWindow, still SubclassWindow is failing(Debug Assertion Failure!). What is its remedy? Could u please suggest? DocumentList parameter is declared and initialized some lines before calling SubclassWindow, as following: HWND DocumentList = CreateDocumentList(parenthandle, rect.left, rect.top, rect.Width(), rect.Height(), someflag) ; Line 1 Line 2 Line 3 SubclassWindow(DocumentList) ; // which fails here, why?

        Software Developer Sanjay Khapre

        modified on Thursday, January 8, 2009 5:24 AM

        S Offline
        S Offline
        SanjaySMK
        wrote on last edited by
        #15

        I got the answer of why SubclassWindow was failing, it was because I had DDX_Control entries inside DoDataExchange function, which shouldn't be there, otherwise the parameter to SubclassWindow will always be attached to the parent dialog box, which doesn't fit its criterion. But now after that, the messages WM_LBUTTONDOWN and WM_LBUTTONDBLCLK should run, which are not running. That means my question is, after calling CWnd::SubclassWindow function, why these two messages do not respond at all?Please suggest some remedy.

        Software Developer Sanjay Khapre

        modified on Thursday, January 8, 2009 9:34 AM

        M 1 Reply Last reply
        0
        • S SanjaySMK

          I got the answer of why SubclassWindow was failing, it was because I had DDX_Control entries inside DoDataExchange function, which shouldn't be there, otherwise the parameter to SubclassWindow will always be attached to the parent dialog box, which doesn't fit its criterion. But now after that, the messages WM_LBUTTONDOWN and WM_LBUTTONDBLCLK should run, which are not running. That means my question is, after calling CWnd::SubclassWindow function, why these two messages do not respond at all?Please suggest some remedy.

          Software Developer Sanjay Khapre

          modified on Thursday, January 8, 2009 9:34 AM

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #16

          Why are you calling SubclassWindow? If you're using MFC you very rarely need to explicitly call it. Mark

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          1 Reply Last reply
          0
          • S SanjaySMK

            In which case CWnd::SubclassWindow(HWND DocumentList) fails? Even though, the variable HWND DocumentList which I am using as its parameter is locally declared and initialized where I am calling SubclassWindow, still SubclassWindow is failing(Debug Assertion Failure!). What is its remedy? Could u please suggest? DocumentList parameter is declared and initialized some lines before calling SubclassWindow, as following: HWND DocumentList = CreateDocumentList(parenthandle, rect.left, rect.top, rect.Width(), rect.Height(), someflag) ; Line 1 Line 2 Line 3 SubclassWindow(DocumentList) ; // which fails here, why?

            Software Developer Sanjay Khapre

            modified on Thursday, January 8, 2009 5:24 AM

            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #17

            Where is this code called from? You really need to provide a context. If SubclassWindow is the CWnd SubclassWindow method, then what's the class you are calling it from?

            SanjaySMK wrote:

            which fails here, why?

            Why don't you step into the function with the debugger and find out? :)

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            S 1 Reply Last reply
            0
            • M Mark Salsbery

              Where is this code called from? You really need to provide a context. If SubclassWindow is the CWnd SubclassWindow method, then what's the class you are calling it from?

              SanjaySMK wrote:

              which fails here, why?

              Why don't you step into the function with the debugger and find out? :)

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              S Offline
              S Offline
              SanjaySMK
              wrote on last edited by
              #18

              I have a method in CListCtrl-derived class, from where I am calling CWnd::SubclassWindow, and after calling that, WM_LBUTTONDOWN and WM_LBUTTONDBLCLK do not get called at all.

              Software Developer Sanjay Khapre

              M 1 Reply Last reply
              0
              • S SanjaySMK

                I have a method in CListCtrl-derived class, from where I am calling CWnd::SubclassWindow, and after calling that, WM_LBUTTONDOWN and WM_LBUTTONDBLCLK do not get called at all.

                Software Developer Sanjay Khapre

                M Offline
                M Offline
                Mark Salsbery
                wrote on last edited by
                #19

                You still haven't answered WHY you are calling SubclassWindow. Where do the CListCtrl derived objects come from? Show some code.

                Mark Salsbery Microsoft MVP - Visual C++ :java:

                S 1 Reply Last reply
                0
                • M Mark Salsbery

                  You still haven't answered WHY you are calling SubclassWindow. Where do the CListCtrl derived objects come from? Show some code.

                  Mark Salsbery Microsoft MVP - Visual C++ :java:

                  S Offline
                  S Offline
                  SanjaySMK
                  wrote on last edited by
                  #20

                  CListCtrl derived objects come from the parent class, i.e. the dialog class, I call one member function of CListCtrl-derived class, SubClassMyList, in which I am calling SubclassWindow(HWND) function, after which mouse events don't work on this derived class. Sorry, I was away for some days, hence couldn't update you quickly.

                  Software Developer Sanjay Khapre

                  M 1 Reply Last reply
                  0
                  • S SanjaySMK

                    CListCtrl derived objects come from the parent class, i.e. the dialog class, I call one member function of CListCtrl-derived class, SubClassMyList, in which I am calling SubclassWindow(HWND) function, after which mouse events don't work on this derived class. Sorry, I was away for some days, hence couldn't update you quickly.

                    Software Developer Sanjay Khapre

                    M Offline
                    M Offline
                    Mark Salsbery
                    wrote on last edited by
                    #21

                    SanjaySMK wrote:

                    in which I am calling SubclassWindow(HWND) function

                    I don't know how many times I've asked why... All my MFC controls for the past decade have got mouse messages just fine without calling subclassWindow...

                    Mark Salsbery Microsoft MVP - Visual C++ :java:

                    S 1 Reply Last reply
                    0
                    • M Mark Salsbery

                      SanjaySMK wrote:

                      in which I am calling SubclassWindow(HWND) function

                      I don't know how many times I've asked why... All my MFC controls for the past decade have got mouse messages just fine without calling subclassWindow...

                      Mark Salsbery Microsoft MVP - Visual C++ :java:

                      S Offline
                      S Offline
                      SanjaySMK
                      wrote on last edited by
                      #22

                      Dear Mark, First of all, I am very sorry if I have tested your patience, although unknowingly and unintentionally. I have some big code of my project, which was running fine in Visual C++ 6.0(in which it was first written), but which I now needed to convert to Visual C++ 2005. After everything I have explained till date, since the functionality(mouse events) after conversion is not running in VC 2005, I created my own MFC application in VC 2005, in which, like the project code, I tried using CWnd's SubclassWindow(HWND). Since this functionality was running in VC 6.0, I need to keep and also make it run in VC 2005. Hence the inclusion of SubclassWindow also in my code(the sample application which I am trying these things in). I hope I am very much clear this time. Could you please help?

                      Software Developer Sanjay Khapre

                      modified on Friday, January 16, 2009 12:45 AM

                      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