MiddleWares_YiHe 郑州颐和医院随访系统中间件

VoiceStation.cpp 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. // VoiceStation.cpp : 定义应用程序的类行为。
  2. //
  3. #include "stdafx.h"
  4. #include "VoiceStation.h"
  5. #include "DisplayWnd.h"
  6. #include "SystemLauncher.h"
  7. #include "ExceptionHandler.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #endif
  11. LONG WINAPI AppUnhandledExceptionFilter(struct _EXCEPTION_POINTERS* ExceptionInfo)
  12. {
  13. RecordExceptionInfo(ExceptionInfo, "VoiceStation");
  14. return EXCEPTION_EXECUTE_HANDLER;
  15. }
  16. // CVoiceStationApp
  17. BEGIN_MESSAGE_MAP(CVoiceStationApp, CWinApp)
  18. ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
  19. END_MESSAGE_MAP()
  20. // CVoiceStationApp 构造
  21. CVoiceStationApp::CVoiceStationApp()
  22. {
  23. // 支持重新启动管理器
  24. m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;
  25. // TODO: 在此处添加构造代码,
  26. // 将所有重要的初始化放置在 InitInstance 中
  27. SetUnhandledExceptionFilter(AppUnhandledExceptionFilter);
  28. }
  29. // 唯一的一个 CVoiceStationApp 对象
  30. CVoiceStationApp theApp;
  31. // CVoiceStationApp 初始化
  32. BOOL CVoiceStationApp::InitInstance()
  33. {
  34. #ifndef _DEBUG
  35. SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOGPFAULTERRORBOX);
  36. #endif
  37. // 禁止多个实例的同时运行
  38. HANDLE hMutexOneInstance = ::CreateMutex(NULL, TRUE, _T(AfxGetAppName()));
  39. if(::GetLastError() == ERROR_ALREADY_EXISTS)
  40. {
  41. if(hMutexOneInstance) // Release the mutex
  42. {
  43. ::ReleaseMutex(hMutexOneInstance);
  44. }
  45. HWND hWndPrevious = ::GetWindow(::GetDesktopWindow(), GW_CHILD);
  46. while(::IsWindow(hWndPrevious))
  47. {
  48. // 检查窗口是否有预设的标记? 有,则是我们寻找的主窗口
  49. if(::GetProp(hWndPrevious, m_pszAppName))
  50. {
  51. // 主窗口已最小化,则恢复其大小
  52. if(::IsIconic(hWndPrevious)) ::ShowWindow(hWndPrevious, SW_RESTORE);
  53. ::SetForegroundWindow(hWndPrevious); // 将主窗激活
  54. ::SetForegroundWindow(::GetLastActivePopup(hWndPrevious)); // 将主窗的对话框激活
  55. return FALSE;
  56. } // end if
  57. hWndPrevious = ::GetWindow(hWndPrevious, GW_HWNDNEXT); // 继续寻找下一个窗口
  58. } // end while
  59. } // end if
  60. // 如果一个运行在 Windows XP 上的应用程序清单指定要
  61. // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
  62. //则需要 InitCommonControlsEx()。否则,将无法创建窗口。
  63. INITCOMMONCONTROLSEX InitCtrls;
  64. InitCtrls.dwSize = sizeof(InitCtrls);
  65. // 将它设置为包括所有要在应用程序中使用的
  66. // 公共控件类。
  67. InitCtrls.dwICC = ICC_WIN95_CLASSES;
  68. InitCommonControlsEx(&InitCtrls);
  69. CWinApp::InitInstance();
  70. if (!AfxSocketInit())
  71. {
  72. AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
  73. return FALSE;
  74. }
  75. AfxEnableControlContainer();
  76. // 标准初始化
  77. // 如果未使用这些功能并希望减小
  78. // 最终可执行文件的大小,则应移除下列
  79. // 不需要的特定初始化例程
  80. // 更改用于存储设置的注册表项
  81. // TODO: 应适当修改该字符串,
  82. // 例如修改为公司或组织名
  83. SetRegistryKey(_T("VoiceStation"));
  84. if(!CSystemLauncher::stage1Start())
  85. return FALSE;
  86. CDisplayWnd* pDisWnd = (CDisplayWnd *)RUNTIME_CLASS(CDisplayWnd)->CreateObject();
  87. m_pMainWnd = pDisWnd;
  88. pDisWnd->Show();
  89. CSystemLauncher::stage2Start();
  90. return TRUE;
  91. }