Monday, April 1, 2013

visual c++ ,mfc program to draw different shapes

                   /*TO DRAW DIFFERENT SHAPES*/


#include<afxwin.h>
#include"resource.h"
class myframe:public CFrameWnd
{
public:
          myframe()
          {
          LoadAccelTable(MAKEINTRESOURCE(IDR_ACCELERATOR1));
            Create(0,"my mfc",WS_OVERLAPPEDWINDOW,rectDefault,0,MAKEINTRESOURCE(IDR_MENU1));
          }
          void line()
          {
              RedrawWindow();
              CClientDC dc(this);
              dc.LineTo(100,100);
          }
          void ellipse()
          {
              RedrawWindow();
              CClientDC dc(this);
              dc.Ellipse(100,100,400,500);
          }
          void rectangle()
          {
              RedrawWindow();
              CClientDC dc(this);
              dc.Rectangle(100,100,200,200);
          }
          void arc()
          {
              RedrawWindow();
              CClientDC dc(this);
              dc.Arc(100,100,200,200,100,100,200,200);
          }
          void roundrect()
          {
              RedrawWindow();
              CClientDC dc(this);
              dc.RoundRect(100,100,200,200,10,10);
          }
          void pie()
          {
              RedrawWindow();
              CClientDC dc(this);
              dc.Pie(100,100,200,200,300,300,400,400);
          }
          DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP(myframe,CFrameWnd)
ON_COMMAND(1,line)
ON_COMMAND(2,ellipse)
ON_COMMAND(3,rectangle)
ON_COMMAND(4,arc)
ON_COMMAND(5,roundrect)
ON_COMMAND(6,pie)
END_MESSAGE_MAP()
class myapp:public CWinApp
{
public:
        virtual BOOL InitInstance()
        {
           m_pMainWnd=new myframe();
           m_pMainWnd->ShowWindow(1);
           m_pMainWnd->UpdateWindow();
           return TRUE;
        }
};
myapp app;

1 comment:

  1. enter the steps in vc++.whether it is single document or dialog based document or multiple document

    ReplyDelete