Solved

Can't use ocx control in secondary thread

Posted on 1997-06-22
2
317 Views
Last Modified: 2013-11-19
Hi, need some help here. I can't seem to use any ocx control (such as grid32 and crystal report control) when they are used in secondary threads.
If I use them in my main application no problem. The problem occurs when I post a thread message (using PostThreadMessage) to another user interface thread (derived using CWinThread, and is in another mfc externison dll). The dialog box that
consists the control will appear but will then crash out with access violation exception after the dialog box is closed.
The msdn knowledge base noted that this is a bug in ver 4.1 of visual c, but visual 4.2b should work. Anyone has any solution here? Thanks a lot.

Regards
Boon Tien Ng

0
Comment
Question by:boontien
2 Comments
 

Expert Comment

by:jasiek
ID: 1302243
I can put here my remark. First of all I always have problems using PostThreadMessage(). Use global variables to transfer data between threads and it will work. Second, if you have access violation on closing window, that means some work in destruction of this window was done by you, and some by MFC. And there is a conflict. I do not know how you create this window, but maybe you should use pointers instead of objects, create objects and delete them explicitly. Use Destroy() on window objects.
Regards,
0
 
LVL 1

Accepted Solution

by:
dabbler earned 100 total points
ID: 1302244
Make sure you're initializing OLE from each thread you're using it in.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Host to IP 7 76
Separate files macro - Errors on larger data set 18 65
ASCII Non-Printable characters/codes and their HTML equivalents 6 104
pre4 challenge 19 93
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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 is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

943 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

9 Experts available now in Live!

Get 1:1 Help Now