Hi ,
          I have  written a basic win32 application which will draw a rectangle 
once we  click a button. But whenever we resize or Minimizs/Maximize the window 
 , it is being painted by background. I don't understand which event I  need to 
handle. I was suggested to use WM_PAINT/WM_SIZE , but while  handling this 
event , when we don't know how many rectangles etc were  drawn on client 
surface how can we restore them once we resized . 
  My code is:
  #include<afxwin.h>
  #define btnmsg WM_USER+10
  class paintfrm:public CFrameWnd
  {
      CButton *btn;
  public:
      paintfrm()
      {
          btn=new CButton();
          Create(NULL,"Paint");
          
btn->Create("Abcd",WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,CRect(0,0,50,50),this,btnmsg);
  
      }
      void onpush()
      {
          CClientDC dc(this);
          POINT pnt;
          pnt.x=50;
          pnt.y=50;
          dc.MoveTo(pnt);
          RECT r;
          r.left=r.top=50;
          r.right=r.bottom=100;
  
          dc.Rectangle(&r);
      }
      DECLARE_MESSAGE_MAP()
  };
  BEGIN_MESSAGE_MAP(paintfrm,CFrameWnd)
  ON_COMMAND(btnmsg,onpush)
  END_MESSAGE_MAP()
  class myapp:public CWinApp
  {
  public:
      BOOL InitInstance()
      {
          m_pMainWnd=new paintfrm();
          m_pMainWnd->ShowWindow(1);
          m_pMainWnd->UpdateWindow();
          return 1;
      }
  };
  myapp app;
  
  
  Thanks&Regards,
  Gopi.k


 
---------------------------------
Access over 1 million songs - Yahoo! Music Unlimited.

Reply via email to