Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Task Panel
  New Posts New Posts RSS Feed - Intercepting the mouse click
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Intercepting the mouse click

 Post Reply Post Reply
Author
Message
afekhar View Drop Down
Groupie
Groupie


Joined: 30 August 2006
Location: France
Status: Offline
Points: 43
Post Options Post Options   Thanks (0) Thanks(0)   Quote afekhar Quote  Post ReplyReply Direct Link To This Post Topic: Intercepting the mouse click
    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,

Thanks.
Back to Top
jfstephe View Drop Down
Newbie
Newbie


Joined: 07 July 2006
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote jfstephe Quote  Post ReplyReply Direct Link To This Post 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.
 
Back to Top
afekhar View Drop Down
Groupie
Groupie


Joined: 30 August 2006
Location: France
Status: Offline
Points: 43
Post Options Post Options   Thanks (0) Thanks(0)   Quote afekhar Quote  Post ReplyReply Direct Link To This Post 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 ?
Back to Top
jfstephe View Drop Down
Newbie
Newbie


Joined: 07 July 2006
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote jfstephe Quote  Post ReplyReply Direct Link To This Post 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);
}
Back to Top
afekhar View Drop Down
Groupie
Groupie


Joined: 30 August 2006
Location: France
Status: Offline
Points: 43
Post Options Post Options   Thanks (0) Thanks(0)   Quote afekhar Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
jfstephe View Drop Down
Newbie
Newbie


Joined: 07 July 2006
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote jfstephe Quote  Post ReplyReply Direct Link To This Post Posted: 27 September 2006 at 12:35pm
Hmm. That's a bit wierd.
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.
J
Back to Top
jfstephe View Drop Down
Newbie
Newbie


Joined: 07 July 2006
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote jfstephe Quote  Post ReplyReply Direct Link To This Post 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

BEGIN_EVENTSINK_MAP(CCodejockDlg, CDialog)
    //{{AFX_EVENTSINK_MAP(CCodejockDlg)
 ON_EVENT(CCodejockDlg, IDC_TASKPANEL1, 1 /* ItemClick */, OnItemClickTaskpanel1, VTS_DISPATCH)
 ON_EVENT(CCodejockDlg, IDC_TASKPANEL1, 6 /* GroupExpanded */, OnGroupExpandedTaskpanel1, VTS_DISPATCH)
 //}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
 
void CCodejockDlg::OnItemClickTaskpanel1(LPDISPATCH Item)
{
// handler
}
 
You could do this by hand but again it's easily done tthrough the class wizard.
Back to Top
afekhar View Drop Down
Groupie
Groupie


Joined: 30 August 2006
Location: France
Status: Offline
Points: 43
Post Options Post Options   Thanks (0) Thanks(0)   Quote afekhar Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

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

This page was generated in 0.156 seconds.