Solved

Detecting CListBox (Mouse) events

Posted on 2001-07-19
5
447 Views
Last Modified: 2013-11-20
Hi,

I have a CListbox on a property page, which I converted
to a draglistbox by overriding the member variable so
that its a CDragListBox type. When you double click on
an item in the listbox a dialog box appears, different
one each time depending on the item selected. I called
the listbox class CMyListBox.

Then to use the CDragListBox member functions, e.g.,
Dropped() I subclassed CMyListBox to CDragList. I then
added in the Dropped() function in CDragList, which
works fine. But now when I double click on an entry in
my listbox it goes straight into the Dropped() function
and the dialog box associated with the entry in the
listbox doesn't appear. I assume this is because when
you double click on an item in the listbox, after
the first click is detected it goes into Dropped(), so
the second click is never registered and OnDblClk() in
CMyListBox is never called.

How can I make my application distinguish between a
single click (when perform drag and drop) and a double
click when wanting to display the associated dialog box.

I tried to put in a call in the Dropped() function in
my subclass to OnDblClk() in CMyListBox? like  

void CDragList::Dropped()
{
  // Do some stuff

  CMyListBox::OnDblClk();
}


but it failed, said that I couldn't call a protected
member function. Whats the right way to do this?


FlipFlop


0
Comment
Question by:FlipFlop
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 6297394
goto your CListBox derived class and remove the message handler OnDblClk from protected to the public. thats all.
0
 

Author Comment

by:FlipFlop
ID: 6297510
Hi,

I've tried that before and it didn't work.  Maybe I'm not
doing it right.  Heres what I tried, in file CMyListBox.h

######################################################
class CMyListBox : public CPropertyPage
{
     DECLARE_DYNCREATE(CMyListBox)
private:

// Construction
public:
     CMyListBox ();
     ~CMyListBox ();

// Dialog Data
     //{{AFX_DATA(CMyListBox )
     enum { IDD = IDD_MYLIST };
     CDragList     m_pMyList;
     //}}AFX_DATA


// Overrides
     // ClassWizard generate virtual function overrides
     //{{AFX_VIRTUAL(CMyListBox )
     public:
     void OnDblclk();
     protected:
     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
     //}}AFX_VIRTUAL

// Implementation
protected:
     // Generated message map functions
     //{{AFX_MSG(CMyListBox)
     virtual BOOL OnInitDialog();
     //}}AFX_MSG
     DECLARE_MESSAGE_MAP()

};
######################################################

When I compile I get the same error message.

DragList.cpp(64) : error C2352: 'CMyListBox::OnDblclk' : illegal call of non-static member function



Confused, FlipFlop

0
 
LVL 42

Accepted Solution

by:
sedgwick earned 50 total points
ID: 6297904
to call your OnDblClick of the CMyListBox u should use your instance, the way u used here is to call static functions.

CMyListBox listbox;
listbox.OnDblclk();

now its gonna work.

0
 

Author Comment

by:FlipFlop
ID: 6299169
Hi Sedgwick,

Yep its working!  Thanks for that.  I've accepted your
answer but as an end note I wonder if you could explain
it.  When you do a

CMyListBox listbox;

I would have expected another listbox to be instantiated,
how is it that it controls my existing listbox?

Cheers, FlipFlop
0
 

Author Comment

by:FlipFlop
ID: 6299177
Hi Sedgwick,

Yep its working!  Thanks for that.  I've accepted your
answer but as an end note I wonder if you could explain
it.  When you do a

CMyListBox listbox;

I would have expected another listbox to be instantiated,
how is it that it controls my existing listbox?

Cheers, FlipFlop
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Looking for a specific application/software 2 124
noX challenge 17 144
firstChar challenge 13 148
listing all the respondents to a twitter feed - Java 5 44
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question