Solved

Using AtlAxCreateControl and unloading controls

Posted on 2001-07-23
5
680 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

705 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