Solved

Using ActiveX Control in MFC DLL

Posted on 2001-07-11
5
688 Views
Last Modified: 2013-11-20
Hi,

I'm trying to create an MFC DLL that creates a dialog and has a Microsoft Web Browser control in it and use it in a straight-api style windows program. I know my activex stuff is correct because i tried creating a dialog-only mfc exe app with a web browser control in it, and it worked fine. i know my dll function is exported correctly because when the web browser control isn't in the dialog, it acts fine.  Its when i throw the activex control and dll into the mix together that things get nasty. The only thing that the debugger says is that CoCreateInstance has failed, and it asks me if i'm sure the control is registered properly and it lists the CLSID. Any help would be greatly appreciated. I'm new, so I only have 75pts, but you can answer this, they're yours.

-zack
0
Comment
Question by:zack_angelo
5 Comments
 

Author Comment

by:zack_angelo
ID: 6273515
hey guys, i just figured this out--when using activex in an MFC dll, you must call CoInitialize() for the DLL's thread. So...just throw a call to CoInitialize() in your DLL's InitInstance() event and you're all set, I hope this helps out anyone else that was having this problem. It seems that Microsoft has a habit of writing their "wizards" to do everything except a smidgen of a task for you to do...and of course that small task will make everything fall apart. <sigh>

-zack
0
 
LVL 4

Expert Comment

by:mandhjo
ID: 6273754
Don't forget to call CoUninitiliaze in the ExitInstance function.
0
 
LVL 2

Expert Comment

by:tdubroff
ID: 6274116
Yes, CoInitialize() must be called per thread!  In MFC though, I believe you can make a call to AfxOleInit() which does both the CoInitialize() and the CoUninitialize() for you.
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9490295
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: 9537282
PAQed, with points refunded (75)

Computer101
E-E Admin
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Complete beginner needs help making a cron job 9 116
has22 challenge 11 95
wordappend challenge 8 177
x-bar in Google Sheets 2 54
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

778 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