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

  1. // ctrltest.cpp : Dialogs and Controls test applet
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "stdafx.h"
  14. #include "ctrltest.h"
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17. // Main Window
  18.  
  19. // The OnTest routines are in the source files containing the particular
  20. // dialog that they are working with.  For example OnTestDerivedEdit is
  21. // in file dertest.cpp
  22.  
  23. BEGIN_MESSAGE_MAP(CTestWindow, CFrameWnd)
  24.     //{{AFX_MSG_MAP(CTestWindow)
  25.     ON_COMMAND(IDM_TEST_DERIVED_EDIT, OnTestDerivedEdit)
  26.     ON_COMMAND(IDM_TEST_WNDCLASS_EDIT, OnTestWndClassEdit)
  27.     ON_COMMAND(IDM_TEST_SUB_EDIT, OnTestSubclassedEdit)
  28.     ON_COMMAND(IDM_TEST_BITMAP_BUTTON1, OnTestBitmapButton1)
  29.     ON_COMMAND(IDM_TEST_BITMAP_BUTTON2, OnTestBitmapButton2)
  30.     ON_COMMAND(IDM_TEST_BITMAP_BUTTON3, OnTestBitmapButton3)
  31.     ON_COMMAND(IDM_TEST_CUSTOM_LIST, OnTestCustomList)
  32.     ON_COMMAND(IDM_TEST_SPIN_EDIT, OnTestSpinEdit)
  33.     //}}AFX_MSG_MAP
  34. END_MESSAGE_MAP()
  35.  
  36. void CTestWindow::SetupMenus()
  37. {
  38.     if ((GetSystemMetrics(SM_PENWINDOWS)) == NULL)
  39.     {
  40.         CMenu* pMenu = GetMenu();
  41.         ASSERT(pMenu != NULL);
  42.         pMenu->EnableMenuItem(IDM_TEST_PENEDIT_CODE, MF_DISABLED|MF_GRAYED);
  43.         pMenu->EnableMenuItem(IDM_TEST_PENEDIT_TEMPLATE, MF_DISABLED|MF_GRAYED);
  44.         pMenu->EnableMenuItem(IDM_TEST_PENEDIT_FEATURES, MF_DISABLED|MF_GRAYED);
  45.     }
  46.     // do not test for spin control until the user tries it
  47.     // if the custom control DLL is not present, the test spin
  48.     //  control menu item will be disabled in 'OnTestSpinEdit'.
  49.  
  50.     // custom menu tests
  51.     AttachCustomMenu();
  52. }
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. // Application class
  56.  
  57. class CTestApp : public CWinApp
  58. {
  59. public:
  60.     CTestApp();
  61.  
  62.     virtual BOOL InitInstance();
  63.     //{{AFX_MSG(CTestApp)
  64.     afx_msg void OnAppAbout();
  65.     //}}AFX_MSG
  66.     DECLARE_MESSAGE_MAP();
  67. };
  68.  
  69. CTestApp::CTestApp()
  70. {
  71.     // Place all significant initialization in InitInstance
  72. }
  73.  
  74.  
  75. BEGIN_MESSAGE_MAP(CTestApp, CWinApp)
  76.     //{{AFX_MSG_MAP(CTestApp)
  77.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  78.     //}}AFX_MSG_MAP
  79. END_MESSAGE_MAP()
  80.  
  81. CTestApp NEAR theTestApp;
  82.  
  83. BOOL CTestApp::InitInstance()
  84. {
  85.     //SetDialogBkColor();   // Gray dialog backgrounds
  86.     Enable3dControls();
  87.  
  88.     CTestWindow* pMainWnd = new CTestWindow;
  89.     if (!pMainWnd->Create(NULL, _T("Control Test App"),
  90.       WS_OVERLAPPEDWINDOW, CFrameWnd::rectDefault, NULL,
  91.       MAKEINTRESOURCE(AFX_IDI_STD_FRAME)/*menu*/))
  92.         return FALSE;
  93.  
  94.     pMainWnd->m_bAutoMenuEnable = FALSE;    // do manual menu enabling
  95.     pMainWnd->SetupMenus();
  96.     pMainWnd->ShowWindow(m_nCmdShow);
  97.     m_pMainWnd = pMainWnd;      // store in CWinApp member
  98.     return TRUE;
  99. }
  100.  
  101. void CTestApp::OnAppAbout()
  102. {
  103.     CDialog(_T("ABOUTBOX")).DoModal();
  104. }
  105.  
  106. /////////////////////////////////////////////////////////////////////////////
  107.