home *** CD-ROM | disk | FTP | other *** search
/ Windows Graphics Programming / Feng_Yuan_Win32_GDI_DirectX.iso / Samples / include / dialog.h < prev    next >
C/C++ Source or Header  |  2000-05-11  |  2KB  |  75 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   : dialog.h                                                             //
  12. //  Description: Dialog box wrapper class                                            //
  13. //  Version    : 1.00.000, May 31, 2000                                              //
  14. //-----------------------------------------------------------------------------------//
  15.  
  16. class KDialog
  17. {
  18.     virtual BOOL OnInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
  19.     {
  20.         m_hWnd = hWnd;
  21.         
  22.         return TRUE;
  23.     }
  24.     
  25.     virtual BOOL OnCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
  26.     {
  27.         return FALSE;
  28.     }
  29.     
  30.     virtual BOOL DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  31.     {
  32.         switch (uMsg)
  33.         {
  34.             case WM_INITDIALOG:
  35.                 return OnInitDialog(hWnd, wParam, lParam);
  36.  
  37.             case WM_COMMAND:
  38.                 return OnCommand(hWnd, wParam, lParam);
  39.         }
  40.  
  41.         return FALSE;
  42.     }
  43.  
  44. protected:    
  45.     
  46.     typedef enum { CDIALOG_MARKER = 31415927 };
  47.     
  48.     typedef struct
  49.     {
  50.         unsigned marker;
  51.         KDialog * pDialog;
  52.     } _DialogCreateRecord;
  53.     
  54.     static BOOL CALLBACK DialogProc(HWND hWnd,  UINT uMsg, WPARAM wParam, LPARAM lParam);
  55.  
  56. public:
  57.     
  58.     HWND   m_hWnd;
  59.     
  60.     KDialog()
  61.     {
  62.         m_hWnd = NULL;
  63.     }
  64.  
  65.     int Dialogbox(HINSTANCE hInstance, LPCTSTR lpTemplate, HWND hWndParent = NULL)
  66.     {
  67.         _DialogCreateRecord ccr;
  68.  
  69.         ccr.marker  = CDIALOG_MARKER;
  70.         ccr.pDialog = this;
  71.  
  72.         return ::DialogBoxParam(hInstance, lpTemplate, hWndParent, DialogProc, (LPARAM) & ccr);
  73.     }
  74. };
  75.