?
Solved

COM object problem

Posted on 2000-01-21
2
Medium Priority
?
175 Views
Last Modified: 2013-11-20
I have written a COM object using the
visual c++ wizard (DLL with automation).
The COM object has the standard DllRegisterServer, DllGetClassObject,
QueryInterface, etc ... I have also
implemented a class factory within the
COM object. My actual object is a CCmdTarget based class which has a handful of methods (including QueryInterface, AddRef, etc..) exposed.
now the problem. I am able to register the COM object, I can create a class factory object and then create my CCmdTarget based object. within the CCmdTarget object one of the methods allows me to create and display a modeless dialog. the method to create the dialog is accessed when a toolbar button on the main application window is pressed. I am able to create and display the dialog correct. within the application main window I also have a routine that uses the CCmdUI to control the state of the toolbar button ,keeping it in the pressed state as long as the modeless dialog box is displayed. I check the state of the dialog box by calling a method within my CCmdTarget class that that uses IsWindowVisible() to check if the dialog is visible. for some reason when I call this method my pointer and HWND
handle are invalid for the dialog box I created earlier and I get a memory error,  what is going on ????
0
Comment
Question by:C_HAG
2 Comments
 
LVL 4

Expert Comment

by:inpras
ID: 2376887
Make sure Ur passing the exact pointer U get while UR creating it.
0
 
LVL 3

Accepted Solution

by:
shaig earned 200 total points
ID: 2377167
Is the dialog local to the function where the DoModal function is called?
If yes, the dialog object is on stack and no referencing should be allowed after the functon exits.
You should hold the dialog object as a data member.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
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.

601 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