Print Page | Close Window

Intercepting the mouse click

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Task Panel
Forum Description: Topics Related to Codejock Task Panel
Printed Date: 21 July 2024 at 12:28pm
Software Version: Web Wiz Forums 12.04 -

Topic: Intercepting the mouse click
Posted By: afekhar
Subject: Intercepting the mouse click
Date Posted: 25 September 2006 at 9:20am
How can I intercept the left mouse click on a TaskPanelGroup header?

Any tip will be greatly appreciated,


Posted By: jfstephe
Date Posted: 27 September 2006 at 11:50am

This will work for VC++:

If you derive a class from CTaskPanel you can capture the messages it sees. Try to react to the click event by implementing  the appropriate message handler, if that doesn't work, override PreTranslateMessage and get the click event that way.

Posted By: afekhar
Date Posted: 27 September 2006 at 11:59am
Thanks alot, but I use the ActiveX version. Don't you know if i can wrap the activex with a window class or something ?

Posted By: jfstephe
Date Posted: 27 September 2006 at 12:08pm
Yeah, it shouldn't be a problem, that's what I'm using.
The easiest way to do it is:
Associate a member variable to your activeX object via ClassWizard. It'll say that it need to generate the TaskPanel wrapper classes for you - change the name/location of these as you see fit.
You now have a member variable to play with and it's of type CTaskPanel.
Add a new generic MFC class derived from CWnd (CMyTaskPanel). ('Insert' -> 'New Class')
Change the base class of CMyTaskPanel from CWnd to CTaskPanel.
The job should indeed now be a good one :-).
Right click on your class in 'ClassView' and add a windows message handler for the message you want.
Like I said, if this doesn't seem to catch the message you can override PreTranslateMessage in CMyTaskPanel e.g.

BOOL CMyTaskPanel ::PreTranslateMessage( MSG* pMsg )
  if (pMsg->message == WM_KEYDOWN)
    // I've caught a key press
  return CTaskPanel::PreTranslateMessage(pMsg);

Posted By: afekhar
Date Posted: 27 September 2006 at 12:25pm
Just one tip and it will be ok, I tried to put the taskpanel activex on a dialog (in the resource view) in order to use the classwizard and create a wrapper class, but the problem is that VStudio refuse that by displaying a message "This activex can't be instantiated". Is there another means to create a wrapper class ?

Thank you very much for your help.

Posted By: jfstephe
Date Posted: 27 September 2006 at 12:35pm
Hmm. That's a bit wierd.
Check out -
and make sure the activeX object is registered.  Perhaps this is license file related (again see the link).
Are you using VS6 or 7?
I take it you inserted the activex control by right clicking on the dialog selecting 'Insert ActiveX Control...' and selecting the control from the dialog?
If you did all that then I think something is knackered. Sorry. I would suggest sorting out your activex instantiated object problem before continuing.

Posted By: jfstephe
Date Posted: 27 September 2006 at 2:25pm
You can also subscribe to the event that are raised. E.g.
in .h
afx_msg void OnItemClickTaskpanel1(LPDISPATCH Item);
afx_msg void OnGroupExpandedTaskpanel1(LPDISPATCH Group);
in .cpp

 ON_EVENT(CCodejockDlg, IDC_TASKPANEL1, 1 /* ItemClick */, OnItemClickTaskpanel1, VTS_DISPATCH)
 ON_EVENT(CCodejockDlg, IDC_TASKPANEL1, 6 /* GroupExpanded */, OnGroupExpandedTaskpanel1, VTS_DISPATCH)
void CCodejockDlg::OnItemClickTaskpanel1(LPDISPATCH Item)
// handler
You could do this by hand but again it's easily done tthrough the class wizard.

Posted By: afekhar
Date Posted: 28 September 2006 at 5:19am
Thanks alot for all your advices. I want to intercept the click on a panel group (not item) and the click events sent by the control are for panel items only. I'll try to create a wrapper class as you suggested.

Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 -
Copyright ©2001-2021 Web Wiz Ltd. -