pickzy.com

C  |  C++  |  Objective-C  |  VC++  |  Win32  |  MFC  |  Java  |  Php  |  Delphi  |  Visual Basic  |  .Net  |  Networking  |  General  |  Games  |  Jobs  |  Javascript  |  




Menu

pickSourcecode.com


        

 




 

VCpp > Programs

 

VC++ - Line Drawing, Shapes and saving, using Document / view Architecture

/*  
The  cline  Class

Our  program  stores  the  information  about  the  lines  thar  are  drawn  in  an  array  of  cline  objects.  The  cline
class  is  publicly  derived  from  CObject.  This  makes  it  easy  for  us  to  add  serialization  support  to  the  cline  
class.  so  that  the  entire  drawing  can  be  saved  or  restored  with  just  a  few  lines  of  code.
*/


//  cline.h
class cline : public CObject

{

DECLARE_SERIAL ( cline ) 


private :


CPo
int startpt ;
CPo
int endpt ;

public :


cline( ) ;

cline ( CPo
int from, CPoint to ) ;
void Serialize ( CArchive &ar ) ;
void draw ( CDC *p ) ;
} ;


//  cline.cpp
#include <afxwin.h>
#include "cline.h"

IMPLEMENT_SERIAL ( cline, CObject, 1 ) 


cline::cline( )

{

}


cline::cline ( CPo
int from, CPoint to ) 
{

startpt = from ;

endpt = to ;

}


void cline::Serialize ( CArchive &ar )
{

CObject::Serialize ( ar ) ;


if ( ar.IsStoring( ) ) 
ar << startpt << endpt ;

else

ar >> startpt >> endpt ;

}


void cline::draw ( CDC *p )
{

p -> MoveTo ( startpt ) ;

p -> LineTo ( endpt ) ;

}


//  Output

 
Privacy Policy | About Us