Solved

Window Handle

Posted on 1997-02-20
3
208 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
Comment Utility
Would you show me some parts of your source code?
0
 

Author Comment

by:casola
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now