ConfigurationPage.cpp 8.2 KB

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