Solved

Can't use ocx control in secondary thread

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

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: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.

831 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