cstm1dlg.cpp
上传用户:hzhsqp
上传日期:2007-01-06
资源大小:1600k
文件大小:6k
源码类别:

IP电话/视频会议

开发平台:

Visual C++

  1. // cstm1dlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "MsDevWizard.h"
  5. #include "cstm1dlg.h"
  6. #include "MsDevWizardaw.h"
  7. #include <stdlib.h>
  8. #include <time.h>
  9. #include <io.h>
  10. #ifdef _PSEUDO_DEBUG
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CCustom1Dlg dialog
  16. CCustom1Dlg::CCustom1Dlg()
  17. : CAppWizStepDlg(CCustom1Dlg::IDD)
  18. {
  19. //{{AFX_DATA_INIT(CCustom1Dlg)
  20. m_class_name = _T("");
  21. m_manufacturer = _T("Equivalence");
  22. m_product_name = _T("");
  23. m_product_type = 0;
  24. m_exe_name = _T("");
  25. m_pwlib_dir = _T("");
  26. m_use_dlls = FALSE;
  27. //}}AFX_DATA_INIT
  28. }
  29. void CCustom1Dlg::DoDataExchange(CDataExchange* pDX)
  30. {
  31. CAppWizStepDlg::DoDataExchange(pDX);
  32. //{{AFX_DATA_MAP(CCustom1Dlg)
  33. DDX_Text(pDX, IDC_CLASS_NAME, m_class_name);
  34. DDX_Text(pDX, IDC_MANUFACTURER, m_manufacturer);
  35. DDX_Text(pDX, IDC_PRODUCT_NAME, m_product_name);
  36. DDX_Radio(pDX, IDC_TEXT_ONLY, m_product_type);
  37. DDX_Text(pDX, IDC_EXE_NAME, m_exe_name);
  38. DDX_Text(pDX, IDC_PWLIB_DIR, m_pwlib_dir);
  39. DDX_Check(pDX, IDC_USE_DLL, m_use_dlls);
  40. //}}AFX_DATA_MAP
  41. }
  42. static void SetDictionaryKey(const char * key, BOOL value)
  43. {
  44.   if (value)
  45.     MsDevWizardaw.m_Dictionary[key] = key;
  46.   else
  47.     MsDevWizardaw.m_Dictionary.RemoveKey(key);
  48. }
  49. // This is called whenever the user presses Next, Back, or Finish with this step
  50. //  present.  Do all validation & data exchange from the dialog in this function.
  51. BOOL CCustom1Dlg::OnDismiss()
  52. {
  53. if (!UpdateData(TRUE))
  54. return FALSE;
  55.         // Strip .exe off end of string (if there is one)
  56.         CString lower_exe = m_exe_name;
  57.         lower_exe.MakeLower();
  58.         int pos = lower_exe.Find(".exe");
  59.         if (pos >= 0)
  60.           m_exe_name = m_exe_name.Mid(pos);
  61.         static const struct {
  62.           const char * product_type;
  63.           const char * parent_app_class;
  64.           const char * parent_win_class;
  65.           const char * header_file;
  66.           BOOL is_gui;
  67.           BOOL is_service;
  68.           BOOL has_http;
  69.         } product_type_strings[] = {
  70.           { "Text Only", "PProcess",            "",                "ptlib.h", FALSE, FALSE, FALSE },
  71.           { "GUI",       "PApplication",        "PTopLevelWindow", "pwlib.h", TRUE,  FALSE, FALSE },
  72.           { "GUI",       "PApplication",        "PMDIFrameWindow", "pwlib.h", TRUE,  FALSE, FALSE },
  73.           { "Service",   "PServiceProcess",     "",                "ptlib.h", FALSE, TRUE,  FALSE },
  74.           { "Service",   "PHTTPServiceProcess", "",                "ptlib.h", FALSE, TRUE,  TRUE  }
  75.         };
  76. MsDevWizardaw.m_Dictionary["PRODUCT_TYPE"] = product_type_strings[m_product_type].product_type;
  77. MsDevWizardaw.m_Dictionary["PRODUCT_NAME"] = m_product_name;
  78. MsDevWizardaw.m_Dictionary["MANUFACTURER"] = m_manufacturer;
  79. MsDevWizardaw.m_Dictionary["EXE_NAME"] = m_exe_name;
  80. MsDevWizardaw.m_Dictionary["APP_CLASS_NAME"] = m_class_name;
  81. MsDevWizardaw.m_Dictionary["PARENT_APP_CLASS"] = product_type_strings[m_product_type].parent_app_class;
  82. MsDevWizardaw.m_Dictionary["PARENT_WIN_CLASS"] = product_type_strings[m_product_type].parent_win_class;
  83. MsDevWizardaw.m_Dictionary["HEADER_FILE"] = product_type_strings[m_product_type].header_file;
  84.         SetDictionaryKey("IS_GUI", product_type_strings[m_product_type].is_gui);
  85.         SetDictionaryKey("IS_SERVICE", product_type_strings[m_product_type].is_service);
  86.         SetDictionaryKey("HAS_HTTP", product_type_strings[m_product_type].has_http);
  87.         srand(clock());
  88. MsDevWizardaw.m_Dictionary["SIGNATURE_KEY"].Format(
  89.                         "%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u",
  90.                         rand()&255, rand()&255, rand()&255, rand()&255,
  91.                         rand()&255, rand()&255, rand()&255, rand()&255,
  92.                         rand()&255, rand()&255, rand()&255, rand()&255,
  93.                         rand()&255, rand()&255, rand()&255, rand()&255);
  94. MsDevWizardaw.m_Dictionary["APPLICATION_KEY"].Format(
  95.                         "%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u",
  96.                         rand()&255, rand()&255, rand()&255, rand()&255,
  97.                         rand()&255, rand()&255, rand()&255, rand()&255,
  98.                         rand()&255, rand()&255, rand()&255, rand()&255,
  99.                         rand()&255, rand()&255, rand()&255, rand()&255);
  100.         MsDevWizardaw.m_has_gui = product_type_strings[m_product_type].is_gui;
  101.         MsDevWizardaw.m_is_service = product_type_strings[m_product_type].is_service;
  102.         MsDevWizardaw.m_has_http = product_type_strings[m_product_type].has_http;
  103.         MsDevWizardaw.m_use_dlls = m_use_dlls;
  104.         MsDevWizardaw.m_pwlib_dir = m_pwlib_dir;
  105. return TRUE; // return FALSE if the dialog shouldn't be dismissed
  106. }
  107. BEGIN_MESSAGE_MAP(CCustom1Dlg, CAppWizStepDlg)
  108. //{{AFX_MSG_MAP(CCustom1Dlg)
  109. //}}AFX_MSG_MAP
  110. END_MESSAGE_MAP()
  111. /////////////////////////////////////////////////////////////////////////////
  112. // CCustom1Dlg message handlers
  113. BOOL CCustom1Dlg::OnInitDialog() 
  114. {
  115. CAppWizStepDlg::OnInitDialog();
  116. m_class_name = MsDevWizardaw.m_Dictionary["Safe_root"];
  117. m_product_name = MsDevWizardaw.m_Dictionary["Root"];
  118. m_exe_name = MsDevWizardaw.m_Dictionary["Root"];
  119.         m_pwlib_dir = "";
  120.         CString full_dir = MsDevWizardaw.m_Dictionary["FULL_DIR_PATH"];
  121.         full_dir.MakeLower();
  122.         int pos;
  123.         if ((pos = full_dir.Find("\pwlib\")) >= 0) {
  124.           pos += 6;
  125.           do {
  126.             full_dir = full_dir.Mid(pos+1);
  127.             if (!full_dir.IsEmpty())
  128.               m_pwlib_dir += "..\";
  129.           } while ((pos = full_dir.Find('\')) >= 0);
  130.         }
  131.         else {
  132.           const char * pwlib_dir = getenv("PWLIB_DIR");
  133.           if (pwlib_dir == NULL)
  134.             pwlib_dir = "c:\pwlib";
  135.           if (_access(pwlib_dir, 0) == 0)
  136.             m_pwlib_dir = pwlib_dir;
  137.         }
  138.         UpdateData(FALSE);
  139. return TRUE;  // return TRUE unless you set the focus to a control
  140.               // EXCEPTION: OCX Property Pages should return FALSE
  141. }