home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / general / cmnctrl2 / propsht.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  3.9 KB  |  160 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 "CmnCtrl2.h"
  16. #include "propsht.h"
  17. #include "progctrl.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.dwFlags &= ~PSH_HASHELP;  // Lose the Help button
  95.     m_psh.hIcon = m_hIcon;
  96.  
  97.     AddPage(&m_progctrlpage);
  98.     AddPage(&m_sliderctrlpage);
  99.     AddPage(&m_spinctrlpage);
  100. }
  101.  
  102. BEGIN_MESSAGE_MAP(CAllControlsSheet, CPropertySheet)
  103.     //{{AFX_MSG_MAP(CAllControlsSheet)
  104.     ON_WM_QUERYDRAGICON()
  105.     ON_WM_SYSCOMMAND()
  106.     //}}AFX_MSG_MAP
  107. END_MESSAGE_MAP()
  108.  
  109. /////////////////////////////////////////////////////////////////////////////
  110. // CAllControlsSheet message handlers
  111.  
  112. BOOL CAllControlsSheet::OnInitDialog()
  113. {
  114.     // Add "About..." menu item to system menu.
  115.  
  116.     // IDM_ABOUTBOX must be in the system command range.
  117.     ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  118.     ASSERT(IDM_ABOUTBOX < 0xF000);
  119.  
  120.     CMenu* pSysMenu = GetSystemMenu(FALSE);
  121.     if (pSysMenu != NULL)
  122.     {
  123.         CString strAboutMenu;
  124.         strAboutMenu.LoadString(IDS_ABOUTBOX);
  125.         if (!strAboutMenu.IsEmpty())
  126.         {
  127.             pSysMenu->AppendMenu(MF_SEPARATOR);
  128.             pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  129.         }
  130.     }
  131.  
  132.     SetIcon(m_hIcon, TRUE);
  133.     SetIcon(m_hIcon, FALSE);
  134.     return CPropertySheet::OnInitDialog();
  135. }
  136. HCURSOR CAllControlsSheet::OnQueryDragIcon()
  137. {
  138.     return (HCURSOR) m_hIcon;
  139. }
  140.  
  141. BOOL CAllControlsSheet::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
  142. {
  143.     //removing the default DS_CONTEXT_HELP style
  144. //  dwStyle= WS_SYSMENU | WS_POPUP | WS_CAPTION | DS_MODALFRAME | WS_VISIBLE;
  145.     return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
  146. }
  147.  
  148. void CAllControlsSheet::OnSysCommand(UINT nID, LPARAM lParam)
  149. {
  150.     if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  151.     {
  152.         CAboutDlg dlgAbout;
  153.         dlgAbout.DoModal();
  154.     }
  155.     else
  156.     {
  157.         CPropertySheet::OnSysCommand(nID, lParam);
  158.     }
  159. }
  160.