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

  1. #pragma once
  2.  
  3. //-----------------------------------------------------------------------------------//
  4. //              Windows Graphics Programming: Win32 GDI and DirectDraw               //
  5. //                             ISBN  0-13-086985-6                                   //
  6. //                                                                                   //
  7. //  Written            by  Yuan, Feng                             www.fengyuan.com   //
  8. //  Copyright (c) 2000 by  Hewlett-Packard Company                www.hp.com         //
  9. //  Published          by  Prentice Hall PTR, Prentice-Hall, Inc. www.phptr.com      //
  10. //                                                                                   //
  11. //  FileName   : background.h                                                         //
  12. //  Description: Bitmap window background, DDB background                            //
  13. //  Version    : 1.00.000, May 31, 2000                                              //
  14. //-----------------------------------------------------------------------------------//
  15.  
  16. // abstract class for overwriting background drawing
  17. class KBackground
  18. {
  19.     WNDPROC m_OldProc;
  20.  
  21.     virtual LRESULT EraseBackground(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  22.     virtual LRESULT WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  23.  
  24.     static LRESULT CALLBACK BackGroundWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  25.  
  26. public:
  27.     KBackground()
  28.     {
  29.         m_OldProc = NULL;
  30.     }
  31.  
  32.     virtual ~KBackground()
  33.     {
  34.     }
  35.  
  36.     BOOL Attach(HWND hWnd);
  37.     BOOL Detatch(HWND hWnd);
  38. };
  39.  
  40. // concrete class for overwriting background drawing using DDB
  41. class KDDBBackground : public KBackground
  42. {
  43.     KDDB    m_DDB;
  44.     int        m_nStyle;
  45.  
  46.     virtual LRESULT EraseBackground(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  47.  
  48. public:
  49.     KDDBBackground()
  50.     {
  51.         m_nStyle = KDDB::draw_tile;
  52.     }
  53.  
  54.     void SetStyle(int style)
  55.     {
  56.         m_nStyle = style;
  57.     }
  58.  
  59.     void SetBitmap(HMODULE hModule, int nRes)
  60.     {
  61.         m_DDB.LoadBitmap(hModule, nRes);
  62.     }
  63. };
  64.  
  65.