Solved

Using AtlAxCreateControl and unloading controls

Posted on 2001-07-23
5
653 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
PAQed, with points refunded (200)

Computer101
E-E Admin
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now