Getting events from an ActiveX control not in a dialog box 
Author Message
 Getting events from an ActiveX control not in a dialog box

I would like to know how to get the ActiveX control I am using to tell me
when things happen.  The problem is that I took care of creating the control
myself, rather than using a dialog box or form view resource editor.  I have
a CView derived class, CFlexView.  It has a member variable of type
CMSFlexGrid called m_grid (CMSFlexGrid is a CWnd-derived wrapper class
created by Visual Studio for me).  I create the control as follows:

int CFlexView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
 if (CView::OnCreate(lpCreateStruct) == -1)
  return -1;

 //create the grid that goes inside this window
 m_grid.Create( NULL , WS_CHILD | WS_VISIBLE | WS_BORDER , CRect(0,0,0,0) ,
this , 0 );

 //a resize message will be sent soon to initialise the size of the window

 return 0;

Quote:
}

I can manipulate the control fine by calling the wrapper class's members but
there is no communication in the opposite direction.
I would like the control to tell me when it is clicked on but do not know
how to set it up.
This is the first time I've properly used ActiveX controls so any help will
be greatly appreciated.

Regards,
Simon Deeley



Tue, 26 Aug 2003 23:47:01 GMT  
 Getting events from an ActiveX control not in a dialog box
Ive created a program that is similar to that of yours. The fact is that you
need to create an EventSinker Object (if im right, VC++6 can create this for
you, just click with the right-button of the mice in your class, I dont
remember).
After you create the event sinker object (derived from CCmdTarget), you need to
associate the EventSinker with your control... something like this:

 m_grid.Create(NULL, WS_CHILD, CRect(0,0,500 + lExtraWidth,400+lExtraHeight),
this, 0); // Create the Control;
 pUnkSrc =  m_grid.GetControlUnknown(); // get the grid IUnknown interface
 iid     = IID_GRID_EVENTS; // this is the interface ID of the grid events
interface (you can get this from OLE Viewer)
 pUnkSink = pSink.GetInterface(&IID_IUnknown); // Get IUnknown interface of the
sink object
 hRet = AfxConnectionAdvise(pUnkSrc, iid , pUnkSink, TRUE, &dwCookie); // Voila !
This little command does all the sync for you !

Dont forget to use AfxConnectionUnadvise, using dwCookie as a parameter when
your program shutdown.

regards

Maurcio T. Ritter
MCP, MCSD

Quote:
-----Original Message-----

I would like to know how to get the ActiveX control I am using to tell me
when things happen.  The problem is that I took care of creating the control
myself, rather than using a dialog box or form view resource editor.  I have
a CView derived class, CFlexView.  It has a member variable of type
CMSFlexGrid called m_grid (CMSFlexGrid is a CWnd-derived wrapper class
created by Visual Studio for me).  I create the control as follows:

int CFlexView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
 if (CView::OnCreate(lpCreateStruct) == -1)
  return -1;

 //create the grid that goes inside this window
 m_grid.Create( NULL , WS_CHILD | WS_VISIBLE | WS_BORDER , CRect(0,0,0,0) ,
this , 0 );

 //a resize message will be sent soon to initialise the size of the window

 return 0;
}

I can manipulate the control fine by calling the wrapper class's members but
there is no communication in the opposite direction.
I would like the control to tell me when it is clicked on but do not know
how to set it up.
This is the first time I've properly used ActiveX controls so any help will
be greatly appreciated.

Regards,
Simon Deeley

.



Wed, 27 Aug 2003 00:16:11 GMT  
 Getting events from an ActiveX control not in a dialog box
Hi Simon,
    Try this page -
http://support.microsoft.com/support/kb/ARTICLES/Q147/7/40.asp

Toon



Wed, 27 Aug 2003 00:36:23 GMT  
 Getting events from an ActiveX control not in a dialog box

Quote:

> I would like to know how to get the ActiveX control I am using to tell me
> when things happen.  The problem is that I took care of creating the control
> myself, rather than using a dialog box or form view resource editor.  I have
> a CView derived class, CFlexView.  It has a member variable of type
> CMSFlexGrid called m_grid (CMSFlexGrid is a CWnd-derived wrapper class
> created by Visual Studio for me).  I create the control as follows:

> int CFlexView::OnCreate(LPCREATESTRUCT lpCreateStruct)
> {
>  if (CView::OnCreate(lpCreateStruct) == -1)
>   return -1;

>  //create the grid that goes inside this window
>  m_grid.Create( NULL , WS_CHILD | WS_VISIBLE | WS_BORDER , CRect(0,0,0,0) ,
> this , 0 );

>  //a resize message will be sent soon to initialise the size of the window

>  return 0;
> }

> I can manipulate the control fine by calling the wrapper class's members but
> there is no communication in the opposite direction.
> I would like the control to tell me when it is clicked on but do not know
> how to set it up.
> This is the first time I've properly used ActiveX controls so any help will
> be greatly appreciated.

> Regards,
> Simon Deeley

The way I do this is to make a throwaway dialog project and drop the ActiveX
control on it. Then use the wizard page to add all the event handlers.  Then cut
and paste the event sink macros made by the wizard (and edit the class name).

--
Scott McPhillips [VC++ MVP]



Wed, 27 Aug 2003 10:34:08 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. HELP: activex control in dialog box in mfc user dll (dialog not launching)

2. Not getting the message, ActiveX control in ATL dialog

3. Getting Javascript to recognize an ActiveX control event

4. Getting Events from ActiveX control in MFC ...

5. getting key events from inside an ActiveX control hosted in a CView

6. ATL ActiveX Control Event not firing in IE?

7. Firing events from an MFC ActiveX DLL (not a control)

8. ActiveX Control not getting window in ie40pp2

9. Getting the focus onto dialog's Activex controls

10. ActiveX Control Events in MFC Dialog

11. PBM: Message box not displayed after main dialog box is closed in MFC dialog-based app

12. ActiveX control events in a Dialog Bar

 

 
Powered by phpBB® Forum Software