Solved

Window Handle

Posted on 1997-02-20
3
227 Views
Last Modified: 2010-04-10
I have a class Parent which inherit from CFrameWnd-class.
In this class I call the CFrameWnd::Create function to obtain for my class a valid handle.
Now I want to inherit another class, Parent1, from the Parent-class.
If I call in the Parent1-class the Create function, I have an error during the execution phase, but if I don't call this function, the Message map in the Parent1-class generates the error: Access Violation during the execution phase.
How can I resolve this problem?
Is it possible to have for the Parent1-class a valid handle different from the Parent-calss's handle?
It's important for me to have a valid handle because I have to handle my personal messages.
Thanks for the answers.
Bye.
0
Comment
Question by:casola
3 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 1162111
Would you show me some parts of your source code?
0
 

Author Comment

by:casola
ID: 1162112
Could you give me some answer?
I'll try to write down part of my source code.
0
 

Accepted Solution

by:
shurik earned 20 total points
ID: 1162113
I suppose you've got a mistake in message map declaration for your Parent1 class. This is the working example. I've made single document application using Application Wizard, then

class CInheritFrame : public CMainFrame
{
protected: // create from serialization only
      DECLARE_DYNCREATE(CInheritFrame)

// Attributes
public:
      CInheritFrame() {;}
      BOOL Create() { return CFrameWnd::Create(NULL, "CInheritFrame"); }

// Operations
public:

// Overrides
      // ClassWizard generated virtual function overrides
      //{{AFX_VIRTUAL(CInheritFrame)
      //}}AFX_VIRTUAL

// Implementation
public:
      virtual ~CInheritFrame() {;}

protected:  // control bar embedded members
      CStatusBar  m_wndStatusBar;
      CToolBar    m_wndToolBar;

// Generated message map functions
protected:
      //{{AFX_MSG(CInheritFrame)
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()
};

then somewhere, for example CDoc::OnNewDocument

      CInheritFrame * pFrame = new CInheritFrame;
      BOOL b = pFrame->Create();
      pFrame->ShowWindow(SW_SHOW);

You will see second frame window


0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

860 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