Solved

Using AtlAxCreateControl and unloading controls

Posted on 2001-07-23
5
664 Views
Last Modified: 2013-11-20
Hi all,

I am using the ATL function AtlAxCreateControl to create an ActiveX control at run time, using my dialog box as the parent window.

My product requires a functionality that, I must also be able to unload this dynamicaly created ActiveX control at run time. By unloading , I mean , destroying the control window (if it had one) and freeing all the associated resources.

Any comments/suggestions is welcome ?

Thanks in advance


0
Comment
Question by:saurabh_dasgupta
5 Comments
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6313222
I'd use CAxWindow::CreateControl/Ex instead it calls AtlAxCreateControl internally and wraps it up in an easy to manipulate object
0
 
LVL 4

Author Comment

by:saurabh_dasgupta
ID: 6316105
Thanks for the reply. I have just managed to get hold of some code from a MSDN article titled:
"Write ActiveX Controls Using Custom Interfaces Provided by ATL 3.0"

In this article I observed that the approach should be:

(i)Creat an instance of CAxWindow
(ii)Query for the interface IAxWinHostWindow using QueryHost method of CAxWindow
(iii)Use the method CreateControl of IAxWinHostWindow to create the OLE control
(iii)Remember a reference to the IUnknown of the OLE control
(iv)When the time to unload comes, use the IOleObject::Close  method

I am still not able to understand why the OLE control pointer returned from a direct call to AtlAxCreate.. Or CAxWindow wont give me an IOleObject interface when I do a query interface ??? Wheras the IAxWinHostWindow approach is absolutely fine ...!!!

Thanks



0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6316291
I couldn't say without further investigation but the ATL source code might hold a clue as IAxWinHostWindow is an ATL interface - it seems that as it is a wrapper then a simple QI on the interface would not work so it exposes a method that allows you to access the wrapped object - I hope this answers you question
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9490552
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

PAQ'd and pts refunded

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Roshan Davis
EE Cleanup Volunteer
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 9537144
PAQed, with points refunded (200)

Computer101
E-E Admin
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

821 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