Solved

Can't use ocx control in secondary thread

Posted on 1997-06-22
2
300 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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…
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.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 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

20 Experts available now in Live!

Get 1:1 Help Now