Solved

Window Handle

Posted on 1997-02-20
3
237 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
[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
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
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 be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

724 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