MTGDI.CPP
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:3k
源码类别:

Windows编程

开发平台:

Visual C++

  1. // mtgdi.cpp : Defines the class behaviors for the application.
  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. #include "stdafx.h"
  13. #include "mtgdi.h"
  14. #include "mainfrm.h"
  15. #include "mtgdidoc.h"
  16. #include "mtgdivw.h"
  17. #include "threads.h"
  18. #ifdef _DEBUG
  19. #undef THIS_FILE
  20. static char BASED_CODE THIS_FILE[] = __FILE__;
  21. #endif
  22. BEGIN_MESSAGE_MAP(CThreadApp, CWinApp)
  23. //{{AFX_MSG_MAP(CThreadApp)
  24. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  25. // NOTE - the ClassWizard will add and remove mapping macros here.
  26. //    DO NOT EDIT what you see in these blocks of generated code!
  27. //}}AFX_MSG_MAP
  28. // Standard file based document commands
  29. ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  30. ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  31. END_MESSAGE_MAP()
  32. CThreadApp::CThreadApp()
  33. {
  34. }
  35. CThreadApp theApp;
  36. BOOL CThreadApp::InitInstance()
  37. {
  38. Enable3dControls();
  39. // Initialize static members of CGDIThread
  40. InitializeCriticalSection(&CGDIThread::m_csGDILock);
  41. // Register the application's document templates.  Document templates
  42. //  serve as the connection between documents, frame windows and views.
  43. CSingleDocTemplate* pDocTemplate;
  44. pDocTemplate = new CSingleDocTemplate(
  45. IDR_MAINFRAME,
  46. RUNTIME_CLASS(CThreadDoc),
  47. RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  48. RUNTIME_CLASS(CThreadView));
  49. AddDocTemplate(pDocTemplate);
  50. // create a new (empty) document
  51. OnFileNew();
  52. if (m_lpCmdLine[0] != '')
  53. {
  54. // TODO: add command line processing here
  55. }
  56. return TRUE;
  57. }
  58. int CThreadApp::ExitInstance()
  59. {
  60. DeleteCriticalSection(&CGDIThread::m_csGDILock);
  61. CloseHandle(CGDIThread::m_hAnotherDead);
  62. return CWinApp::ExitInstance();
  63. }
  64. /////////////////////////////////////////////////////////////////////////////
  65. // CAboutDlg dialog used for App About
  66. class CAboutDlg : public CDialog
  67. {
  68. public:
  69. CAboutDlg();
  70. // Dialog Data
  71. //{{AFX_DATA(CAboutDlg)
  72. enum { IDD = IDD_ABOUTBOX };
  73. //}}AFX_DATA
  74. // Implementation
  75. protected:
  76. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  77. //{{AFX_MSG(CAboutDlg)
  78. // No message handlers
  79. //}}AFX_MSG
  80. DECLARE_MESSAGE_MAP()
  81. };
  82. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  83. {
  84. //{{AFX_DATA_INIT(CAboutDlg)
  85. //}}AFX_DATA_INIT
  86. }
  87. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  88. {
  89. CDialog::DoDataExchange(pDX);
  90. //{{AFX_DATA_MAP(CAboutDlg)
  91. //}}AFX_DATA_MAP
  92. }
  93. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  94. //{{AFX_MSG_MAP(CAboutDlg)
  95. // No message handlers
  96. //}}AFX_MSG_MAP
  97. END_MESSAGE_MAP()
  98. // App command to run the dialog
  99. void CThreadApp::OnAppAbout()
  100. {
  101. CAboutDlg().DoModal();
  102. }