home *** CD-ROM | disk | FTP | other *** search
/ Windows Graphics Programming / Feng_Yuan_Win32_GDI_DirectX.iso / Samples / Chapt_04 / Pogy / Setup.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-11  |  2.9 KB  |  99 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   : setup.cpp                                                             //
  10. //  Description: KSetupPogyPage class                                                //
  11. //  Version    : 1.00.000, May 31, 2000                                              //
  12. //-----------------------------------------------------------------------------------//
  13.  
  14. #define NOCRYPT
  15.  
  16. #include <windows.h>
  17. #include <commctrl.h>
  18. #include <assert.h>
  19. #include <stdio.h>
  20. #include <tchar.h>
  21.  
  22. #include "..\..\include\win.h"
  23. #include "..\..\include\property.h"
  24. #include "..\..\include\Profile.h"
  25.  
  26. #include "Resource.h"
  27. #include "Setup.h"
  28.  
  29. const TCHAR sec_option    [] = _T("Option");
  30.  
  31. const TCHAR key_logcall   [] = _T("LogCall");
  32. const TCHAR key_dispcall  [] = _T("DispCall");
  33.  
  34.  
  35. void KSetupPogyPage::SetButtons(void)
  36. {
  37.     if ( IsWindow(m_hWnd) )
  38.     {
  39.         SendDlgItemMessage(m_hWnd, IDC_LOGCALL,   BM_SETCHECK, bLogCall, 0);
  40.         SendDlgItemMessage(m_hWnd, IDC_DISPCALL,  BM_SETCHECK, bDispCall, 0);
  41.     }
  42. }
  43.  
  44.  
  45. void KSetupPogyPage::ReadButtons(void)
  46. {
  47.     if ( IsWindow(m_hWnd) )
  48.     {
  49.         bLogCall   = SendDlgItemMessage(m_hWnd, IDC_LOGCALL,  BM_GETCHECK, 0, 0) != 0;
  50.         bDispCall  = SendDlgItemMessage(m_hWnd, IDC_DISPCALL, BM_GETCHECK, 0, 0) != 0;
  51.     }
  52. }
  53.  
  54.  
  55. BOOL KSetupPogyPage::DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  56. {
  57.     switch (uMsg)
  58.     {
  59.         case WM_INITDIALOG:
  60.             m_hWnd = hWnd;
  61.             SetButtons();
  62.             return TRUE;
  63.  
  64.         case WM_DESTROY:
  65.             ReadButtons();
  66.             m_hWnd = NULL;
  67.             return TRUE;
  68.  
  69.         default:
  70.             break;
  71.     }
  72.  
  73.     return FALSE;
  74. }
  75.  
  76.  
  77. void KSetupPogyPage::ReadOptions(HINSTANCE hInstance)
  78. {
  79.     KProfile Profile;
  80.  
  81.     Profile.SetFileName(hInstance, _T("Pogy.ini"));
  82.     
  83.     bLogCall   = Profile.ReadInt(sec_option, key_logcall,  true) != 0;
  84.     bDispCall  = Profile.ReadInt(sec_option, key_dispcall, true) != 0;
  85. }
  86.  
  87.  
  88. void KSetupPogyPage::SaveOptions(HINSTANCE hInstance)
  89. {
  90.     KProfile Profile;
  91.  
  92.     Profile.SetFileName(hInstance, _T("Pogy.ini"));
  93.  
  94.     Profile.Write(sec_option, key_logcall,   bLogCall);
  95.     Profile.Write(sec_option, key_dispcall,  bDispCall);
  96. }
  97.  
  98.  
  99.