Solved

Can't use ocx control in secondary thread

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Show shut-down message as Windows 8 shuts down. 9 110
building a service to accessed via telnet client, want colors ? 4 107
wordmultiple challenge 12 170
Problem to App 4 145
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: 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.
Suggested Courses

738 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