home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / general / cmnctrl1 / propsht.cpp < prev    next >
C/C++ Source or Header  |  1998-03-26  |  4KB  |  156 lines

  1. // AllControlsSheet.cpp : implementation file
  2. //
  3.  
  4. // This is a part of the Microsoft Foundation Classes C++ library.
  5. // Copyright (C) 1992-1998 Microsoft Corporation
  6. // All rights reserved.
  7. //
  8. // This source code is only intended as a supplement to the
  9. // Microsoft Foundation Classes Reference and related
  10. // electronic documentation provided with the library.
  11. // See these sources for detailed information regarding the
  12. // Microsoft Foundation Classes product.
  13.  
  14. #include "stdafx.h"
  15. #include "CmnCtrl1.h"
  16. #include "propsht.h"
  17. #include "mtreectl.h"
  18.  
  19. #ifdef _DEBUG
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24.  
  25. class CAboutDlg : public CDialog
  26. {
  27. public:
  28.     CAboutDlg();
  29.  
  30. // Dialog Data
  31.     //{{AFX_DATA(CAboutDlg)
  32.     enum { IDD = IDD_ABOUTBOX };
  33.     //}}AFX_DATA
  34.  
  35.     // ClassWizard generated virtual function overrides
  36.     //{{AFX_VIRTUAL(CAboutDlg)
  37.     protected:
  38.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  39.     //}}AFX_VIRTUAL
  40.  
  41. // Implementation
  42. protected:
  43.     //{{AFX_MSG(CAboutDlg)
  44.     //}}AFX_MSG
  45.     DECLARE_MESSAGE_MAP()
  46. };
  47.  
  48. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  49. {
  50.     //{{AFX_DATA_INIT(CAboutDlg)
  51.     //}}AFX_DATA_INIT
  52. }
  53.  
  54. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  55. {
  56.     CDialog::DoDataExchange(pDX);
  57.     //{{AFX_DATA_MAP(CAboutDlg)
  58.     //}}AFX_DATA_MAP
  59. }
  60.  
  61. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  62.     //{{AFX_MSG_MAP(CAboutDlg)
  63.         // No message handlers
  64.     //}}AFX_MSG_MAP
  65. END_MESSAGE_MAP()
  66.  
  67. /////////////////////////////////////////////////////////////////////////////
  68. // CAllControlsSheet
  69.  
  70. IMPLEMENT_DYNAMIC(CAllControlsSheet, CPropertySheet)
  71.  
  72. CAllControlsSheet::CAllControlsSheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
  73.     :CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
  74. {
  75.     AddControlPages();
  76.  
  77.     // TODO :: Add the pages for the rest of the controls here.
  78. }
  79.  
  80. CAllControlsSheet::CAllControlsSheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
  81.     :CPropertySheet(pszCaption, pParentWnd, iSelectPage)
  82. {
  83.     AddControlPages();
  84. }
  85.  
  86. CAllControlsSheet::~CAllControlsSheet()
  87. {
  88. }
  89.  
  90. void CAllControlsSheet::AddControlPages()
  91. {
  92.     m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  93.     m_psh.dwFlags |= PSP_USEHICON;
  94.     m_psh.hIcon = m_hIcon;
  95.     m_psh.dwFlags |= PSH_NOAPPLYNOW;    // Lose the Apply Now button
  96.     m_psh.dwFlags &= ~PSH_HASHELP;  // Lose the Help button
  97.  
  98.     AddPage(&m_treectrlpage);
  99.     AddPage(&m_animctrlpage);
  100.     AddPage(&m_toolbarpage);
  101.     AddPage(&m_datetimepage);
  102.     AddPage(&m_monthcalpage);
  103. }
  104.  
  105. BEGIN_MESSAGE_MAP(CAllControlsSheet, CPropertySheet)
  106.     //{{AFX_MSG_MAP(CAllControlsSheet)
  107.     ON_WM_QUERYDRAGICON()
  108.     ON_WM_SYSCOMMAND()
  109.     //}}AFX_MSG_MAP
  110. END_MESSAGE_MAP()
  111.  
  112. /////////////////////////////////////////////////////////////////////////////
  113. // CAllControlsSheet message handlers
  114.  
  115. BOOL CAllControlsSheet::OnInitDialog()
  116. {
  117.     // Add "About..." menu item to system menu.
  118.  
  119.     // IDM_ABOUTBOX must be in the system command range.
  120.     ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  121.     ASSERT(IDM_ABOUTBOX < 0xF000);
  122.  
  123.     CMenu* pSysMenu = GetSystemMenu(FALSE);
  124.     if (pSysMenu != NULL)
  125.     {
  126.         CString strAboutMenu;
  127.         strAboutMenu.LoadString(IDS_ABOUTBOX);
  128.         if (!strAboutMenu.IsEmpty())
  129.         {
  130.             pSysMenu->AppendMenu(MF_SEPARATOR);
  131.             pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  132.         }
  133.     }
  134.  
  135.     SetIcon(m_hIcon, TRUE);
  136.     SetIcon(m_hIcon, FALSE);
  137.     return CPropertySheet::OnInitDialog();
  138. }
  139. HCURSOR CAllControlsSheet::OnQueryDragIcon()
  140. {
  141.     return (HCURSOR) m_hIcon;
  142. }
  143.  
  144. void CAllControlsSheet::OnSysCommand(UINT nID, LPARAM lParam)
  145. {
  146.     if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  147.     {
  148.         CAboutDlg dlgAbout;
  149.         dlgAbout.DoModal();
  150.     }
  151.     else
  152.     {
  153.         CPropertySheet::OnSysCommand(nID, lParam);
  154.     }
  155. }
  156.