Solved

sdi application

Posted on 2010-11-18
9
559 Views
Last Modified: 2012-05-10
#include<afxwin.h>
#include "resource.h"

class MyDoc :public CDocument
{
public:
      MyDoc()
      {
      }
      DECLARE_DYNCREATE(MyDoc)
};

IMPLEMENT_DYNCREATE(MyDoc,CDocument)

class MyWnd : public CFrameWnd
{
public:
      MyWnd()
      {
      }
      DECLARE_DYNCREATE(MyWnd)

};

IMPLEMENT_DYNCREATE(MyWnd,CFrameWnd)

class MyView : public CView
{
public:
      MyView()
      {
      }
      DECLARE_DYNCREATE(MyView)
};

IMPLEMENT_DYNCREATE(MyView,CView)

class MyApp : public CWinApp
{
      CRuntimeClass *md,*mv,*mf;
public:
      BOOL InitInstance()
      {
            md = RUNTIME_CLASS(MyDoc);
            mf= RUNTIME_CLASS(MyWnd);
            mv = RUNTIME_CLASS(MyView);
            
            CSingleDocTemplate *sdi = new CSingleDocTemplate(IDR_MENU1,md,mv,mf);
            AddDocTemplate(sdi);
            return TRUE;
      }

};
MyApp app;

error
Compiling...
SDI.CPP
E:\VC++\SDI Applicaion\SDI.CPP(36) : error C2259: 'MyView' : cannot instantiate abstract class due to following members:
        E:\VC++\SDI Applicaion\SDI.CPP(27) : see declaration of 'MyView'
E:\VC++\SDI Applicaion\SDI.CPP(36) : warning C4259: 'void __thiscall CView::OnDraw(class CDC *)' : pure virtual function was not defined
        c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(3594) : see declaration of 'OnDraw'
E:\VC++\SDI Applicaion\SDI.CPP(36) : error C2259: 'MyView' : cannot instantiate abstract class due to following members:
        E:\VC++\SDI Applicaion\SDI.CPP(27) : see declaration of 'MyView'
E:\VC++\SDI Applicaion\SDI.CPP(36) : warning C4259: 'void __thiscall CView::OnDraw(class CDC *)' : pure virtual function was not defined
        c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(3594) : see declaration of 'OnDraw'
Error executing cl.exe.


please help me out
0
Comment
Question by:VenkateshArchana
[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
  • 5
  • 4
9 Comments
 
LVL 31

Accepted Solution

by:
Zoppo earned 50 total points
ID: 34163284
Hi VenkateshArchana,

the error messages exactly tell you what's wrong - your CView-derived class has to implement it's own 'OnDraw' function since the base class didn't implement it allthough it's declared (that's why CView is an abstract class).

So, implement a 'void MyView::OnDraw( CDC* )' to resolve this errors ...

Hope that helps,

ZOPPO
0
 

Author Closing Comment

by:VenkateshArchana
ID: 34163421
yes i missed OnDraw in view class,thanks
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 34163438
Hm - you're welcome - but, why did you decide to rate this answer as 'B'? Was anything missing or unclear or incorrect?
0
Independent Software Vendors: 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!

 

Author Comment

by:VenkateshArchana
ID: 34163522
i just missed out , surely it was an excellent answer with one line
0
 

Author Comment

by:VenkateshArchana
ID: 34163537
can u explain the difference between between CClientDC and CPaintDC
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 34163587
A CClientDC is a DC which 'addresses' the client area of a window without any extra handling. A CPaintDC is a DC which internally handles calls to 'BeginDraw' and 'EndDraw' GDI functions which are used to draw when a window (or part of it) needs to be updated. So a CPaintDC i.e. is created with a clipping region including only the parts of the window which needs updating, a CClientDC initially has no clipping region.
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 34163605
Addition: due to the above mentioned you usually cannot use CPaintDC outside of a WM_PAINT message handler since only within a WM_PAINT message handler BeginPaint/EndPaint can be used to create a DC. And, further, it's not possible to create more than one CPaintDC while processing a WM_PAINT message ...
0
 

Author Comment

by:VenkateshArchana
ID: 34164126
can u give me an example for the above 2
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 34164713
Well, the usage of both is the same (as with any kind of DC), the only difference is when to use which one - commonly (i.e. with a CView) there's no need to worry about this since the relevant functions get a CDC* passed like CView::OnDraw. A CPaintDC is only needed/used when a WM_PAINT message is to be handled directly, so i.e. if a new kind of control is to be implemented.

Here's a link to a book (at google-boos) with lot's of MFC samples, maybe this can help you: http://books.google.com/books?id=7PsZNxl_5U8C&pg=PA120&lpg=PA120&dq=CPaintDC+sample&source=bl&ots=SYdWrtLJMn&sig=S-4kSnkbSPzeFk7RhPtr8C9AE8E&hl=de&ei=fz3lTPTqJoLusgavgN24Cw&sa=X&oi=book_result&ct=result&resnum=6&ved=0CEYQ6AEwBQ#v=onepage&q&f=false

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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
FMX enumerated colours 2 152
Header of docx file 17 142
Create a path if not exists 7 123
Precision Problem in C++ 7 65
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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

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