WalkLtDemo.cpp 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. //Download by http://www.NewXing.com
  2. // WalkLtDemo.cpp : Defines the class behaviors for the application.
  3. //
  4. #include "stdafx.h"
  5. #include "WalkLtDemo.h"
  6. #include "MainFrm.h"
  7. #include "WalkLtDemoDoc.h"
  8. #include "WalkLtDemoView.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CWalkLtDemoApp
  16. BEGIN_MESSAGE_MAP(CWalkLtDemoApp, CWinApp)
  17. //{{AFX_MSG_MAP(CWalkLtDemoApp)
  18. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  19. // NOTE - the ClassWizard will add and remove mapping macros here.
  20. // DO NOT EDIT what you see in these blocks of generated code!
  21. //}}AFX_MSG_MAP
  22. // Standard file based document commands
  23. ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  24. ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  25. // Standard print setup command
  26. ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  27. END_MESSAGE_MAP()
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CWalkLtDemoApp construction
  30. CWalkLtDemoApp::CWalkLtDemoApp()
  31. {
  32. // TODO: add construction code here,
  33. // Place all significant initialization in InitInstance
  34. }
  35. /////////////////////////////////////////////////////////////////////////////
  36. // The one and only CWalkLtDemoApp object
  37. CWalkLtDemoApp theApp;
  38. // add for gdi+ ---------------
  39. GdiplusStartupInput g_gdiplusStartupInput;
  40. ULONG_PTR g_gdiplusToken;
  41. //-----------------------------------
  42. /////////////////////////////////////////////////////////////////////////////
  43. // CWalkLtDemoApp initialization
  44. BOOL CWalkLtDemoApp::InitInstance()
  45. {
  46. // add for Gdi+ ---------------
  47. GdiplusStartup(&g_gdiplusToken,&g_gdiplusStartupInput,NULL);
  48. //-----------------------------------
  49. // 设置 GDIPLUS 样例图片所在目录 ------------
  50. // ---- 假设为 本执行程序所在目录下的 gidplus_demo_data
  51. TCHAR ModuleDirectory[_MAX_PATH];
  52. ::GetModuleFileName(NULL, ModuleDirectory, _MAX_PATH);
  53. TCHAR *p=::_tcsrchr(ModuleDirectory, '\\');
  54. if (p)
  55. {
  56. *p=0;
  57. ::_tcscat(ModuleDirectory, "\\gidplus_demo_data");
  58. ::SetCurrentDirectory(ModuleDirectory);
  59. }
  60. //-----------------------------------
  61. AfxEnableControlContainer();
  62. // Standard initialization
  63. // If you are not using these features and wish to reduce the size
  64. // of your final executable, you should remove from the following
  65. // the specific initialization routines you do not need.
  66. #ifdef _AFXDLL
  67. Enable3dControls(); // Call this when using MFC in a shared DLL
  68. #else
  69. Enable3dControlsStatic(); // Call this when linking to MFC statically
  70. #endif
  71. // Change the registry key under which our settings are stored.
  72. // TODO: You should modify this string to be something appropriate
  73. // such as the name of your company or organization.
  74. SetRegistryKey(_T("Local AppWizard-Generated Applications"));
  75. LoadStdProfileSettings(); // Load standard INI file options (including MRU)
  76. // Register the application's document templates. Document templates
  77. // serve as the connection between documents, frame windows and views.
  78. CSingleDocTemplate* pDocTemplate;
  79. pDocTemplate = new CSingleDocTemplate(
  80. IDR_MAINFRAME,
  81. RUNTIME_CLASS(CWalkLtDemoDoc),
  82. RUNTIME_CLASS(CMainFrame), // main SDI frame window
  83. RUNTIME_CLASS(CWalkLtDemoView));
  84. AddDocTemplate(pDocTemplate);
  85. // Parse command line for standard shell commands, DDE, file open
  86. CCommandLineInfo cmdInfo;
  87. ParseCommandLine(cmdInfo);
  88. // Dispatch commands specified on the command line
  89. if (!ProcessShellCommand(cmdInfo))
  90. return FALSE;
  91. // The one and only window has been initialized, so show and update it.
  92. m_pMainWnd->ShowWindow(SW_SHOW);
  93. m_pMainWnd->UpdateWindow();
  94. return TRUE;
  95. }
  96. // add for Gdi+ ---------------
  97. int CWalkLtDemoApp::ExitInstance()
  98. {
  99. GdiplusShutdown(g_gdiplusToken);
  100. return CWinApp::ExitInstance();
  101. }
  102. //----------------------------------
  103. /////////////////////////////////////////////////////////////////////////////
  104. // CAboutDlg dialog used for App About
  105. class CAboutDlg : public CDialog
  106. {
  107. public:
  108. CAboutDlg();
  109. // Dialog Data
  110. //{{AFX_DATA(CAboutDlg)
  111. enum { IDD = IDD_ABOUTBOX };
  112. //}}AFX_DATA
  113. // ClassWizard generated virtual function overrides
  114. //{{AFX_VIRTUAL(CAboutDlg)
  115. protected:
  116. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  117. //}}AFX_VIRTUAL
  118. // Implementation
  119. protected:
  120. //{{AFX_MSG(CAboutDlg)
  121. // No message handlers
  122. //}}AFX_MSG
  123. DECLARE_MESSAGE_MAP()
  124. };
  125. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  126. {
  127. //{{AFX_DATA_INIT(CAboutDlg)
  128. //}}AFX_DATA_INIT
  129. }
  130. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  131. {
  132. CDialog::DoDataExchange(pDX);
  133. //{{AFX_DATA_MAP(CAboutDlg)
  134. //}}AFX_DATA_MAP
  135. }
  136. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  137. //{{AFX_MSG_MAP(CAboutDlg)
  138. // No message handlers
  139. //}}AFX_MSG_MAP
  140. END_MESSAGE_MAP()
  141. // App command to run the dialog
  142. void CWalkLtDemoApp::OnAppAbout()
  143. {
  144. CAboutDlg aboutDlg;
  145. aboutDlg.DoModal();
  146. }
  147. /////////////////////////////////////////////////////////////////////////////
  148. // CWalkLtDemoApp message handlers