home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 19.ddi / MFC / SAMPLES / CTRLTEST / CTRLTEST.CP_ / CTRLTEST.CP
Encoding:
Text File  |  1993-02-08  |  3.3 KB  |  109 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 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 Microsoft
  9. // WinHelp 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.     ON_COMMAND(IDM_TEST_PENEDIT_CODE, OnTestPenEditFromCode)
  34.     ON_COMMAND(IDM_TEST_PENEDIT_TEMPLATE, OnTestPenEditFromTemplate)
  35.     ON_COMMAND(IDM_TEST_PENEDIT_FEATURES, OnTestPenEditFeatures)
  36.     //}}AFX_MSG_MAP
  37. END_MESSAGE_MAP()
  38.  
  39. void CTestWindow::SetupMenus()
  40. {
  41.     if ((GetSystemMetrics(SM_PENWINDOWS)) == NULL)
  42.     {
  43.         CMenu* pMenu = GetMenu();
  44.         ASSERT(pMenu != NULL);
  45.         pMenu->EnableMenuItem(IDM_TEST_PENEDIT_CODE, MF_DISABLED|MF_GRAYED);
  46.         pMenu->EnableMenuItem(IDM_TEST_PENEDIT_TEMPLATE, MF_DISABLED|MF_GRAYED);
  47.         pMenu->EnableMenuItem(IDM_TEST_PENEDIT_FEATURES, MF_DISABLED|MF_GRAYED);
  48.     }
  49.     // do not test for spin control until the user tries it
  50.     // if the custom control DLL is not present, the test spin
  51.     //  control menu item will be disabled in 'OnTestSpinEdit'.
  52.  
  53.     // custom menu tests
  54.     AttachCustomMenu();
  55. }
  56.  
  57. /////////////////////////////////////////////////////////////////////////////
  58. // Application class
  59.  
  60. class CTestApp : public CWinApp
  61. {
  62. public:
  63.     CTestApp();
  64.  
  65.     virtual BOOL InitInstance();
  66.     //{{AFX_MSG(CTestApp)
  67.     afx_msg void OnAppAbout();
  68.     //}}AFX_MSG
  69.     DECLARE_MESSAGE_MAP();
  70. };
  71.  
  72. CTestApp::CTestApp()
  73. {
  74.     // Place all significant initialization in InitInstance
  75. }
  76.  
  77.  
  78. BEGIN_MESSAGE_MAP(CTestApp, CWinApp)
  79.     //{{AFX_MSG_MAP(CTestApp)
  80.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  81.     //}}AFX_MSG_MAP
  82. END_MESSAGE_MAP()
  83.  
  84. CTestApp NEAR theTestApp;
  85.  
  86. BOOL CTestApp::InitInstance()
  87. {
  88.     SetDialogBkColor(RGB(192, 192, 192));   // Gray dialog backgrounds
  89.  
  90.     CTestWindow* pMainWnd = new CTestWindow;
  91.     if (!pMainWnd->Create(NULL, "Control Test App",
  92.       WS_OVERLAPPEDWINDOW, CFrameWnd::rectDefault, NULL,
  93.       MAKEINTRESOURCE(AFX_IDI_STD_FRAME)/*menu*/))
  94.         return FALSE;
  95.  
  96.     pMainWnd->m_bAutoMenuEnable = FALSE;    // do manual menu enabling
  97.     pMainWnd->SetupMenus();
  98.     pMainWnd->ShowWindow(m_nCmdShow);
  99.     m_pMainWnd = pMainWnd;      // store in CWinApp member
  100.     return TRUE;
  101. }
  102.  
  103. void CTestApp::OnAppAbout()
  104. {
  105.     CDialog("ABOUTBOX").DoModal();
  106. }
  107.  
  108. /////////////////////////////////////////////////////////////////////////////
  109.