ConfigurationPage.cpp 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. /****************************************************************/
  2. /* */
  3. /* ConfigurationPage.cpp */
  4. /* */
  5. /* Implementation of the CConfigurationPage class. */
  6. /* This class is a part of the FTP Server Application */
  7. /* */
  8. /* Programmed by LYFZ van der Meer */
  9. /* Copyright LYFZ Software Solutions 2002 */
  10. /* http://www.LYFZvandermeer.nl */
  11. /* */
  12. /* Last updated: 10 july 2002 */
  13. /* */
  14. /****************************************************************/
  15. #include "stdafx.h"
  16. #include "DBServer.h"
  17. #include "theDBServer.h"
  18. #include "ConfigurationPage.h"
  19. #include "UserAccountsDlg.h"
  20. #include "DBServerDlg.h"
  21. #include "InputCode.h"
  22. #ifdef _DEBUG
  23. #define new DEBUG_NEW
  24. #undef THIS_FILE
  25. static char THIS_FILE[] = __FILE__;
  26. #endif
  27. extern CtheDBServer theServer;
  28. extern CDBServer theApp;
  29. CConfigurationPage::CConfigurationPage() : CDialogResize(CConfigurationPage::IDD)
  30. {
  31. //{{AFX_DATA_INIT(CConfigurationPage)
  32. m_strGoodbyeMessage = _T("");
  33. m_bStartInTray = FALSE;
  34. m_strWelcomeMessage = _T("");
  35. m_bLaunchOnStartup = FALSE;
  36. m_bAutoActivate = FALSE;
  37. m_nLogLevel = 0;
  38. m_strApplicationName = _T("");
  39. m_version = _T("");
  40. m_versionno = _T("");
  41. m_company = _T("");
  42. //}}AFX_DATA_INIT
  43. m_bModified = FALSE;
  44. m_pImage=NULL;
  45. }
  46. CConfigurationPage::~CConfigurationPage()
  47. {
  48. // if( m_pImage ) delete m_pImage;m_pImage=NULL;
  49. }
  50. void CConfigurationPage::DoDataExchange(CDataExchange* pDX)
  51. {
  52. CDialogResize::DoDataExchange(pDX);
  53. //{{AFX_DATA_MAP(CConfigurationPage)
  54. DDX_Text(pDX, IDC_GOODBYE_MSG, m_strGoodbyeMessage);
  55. DDX_Check(pDX, IDC_START_IN_TRAY, m_bStartInTray);
  56. DDX_Text(pDX, IDC_WELCOME_MSG, m_strWelcomeMessage);
  57. DDX_Check(pDX, IDC_LAUNCH_ON_STARTUP, m_bLaunchOnStartup);
  58. DDX_Check(pDX, IDC_AUTOACTIVATE, m_bAutoActivate);
  59. DDX_CBIndex(pDX, IDC_LOGLEVEL, m_nLogLevel);
  60. DDX_Text(pDX, IDC_APPLICATIONNAME, m_strApplicationName);
  61. DDX_Text(pDX, IDC_PORT, m_version);
  62. DDX_Text(pDX, IDC_MAX_USERS, m_versionno);
  63. DDX_Text(pDX, IDC_TIMEOUT, m_company);
  64. //}}AFX_DATA_MAP
  65. }
  66. BEGIN_MESSAGE_MAP(CConfigurationPage, CDialogResize)
  67. //{{AFX_MSG_MAP(CConfigurationPage)
  68. ON_WM_DESTROY()
  69. ON_BN_CLICKED(IDC_LAUNCH_ON_STARTUP, OnLaunchOnStartup)
  70. ON_BN_CLICKED(IDC_VIEW, OnView)
  71. ON_BN_CLICKED(IDC_CLEAR, OnClear)
  72. ON_UPDATE_COMMAND_UI(IDC_APPLY, OnUpdateApply)
  73. ON_EN_CHANGE(IDC_PORT, OnSomethingChanged)
  74. ON_BN_CLICKED(IDC_APPLY, OnApply)
  75. ON_EN_CHANGE(IDC_MAX_USERS, OnSomethingChanged)
  76. ON_EN_CHANGE(IDC_TIMEOUT, OnSomethingChanged)
  77. ON_EN_CHANGE(IDC_WELCOME_MSG, OnSomethingChanged)
  78. ON_EN_CHANGE(IDC_GOODBYE_MSG, OnSomethingChanged)
  79. ON_CBN_SELCHANGE(IDC_LOGLEVEL, OnSomethingChanged)
  80. ON_BN_CLICKED(IDC_START_IN_TRAY, OnSomethingChanged)
  81. ON_BN_CLICKED(IDC_AUTOACTIVATE, OnSomethingChanged)
  82. ON_EN_CHANGE(IDC_APPLICATIONNAME, OnSomethingChanged)
  83. ON_WM_PAINT()
  84. //}}AFX_MSG_MAP
  85. END_MESSAGE_MAP()
  86. BEGIN_DLGRESIZE_MAP(CConfigurationPage)
  87. DLGRESIZE_CONTROL(IDC_WELCOME_MSG, DLSZ_SIZE_X)
  88. DLGRESIZE_CONTROL(IDC_GOODBYE_MSG, DLSZ_SIZE_X)
  89. DLGRESIZE_CONTROL(IDC_APPLICATIONNAME, DLSZ_SIZE_X)
  90. DLGRESIZE_CONTROL(IDC_VIEW, DLSZ_MOVE_X)
  91. DLGRESIZE_CONTROL(IDC_CLEAR, DLSZ_MOVE_X)
  92. DLGRESIZE_CONTROL(IDC_APPLY, DLSZ_MOVE_X | DLSZ_MOVE_Y)
  93. DLGRESIZE_CONTROL(IDC_IPLIST, DLSZ_SIZE_Y)
  94. END_DLGRESIZE_MAP()
  95. /********************************************************************/
  96. /* */
  97. /* Function name : OnInitDialog */
  98. /* Description : Called by the framework in response to the */
  99. /* WM_INITDIALOG message. */
  100. /* */
  101. /********************************************************************/
  102. extern void LoadImageFromRes(Image **img, LPCTSTR lpszResourceName, LPCTSTR ResourceType);
  103. BOOL CConfigurationPage::OnInitDialog()
  104. {
  105. CDialogResize::OnInitDialog();
  106. m_version="";
  107. #ifdef CHILD_VERSION
  108. m_version+="儿童";
  109. #else
  110. m_version+="婚纱";
  111. #endif
  112. #ifdef ENTERPRISE_VERSION
  113. m_version+="集团版";
  114. #endif
  115. #ifdef CONNCOUNT_VERSION
  116. CString temp;
  117. temp.Format ("座席版");
  118. m_version+=temp;
  119. #endif
  120. if(m_version=="婚纱" || m_version=="儿童")
  121. m_version+="全能版";
  122. m_versionno="00000";
  123. m_company="利亚方舟软件开发有限公司";
  124. m_strWelcomeMessage="www.lyfz.net 4006-067-068";
  125. UpdateData(false);
  126. LoadImageFromRes(&m_pImage, MAKEINTRESOURCE(IDR_PNG1), _T("png") );
  127. return TRUE;
  128. }
  129. /********************************************************************/
  130. /* */
  131. /* Function name : OnDestroy */
  132. /* Description : Called by the framework in response to the */
  133. /* WM_DESTROY message. */
  134. /* */
  135. /********************************************************************/
  136. void CConfigurationPage::OnDestroy()
  137. {
  138. CDialogResize::OnDestroy();
  139. }
  140. /********************************************************************/
  141. /* */
  142. /* Function name : OnLaunchOnStartup */
  143. /* Description : Launch application on startup? */
  144. /* */
  145. /********************************************************************/
  146. void CConfigurationPage::OnLaunchOnStartup()
  147. {
  148. UpdateData(TRUE);
  149. if (m_bLaunchOnStartup)
  150. {
  151. char szModuleFilename[MAX_PATH];
  152. // Get application's full path.
  153. ::GetModuleFileName(NULL, szModuleFilename, MAX_PATH);
  154. // create shortcut
  155. CreateStartMenuShortcut(szModuleFilename, "FTP Server", "Startup");
  156. }
  157. else
  158. {
  159. // remove shortcut
  160. RemoveStartMenuShortcut("FTP Server", "Startup");
  161. }
  162. OnSomethingChanged();
  163. }
  164. /********************************************************************/
  165. /* */
  166. /* Function name : OnView */
  167. /* Description : View log file contents. */
  168. /* */
  169. /********************************************************************/
  170. void CConfigurationPage::OnView() // 医院跟踪功能;
  171. {
  172. /* int ExecStatus = (UINT)ShellExecute(m_hWnd, "open", "NOTEPAD.EXE", (LPCTSTR)theApp.m_LogFile.m_FileName, 0, SW_SHOW);
  173. switch(ExecStatus)
  174. {
  175. case 0:
  176. MessageBox("Systeem is out of Memory","ShellExecute Error",MB_OK | MB_ICONEXCLAMATION);
  177. break;
  178. case 2:
  179. MessageBox("'NOTEPAD.EXE' is not found !","ShellExecute Error",MB_OK | MB_ICONEXCLAMATION);
  180. break;
  181. default:
  182. if (ExecStatus <= 32)
  183. MessageBox("Problem with executing of NOTEPAD.EXE","ShellExecute Error",MB_OK | MB_ICONEXCLAMATION);
  184. break;
  185. } */
  186. InputCode dlg;
  187. dlg.DoModal ();
  188. }
  189. /********************************************************************/
  190. /* */
  191. /* Function name : OnClear */
  192. /* Description : Clear log file contents. */
  193. /* */
  194. /********************************************************************/
  195. void CConfigurationPage::OnClear()
  196. {
  197. theApp.m_LogFile.Clear();
  198. }
  199. /********************************************************************/
  200. /* */
  201. /* Function name : OnApply */
  202. /* Description : Update FTP server settings. */
  203. /* */
  204. /********************************************************************/
  205. void CConfigurationPage::OnApply()
  206. {
  207. }
  208. /********************************************************************/
  209. /* */
  210. /* Function name : OnUpdateApply */
  211. /* Description : Update button state. */
  212. /* */
  213. /********************************************************************/
  214. void CConfigurationPage::OnUpdateApply(CCmdUI* pCmdUI)
  215. {
  216. pCmdUI->Enable(m_bModified);
  217. }
  218. /********************************************************************/
  219. /* */
  220. /* Function name : OnSomethingChanged */
  221. /* Description : Something has changed... */
  222. /* */
  223. /********************************************************************/
  224. void CConfigurationPage::OnSomethingChanged()
  225. {
  226. m_bModified = TRUE;
  227. UpdateDialogControls(this, FALSE);
  228. }
  229. void CConfigurationPage::OnPaint()
  230. {
  231. CPaintDC dc(this); // device context for painting
  232. // TODO: Add your message handler code here
  233. if(m_pImage)
  234. {
  235. CRect rc;
  236. GetDlgItem(IDC_STATIC1)->GetWindowRect(rc);
  237. ScreenToClient(rc);
  238. Graphics dcgraph(dc.GetSafeHdc());
  239. Rect destinationRect(rc.left , rc.top , rc.Width (), rc.Height ());
  240. dcgraph.DrawImage(m_pImage, destinationRect, 0,0,m_pImage->GetWidth(), m_pImage->GetHeight(),UnitPixel);
  241. }
  242. // Do not call CDialogResize::OnPaint() for painting messages
  243. }