home *** CD-ROM | disk | FTP | other *** search
/ Windows Graphics Programming / Feng_Yuan_Win32_GDI_DirectX.iso / Samples / include / Canvas.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-11  |  1.9 KB  |  77 lines

  1. //-----------------------------------------------------------------------------------//
  2. //              Windows Graphics Programming: Win32 GDI and DirectDraw               //
  3. //                             ISBN  0-13-086985-6                                   //
  4. //                                                                                   //
  5. //  Written            by  Yuan, Feng                             www.fengyuan.com   //
  6. //  Copyright (c) 2000 by  Hewlett-Packard Company                www.hp.com         //
  7. //  Published          by  Prentice Hall PTR, Prentice-Hall, Inc. www.phptr.com      //
  8. //                                                                                   //
  9. //  FileName   : canvas.cpp                                                             //
  10. //  Description: Generic simple child window class                                   //
  11. //  Version    : 1.00.000, May 31, 2000                                              //
  12. //-----------------------------------------------------------------------------------//
  13.  
  14. #define STRICT
  15. #define WIN32_LEAN_AND_MEAN
  16.  
  17. #include <windows.h>
  18. #include <commctrl.h>
  19. #include <tchar.h>
  20. #include <assert.h>
  21.  
  22. #include "win.h"
  23. #include "Canvas.h"
  24.  
  25.  
  26. KCanvas::KCanvas()
  27. {
  28. }
  29.  
  30.  
  31. KCanvas::~KCanvas()
  32. {
  33. }
  34.  
  35.  
  36. void KCanvas::OnDraw(HDC hDC, const RECT * rcPaint)
  37. {
  38. //    Rectangle(hDC, 0, 0, 100, 100);
  39. }
  40.  
  41.  
  42. // called by CFrame::OnCommand
  43. BOOL KCanvas::OnCommand(WPARAM wParam, LPARAM lParam)
  44. {
  45.     return FALSE;    // not processed
  46. }
  47.  
  48.  
  49. LRESULT KCanvas::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  50. {
  51.     switch( uMsg )
  52.     {
  53.         case WM_CREATE:
  54.             m_hWnd = hWnd;
  55.  
  56.             return 0;
  57.  
  58.         case WM_PAINT:
  59.             {
  60.                 PAINTSTRUCT ps; 
  61.  
  62.                 HDC hDC = BeginPaint(m_hWnd, &ps);
  63.  
  64.                 OnDraw(hDC, & ps.rcPaint);
  65.  
  66.                 EndPaint(m_hWnd, &ps);
  67.             }
  68.             return 0;
  69.  
  70.         case WM_COMMAND:
  71.             if ( OnCommand(wParam, lParam) )
  72.                 return 0;
  73.     }
  74.  
  75.     return DefWindowProc(hWnd, uMsg, wParam, lParam);
  76. }
  77.