home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / labs / c12 / lab01 / ex03 / dibfileproppage.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  2.8 KB  |  99 lines

  1. // DibFilePropPage.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "PalView.h"
  6. #include "DibFilePropPage.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CDibFilePropPage dialog
  16.  
  17. IMPLEMENT_DYNCREATE(CDibFilePropPage, COlePropertyPage)
  18.  
  19.  
  20. /////////////////////////////////////////////////////////////////////////////
  21. // Message map
  22.  
  23. BEGIN_MESSAGE_MAP(CDibFilePropPage, COlePropertyPage)
  24.     //{{AFX_MSG_MAP(CDibFilePropPage)
  25.     ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
  26.     //}}AFX_MSG_MAP
  27. END_MESSAGE_MAP()
  28.  
  29.  
  30. /////////////////////////////////////////////////////////////////////////////
  31. // Initialize class factory and guid
  32.  
  33. // {7F7767D6-365B-11D0-9C9D-00A0D100E3C8}
  34. IMPLEMENT_OLECREATE_EX(CDibFilePropPage, "PalView.CDibFilePropPage",
  35.     0x7f7767d6, 0x365b, 0x11d0, 0x9c, 0x9d, 0x0, 0xa0, 0xd1, 0x0, 0xe3, 0xc8)
  36.  
  37.  
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CDibFilePropPage::CDibFilePropPageFactory::UpdateRegistry -
  40. // Adds or removes system registry entries for CDibFilePropPage
  41.  
  42. BOOL CDibFilePropPage::CDibFilePropPageFactory::UpdateRegistry(BOOL bRegister)
  43. {
  44.     // TODO: Define string resource for page type; replace '0' below with ID.
  45.  
  46.     if (bRegister)
  47.         return AfxOleRegisterPropertyPageClass(AfxGetInstanceHandle(),
  48.             m_clsid, IDS_DIBPAGE);
  49.     else
  50.         return AfxOleUnregisterClass(m_clsid, NULL);
  51. }
  52.  
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CDibFilePropPage::CDibFilePropPage - Constructor
  56.  
  57. // TODO: Define string resource for page caption; replace '0' below with ID.
  58.  
  59. CDibFilePropPage::CDibFilePropPage() :
  60.     COlePropertyPage(IDD, IDS_DIBPAGE_CAPTION)
  61. {
  62.     //{{AFX_DATA_INIT(CDibFilePropPage)
  63.     m_DibFileName = _T("");
  64.     //}}AFX_DATA_INIT
  65. }
  66.  
  67.  
  68. /////////////////////////////////////////////////////////////////////////////
  69. // CDibFilePropPage::DoDataExchange - Moves data between page and properties
  70.  
  71. void CDibFilePropPage::DoDataExchange(CDataExchange* pDX)
  72. {
  73.     // NOTE: ClassWizard will add DDP, DDX, and DDV calls here
  74.     //    DO NOT EDIT what you see in these blocks of generated code !
  75.     //{{AFX_DATA_MAP(CDibFilePropPage)
  76.     DDP_Text(pDX, IDC_DIB_FILENAME, m_DibFileName, _T("DibFileName") );
  77.     DDX_Text(pDX, IDC_DIB_FILENAME, m_DibFileName);
  78.     //}}AFX_DATA_MAP
  79.     DDP_PostProcessing(pDX);
  80. }
  81.  
  82.  
  83. /////////////////////////////////////////////////////////////////////////////
  84. // CDibFilePropPage message handlers
  85.  
  86. void CDibFilePropPage::OnBrowse() 
  87. {
  88.     CFileDialog dlg(TRUE);
  89.  
  90.     if(dlg.DoModal() == IDOK)
  91.     {
  92.         CEdit * pEdit = (CEdit *)GetDlgItem(IDC_DIB_FILENAME);
  93.         if(0 != pEdit)
  94.         {        
  95.             pEdit->SetWindowText(dlg.GetPathName());    
  96.         }
  97.     }
  98. }
  99.