We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Dynamically loading an activex control

awhit01
awhit01 asked
on
Medium Priority
441 Views
Last Modified: 2013-11-20
I know that it is possible to instantiate an activex control at runtime by passing the CLSID. Does anyone know any more about this or have a sample???

Thanks
Comment
Watch Question

Commented:
You're asking this question in the MFC section, so i am assuming you have visual c installed ...
Take a look into the TSTCON32.EXE source code, which you'll find on your vc++ cd.
It is the 'Test container' in your 'Tools' menu, and it binds dynamically to an user selectable
OCX ... Is that what you're looking for?

Author

Commented:
I dont appear to have the code for this but I do know what you mean. Where can i get the source??


Commented:
I currently have no access to my Visual C++ CD - it's installed on the computer in my office.
But i am 100% sure that the source code is provided (i'm using VC 4.0) - search the
CD for 'tstcon.mdp' or 'tstcon32.mdp' or even 'tstcon.mak'.
On of these should be successful ...
Another helpful page could be

http://premium.microsoft.com/msdn/library/techart/msdn_contcntr.htm

just check it out

Author

Commented:
Code is not on Visual C++ 4 disc, Visual C++ 5 disc, Platform SDK or MSSDK. Are you sure the code came from there??


Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
No, the control must have no dependency on the container. The control is user-selectable at runtime and it's methods/properties should be accessibly


Commented:
I see. So call CWnd::CreateControl.

BOOL CWnd::CreateControl( LPCTSTR lpszClass, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CFile* pPersist = NULL, BOOL bStorage = FALSE, BSTR bstrLicKey = NULL );

BOOL CWnd::CreateControl( REFCLSID clsid, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CFile* pPersist = NULL, BOOL bStorage = FALSE, BSTR bstrLicKey = NULL );

CWnd::CreateControl helps to do this

Commented:
And you can call CWnd::InvokeHelper to access its methods and properties.

Commented:
Also CWnd::GetProperty, CWnd::SetProperty.

Commented:
Take a look into a visual c generated ocx mapper. You'll see there how the control
gets initialized and how the functions are called.

Commented:
>generated ocx mapper
generated OCX wrapper class

Commented:
Sorry - i am in germany and unfortunately it is quite expensive to have access to
the internet here - so i am often a little bit in a hurry :)
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.