AppGlobalF.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "AppGlobalF.h"
  5. #include "ITSDbF.h"
  6. #include "ITSUtilF.h"
  7. #include "ITSLogF.h"
  8. #include <inifiles.hpp>
  9. //---------------------------------------------------------------------------
  10. #pragma package(smart_init)
  11. //---------------------------------------------------------------------------
  12. String CenterCd = ""; // 지역센터 코드
  13. String CenterId = ""; // 지역센터 아이디
  14. String CenterName = ""; // 지역센터 명칭
  15. int g_nPid = -1; // Application Process ID
  16. String g_sAppDir = ""; // Application Directory
  17. String g_sAppName= ""; // Program name
  18. String g_sCfgDir = ""; // Config File Directory
  19. String g_sLogDir = ""; // Program Log Directory
  20. String g_sTempDir = ""; // Program Temp Directory
  21. String g_sFormsDir = ""; // Program Forms Directory
  22. String g_sLangDir = "";
  23. APP_CONFIG g_AppCfg;
  24. LOGININFO *g_pLOGIN = NULL;
  25. LOG_INFO g_LogCfg;
  26. TITSLog *ITSLog = NULL;
  27. //---------------------------------------------------------------------------
  28. bool LoadDefaultConfigInfo(String ACfgFile/*=""*/)
  29. {
  30. String sCfgFile;
  31. TIniFile *pIniFile = NULL;
  32. String sIniFile = ChangeFileExt(ExtractFileName(Application->ExeName), ".ini");
  33. if (!ACfgFile.IsEmpty())
  34. sIniFile = ACfgFile + ".ini";
  35. sCfgFile = g_sCfgDir + sIniFile;
  36. g_AppCfg.sConfigFile = sCfgFile;
  37. g_AppCfg.AutoLogout.Enabled = false;
  38. g_AppCfg.AutoLogout.IntervalMin = 0;
  39. g_AppCfg.AutoLogout.LogoutExit = false;
  40. g_AppCfg.thr.pThread = NULL;
  41. g_AppCfg.thr.dwThreadId = 0;
  42. g_AppCfg.thr.nHandle = 0;
  43. g_AppCfg.thr.bRunning = false;
  44. g_AppCfg.bAppClose = false;
  45. try
  46. {
  47. String sTmp;
  48. pIniFile = new TIniFile(sCfgFile);
  49. g_AppCfg.sTitle = pIniFile->ReadString("APPLICATION", "TITLE", "광역교통정보 교통관리시스템");
  50. g_AppCfg.sProcessId = pIniFile->ReadString("APPLICATION", "PROCESSID", "999999");
  51. g_AppCfg.sLogDay = pIniFile->ReadString("APPLICATION", "LOGDAY", "");
  52. g_AppCfg.sSkinName = pIniFile->ReadString("APPLICATION", "SKINNAME", "Black");
  53. if (g_AppCfg.sSkinName.IsEmpty()) g_AppCfg.sSkinName = "Blue";
  54. sTmp = pIniFile->ReadString("APPLICATION", "SAVEFORM", "1");
  55. g_AppCfg.bSaveForm = (sTmp == "1") ? true : false;
  56. sTmp = "1";
  57. sTmp = pIniFile->ReadString("APPLICATION", "LOGINPROMPT", "1");
  58. g_AppCfg.bLoginPrompt = (sTmp == "1") ? true : false;
  59. g_AppCfg.sDefUseId = pIniFile->ReadString("APPLICATION", "LASTUSER", "");
  60. g_AppCfg.sLang = pIniFile->ReadString("APPLICATION", "LANGUAGE", "kr");
  61. g_AppCfg.sLang = g_AppCfg.sLang.LowerCase();
  62. if (g_AppCfg.sLang != "en" && g_AppCfg.sLang != "kr")
  63. g_AppCfg.sLang = "kr";
  64. g_AppCfg.bDebug = false;
  65. sTmp = pIniFile->ReadString("APPLICATION", "DEBUG", "0");
  66. if (sTmp == "1") g_AppCfg.bDebug = true;
  67. sTmp = pIniFile->ReadString("ALARM", "WINDOW", "1");
  68. g_AppCfg.Alarm.Window = (sTmp == "1") ? true : false;
  69. sTmp = pIniFile->ReadString("ALARM", "ENABLED", "0");
  70. g_AppCfg.Alarm.Enabled = (sTmp == "1") ? true : false;
  71. sTmp = pIniFile->ReadString("ALARM", "TIMEOUT", "10");
  72. g_AppCfg.Alarm.TimeOut = sTmp.ToIntDef(0);
  73. if (g_AppCfg.Alarm.TimeOut == 0) g_AppCfg.Alarm.TimeOut = 10;
  74. if (g_AppCfg.Alarm.TimeOut > 60) g_AppCfg.Alarm.TimeOut = 60;
  75. sTmp = pIniFile->ReadString("TEMPERATURE", "ALARMVALUE", "45");
  76. g_AppCfg.Temp.AlarmValue = sTmp.ToIntDef(0);
  77. sTmp = pIniFile->ReadString("INCIDENT", "WINDOW", "1");
  78. g_AppCfg.Incident.Window = (sTmp == "1") ? true : false;
  79. sTmp = pIniFile->ReadString("INCIDENT", "ENABLED", "0");
  80. g_AppCfg.Incident.Enabled = (sTmp == "1") ? true : false;
  81. sTmp = pIniFile->ReadString("INCIDENT", "TIMEOUT", "30");
  82. g_AppCfg.Incident.TimeOut = sTmp.ToIntDef(0);
  83. if (g_AppCfg.Incident.TimeOut == 0) g_AppCfg.Incident.TimeOut = 30;
  84. if (g_AppCfg.Incident.TimeOut > 300) g_AppCfg.Incident.TimeOut = 60;
  85. sTmp = pIniFile->ReadString("AUTOLOGOUT", "ENABLED", "0");
  86. g_AppCfg.AutoLogout.Enabled = (sTmp == "1") ? true : false;
  87. sTmp = pIniFile->ReadString("AUTOLOGOUT", "INTERVALMIN", "10");
  88. g_AppCfg.AutoLogout.IntervalMin = sTmp.ToIntDef(0);
  89. if (g_AppCfg.AutoLogout.IntervalMin == 0) g_AppCfg.AutoLogout.IntervalMin = 10;
  90. sTmp = pIniFile->ReadString("AUTOLOGOUT", "LOGOUTEXIT", "0");
  91. g_AppCfg.AutoLogout.LogoutExit = (sTmp == "1") ? true : false;
  92. String sSqlLog;
  93. g_AppCfg.itsdb.bSqlLog = false;
  94. g_AppCfg.itsdb.sProvider = pIniFile->ReadString("ITSDB", "PROVIDER", "OraOLEDB.Oracle.1");
  95. g_AppCfg.itsdb.sServerName = pIniFile->ReadString("ITSDB", "SERVERNAME", "HANTE");
  96. g_AppCfg.itsdb.sUserName = pIniFile->ReadString("ITSDB", "USERNAME", "hnits");
  97. g_AppCfg.itsdb.sPassword = pIniFile->ReadString("ITSDB", "PASSWORD", "hnits");
  98. //sSqlLog = pIniFile->ReadString("ITSDB", "SQLLOG", "0");
  99. //if (sSqlLog == "1") g_AppCfg.itsdb.bSqlLog = true;
  100. #if 0
  101. //세종시
  102. g_AppCfg.vmscam.sComModel = pIniFile->ReadString("VMSCAMERA", "COMPANY", "Samsung");
  103. g_AppCfg.vmscam.sDevModel = pIniFile->ReadString("VMSCAMERA", "DEVICE", "Samsung Network Camera/Encoder");
  104. #else
  105. g_AppCfg.vmscam.sComModel = pIniFile->ReadString("VMSCAMERA", "COMPANY", "Samsung");
  106. g_AppCfg.vmscam.sDevModel = pIniFile->ReadString("VMSCAMERA", "DEVICE", "SNP-3371TH");
  107. #endif
  108. CenterId = pIniFile->ReadString("CENTER", "CENTERID", "L01");
  109. CenterName = pIniFile->ReadString("CENTER", "CENTERNAME", "중앙센터");
  110. CenterCd = String(StrToInt(CenterId.SubString(2, 2)));
  111. g_AppCfg.flashmap.sMainMap = pIniFile->ReadString("FLASHMAP", "MAINMAP", "");
  112. g_AppCfg.flashmap.sLinkMap = pIniFile->ReadString("FLASHMAP", "LINKMAP", "");
  113. #if 0
  114. if (g_AppCfg.flashmap.sMainMap == "" ||
  115. g_AppCfg.flashmap.sLinkMap == "")
  116. {
  117. Application->MessageBox(L"지도 설정 정보를 읽어오는데 실패하였습니다.!!!!!!!!!!",
  118. L"환경설정 정보 로딩 오류!!!",
  119. MB_OK|MB_ICONERROR);
  120. }
  121. #endif
  122. g_AppCfg.flashmap.sMainMap = g_sAppDir + g_AppCfg.flashmap.sMainMap;
  123. g_AppCfg.flashmap.sLinkMap = g_sAppDir + g_AppCfg.flashmap.sLinkMap;
  124. }
  125. __finally
  126. {
  127. if (pIniFile) delete pIniFile;
  128. pIniFile = NULL;
  129. WriteConfigInfo(sIniFile, "AUTOLOGOUT", "LOGOUTEXIT", "0");
  130. }
  131. return true;
  132. }
  133. //---------------------------------------------------------------------------
  134. bool CMM_InsertLoginHist(PLOGININFO pLogin, bool ALogin)
  135. {
  136. String sQry;
  137. bool bResult= false;
  138. TADOQuery *adoQry = NULL;
  139. if (!pLogin) return false;
  140. if (ALogin)
  141. {
  142. sQry = "INSERT INTO TB_USERCNNC_HS ( \r\n"
  143. " LOGIN_HMS, \r\n"
  144. " USER_ID, \r\n"
  145. " LOGOUT_HMS \r\n"
  146. " ) \r\n"
  147. "VALUES ( \r\n"
  148. " :p01, \r\n"
  149. " :p02, \r\n"
  150. " NULL \r\n"
  151. " ) \r\n";
  152. }
  153. else
  154. {
  155. sQry = "UPDATE TB_USERCNNC_HS SET \r\n"
  156. " LOGOUT_HMS = TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS') \r\n"
  157. " WHERE LOGIN_HMS = :p01 \r\n"
  158. " AND USER_ID = :p02 \r\n";
  159. }
  160. try
  161. {
  162. try
  163. {
  164. adoQry = new TADOQuery(NULL);
  165. adoQry->Connection = ITSDb_GetConnection();
  166. ITSDb_GetConnection()->BeginTrans();
  167. adoQry->Close();
  168. adoQry->SQL->Text = sQry;
  169. adoQry->Parameters->ParamByName("p01")->Value = pLogin->sLoginTime;
  170. adoQry->Parameters->ParamByName("p02")->Value = pLogin->sUserId;
  171. int nRowCnt = adoQry->ExecSQL();
  172. ITSDb_GetConnection()->CommitTrans();
  173. bResult = nRowCnt > 1 ? true : false;
  174. }
  175. catch (Exception &exception)
  176. {
  177. ITSDb_GetConnection()->RollbackTrans();
  178. throw Exception(String(exception.ClassName()) + exception.Message);
  179. }
  180. catch (...)
  181. {
  182. ITSDb_GetConnection()->RollbackTrans();
  183. }
  184. }
  185. __finally
  186. {
  187. if (adoQry)
  188. {
  189. adoQry->Close();
  190. delete adoQry;
  191. }
  192. }
  193. return bResult;
  194. }
  195. //---------------------------------------------------------------------------
  196. /*
  197. * 환경설정 정보를 저장하는 함수.
  198. * arguments
  199. * String : RegisterKey 또는 파일이름
  200. * return
  201. * bool : 실패하면 false
  202. */
  203. bool WriteConfigInfo(String sCfgFile, String sTitle, String sItem, String sValue)
  204. {
  205. String ConfigFile;
  206. TIniFile *pIniFile = NULL;
  207. ConfigFile = sCfgFile;
  208. try
  209. {
  210. pIniFile = new TIniFile(ConfigFile);
  211. if (pIniFile == NULL)
  212. {
  213. return false;
  214. }
  215. pIniFile->WriteString(sTitle, sItem, sValue);
  216. }
  217. catch(...)
  218. {
  219. }
  220. if (pIniFile)
  221. {
  222. pIniFile->Free();
  223. pIniFile = NULL;
  224. }
  225. return true;
  226. }
  227. //---------------------------------------------------------------------------
  228. /*
  229. * 환경설정 정보를 읽어오는 함수.
  230. * arguments
  231. * String : RegisterKey 또는 파일이름
  232. * return
  233. * bool : 실패하면 false
  234. */
  235. bool ReadConfigInfo(String sCfgFile, String sTitle, String sItem, String &sValue)
  236. {
  237. bool bRes;
  238. String ConfigFile;
  239. TIniFile *pIniFile = NULL;
  240. bRes = false;
  241. ConfigFile = sCfgFile;
  242. try
  243. {
  244. pIniFile = new TIniFile(ConfigFile);
  245. if (pIniFile == NULL)
  246. {
  247. return bRes;
  248. }
  249. sValue = pIniFile->ReadString(sTitle, sItem, "");
  250. if (sValue != "")
  251. {
  252. bRes = true;
  253. }
  254. }
  255. catch(...)
  256. {
  257. }
  258. if (pIniFile)
  259. {
  260. pIniFile->Free();
  261. pIniFile = NULL;
  262. }
  263. return bRes;
  264. }
  265. //---------------------------------------------------------------------------
  266. void ShowErrorMsg(String ATitle, String AErrMsg)
  267. {
  268. Application->NormalizeTopMosts();
  269. Application->MessageBox(AErrMsg.c_str(), ATitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
  270. Application->RestoreTopMosts();
  271. }
  272. //----------------------------------------------------------------------------
  273. String APP_GetCode(TcxComboBox *ACombo)
  274. {
  275. String sReturn = "";
  276. if (ACombo->ItemIndex >= 0)
  277. {
  278. String sDesc = ACombo->Properties->Items->Strings[ACombo->ItemIndex];
  279. String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
  280. sDesc.Pos("]") - (sDesc.Pos("[") + 1));
  281. sReturn = sCode;
  282. }
  283. return sReturn;
  284. }
  285. //----------------------------------------------------------------------------
  286. String APP_GetCodeDesc(TcxComboBox *ACombo, String ACode)
  287. {
  288. String sReturn = "";
  289. for (int ii = 0; ii < ACombo->Properties->Items->Count; ii++)
  290. {
  291. String sDesc = ACombo->Properties->Items->Strings[ii];
  292. String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
  293. sDesc.Pos("]") - (sDesc.Pos("[") + 1));
  294. if (ACode == sCode)
  295. {
  296. sReturn = sDesc;
  297. break;
  298. }
  299. }
  300. return sReturn;
  301. }
  302. //----------------------------------------------------------------------------
  303. String APP_GetCodeName(TcxComboBox *ACombo, String ACode)
  304. {
  305. String sReturn = "";
  306. for (int ii = 0; ii < ACombo->Properties->Items->Count; ii++)
  307. {
  308. String sDesc = ACombo->Properties->Items->Strings[ii];
  309. String sName = sDesc.SubString(sDesc.Pos("]") + 1, sDesc.Length());
  310. String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
  311. sDesc.Pos("]") - (sDesc.Pos("[") + 1));
  312. if (ACode == sCode)
  313. {
  314. sReturn = sName.Trim();
  315. break;
  316. }
  317. }
  318. return sReturn;
  319. }
  320. //----------------------------------------------------------------------------
  321. String APP_GetCodeIdByName(TcxComboBox *ACombo, String AName)
  322. {
  323. String sReturn = "3";
  324. for (int ii = 0; ii < ACombo->Properties->Items->Count; ii++)
  325. {
  326. String sDesc = ACombo->Properties->Items->Strings[ii];
  327. String sName = sDesc.SubString(sDesc.Pos("]") + 1, sDesc.Length());
  328. String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
  329. sDesc.Pos("]") - (sDesc.Pos("[") + 1));
  330. if (sName.Trim() == AName.Trim())
  331. {
  332. sReturn = sCode;
  333. break;
  334. }
  335. }
  336. return sReturn;
  337. }
  338. //----------------------------------------------------------------------------
  339. String APP_GetCodeDefCode(TcxComboBox *ACombo)
  340. {
  341. String sReturn = "";
  342. if (ACombo->Properties->Items->Count > 0)
  343. {
  344. String sDesc = ACombo->Properties->Items->Strings[0];
  345. String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
  346. sDesc.Pos("]") - (sDesc.Pos("[") + 1));
  347. sReturn = sCode;
  348. }
  349. return sReturn;
  350. }
  351. //----------------------------------------------------------------------------
  352. String APP_GetCodeDefDesc(TcxComboBox *ACombo)
  353. {
  354. String sReturn = "";
  355. if (ACombo->Properties->Items->Count > 0)
  356. {
  357. String sDesc = ACombo->Properties->Items->Strings[0];
  358. sReturn = sDesc;
  359. }
  360. return sReturn;
  361. }
  362. //----------------------------------------------------------------------------
  363. int APP_SetCode(TcxComboBox *ACombo, String ACode)
  364. {
  365. int nItemIndex = -1;
  366. for (int ii = 0; ii < ACombo->Properties->Items->Count; ii++)
  367. {
  368. String sDesc = ACombo->Properties->Items->Strings[ii];
  369. String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
  370. sDesc.Pos("]") - (sDesc.Pos("[") + 1));
  371. if (ACode == sCode)
  372. {
  373. nItemIndex = ii;
  374. break;
  375. }
  376. }
  377. ACombo->ItemIndex = nItemIndex;
  378. return nItemIndex;
  379. }
  380. //----------------------------------------------------------------------------
  381. ULONG ProcIDFromWnd(HWND hwnd) // 윈도우 핸들로 프로세스 아이디 얻기
  382. {
  383. ULONG idProc;
  384. GetWindowThreadProcessId( hwnd, &idProc );
  385. return idProc;
  386. }
  387. //----------------------------------------------------------------------------
  388. HWND GetWinHandle(ULONG pid) // 프로세스 아이디로 윈도우 핸들 얻기
  389. {
  390. HWND tempHwnd = FindWindow(NULL,NULL); // 최상위 윈도우 핸들 찾기
  391. while( tempHwnd != NULL )
  392. {
  393. if( GetParent(tempHwnd) == NULL ) // 최상위 핸들인지 체크, 버튼 등도 핸들을 가질 수 있으므로 무시하기 위해
  394. if( pid == ProcIDFromWnd(tempHwnd) )
  395. return tempHwnd;
  396. tempHwnd = GetWindow(tempHwnd, GW_HWNDNEXT); // 다음 윈도우 핸들 찾기
  397. }
  398. return NULL;
  399. }
  400. //----------------------------------------------------------------------------
  401. String ITSUtil_FormatStr(String AStrDateTime, String AFormat)
  402. {
  403. #define SYEAR "-"
  404. #define STIME ":"
  405. #define SPACE " "
  406. String sDateTime = "";
  407. String sInData = AnsiString(AStrDateTime);
  408. //ShowMessage("IN: " + AStrDateTime + " " + sInData + " " + AFormat);
  409. if (sInData.IsEmpty())
  410. return sInData;
  411. //sDateTime = sInData;
  412. try
  413. {
  414. if (AFormat == STR_DATETIME)
  415. {
  416. if (sInData.Length() < 14) return sInData;
  417. sDateTime = sInData.SubString( 1, 4) + SYEAR +
  418. sInData.SubString( 5, 2) + SYEAR +
  419. sInData.SubString( 7, 2) + SPACE +
  420. sInData.SubString( 9, 2) + STIME +
  421. sInData.SubString(11, 2) + STIME +
  422. sInData.SubString(13, 2);
  423. }
  424. else
  425. if (AFormat == STR_HHNN)
  426. {
  427. if (sInData.Length() < 12) return sInData;
  428. sDateTime = sInData.SubString( 1, 4) + SYEAR +
  429. sInData.SubString( 5, 2) + SYEAR +
  430. sInData.SubString( 7, 2) + SPACE +
  431. sInData.SubString( 9, 2) + STIME +
  432. sInData.SubString(11, 2);
  433. }
  434. else
  435. if (AFormat == STR_DATEHOUR)
  436. {
  437. if (sInData.Length() < 10) return sInData;
  438. sDateTime = sInData.SubString( 1, 4) + SYEAR +
  439. sInData.SubString( 5, 2) + SYEAR +
  440. sInData.SubString( 7, 2) + SPACE +
  441. sInData.SubString( 9, 2);
  442. }
  443. else
  444. if (AFormat == STR_DATE)
  445. {
  446. if (sInData.Length() < 8) return sInData;
  447. sDateTime = sInData.SubString( 1, 4) + SYEAR +
  448. sInData.SubString( 5, 2) + SYEAR +
  449. sInData.SubString( 7, 2);
  450. }
  451. else
  452. if (AFormat == STR_MM)
  453. {
  454. if (sInData.Length() < 6) return sInData;
  455. sDateTime = sInData.SubString( 1, 4) + SYEAR +
  456. sInData.SubString( 5, 2);
  457. }
  458. else
  459. {
  460. sDateTime = sInData;
  461. }
  462. }
  463. catch(...)
  464. {
  465. }
  466. //ShowMessage("OUT: " + sDateTime);
  467. return sDateTime;
  468. }
  469. //---------------------------------------------------------------------------
  470. TColor g_DispColor[MAX_DISPCOLOR];
  471. void APP_InitDisplayColor()
  472. {
  473. g_DispColor[ 0] = Graphics::clBlue;
  474. g_DispColor[ 1] = Graphics::clRed;
  475. g_DispColor[ 2] = Graphics::clLime;
  476. g_DispColor[ 3] = Graphics::clMaroon;
  477. g_DispColor[ 4] = Graphics::clGreen;
  478. g_DispColor[ 5] = Graphics::clMenuHighlight;
  479. g_DispColor[ 6] = Graphics::clBackground;
  480. g_DispColor[ 7] = Graphics::clPurple;
  481. g_DispColor[ 8] = Graphics::clTeal;
  482. g_DispColor[ 9] = Graphics::clYellow;
  483. g_DispColor[10] = Graphics::clFuchsia;
  484. g_DispColor[11] = Graphics::clAqua;
  485. g_DispColor[12] = Graphics::clMoneyGreen;
  486. g_DispColor[13] = Graphics::clSkyBlue;
  487. g_DispColor[14] = Graphics::clRed;
  488. g_DispColor[15] = Graphics::clLime;
  489. g_DispColor[16] = Graphics::clYellow;
  490. g_DispColor[17] = Graphics::clBlue;
  491. g_DispColor[18] = Graphics::clFuchsia;
  492. g_DispColor[19] = Graphics::clAqua;
  493. g_DispColor[20] = Graphics::clMoneyGreen;
  494. g_DispColor[21] = Graphics::clActiveCaption;
  495. }
  496. //---------------------------------------------------------------------------
  497. TColor APP_GetDisplayColor(int ASeq)
  498. {
  499. return g_DispColor[ASeq % MAX_DISPCOLOR];
  500. }
  501. //---------------------------------------------------------------------------
  502. void APP_DelVmsSizeCombo(TcxComboBox *cboBox)
  503. {
  504. TStrings *pStrItems;
  505. TVmsSizeType *Ov;
  506. pStrItems = ((TcxComboBox *)cboBox)->Properties->Items;
  507. for (int ii = pStrItems->Count-1; ii >= 0; ii--)
  508. {
  509. Ov = (TVmsSizeType *)pStrItems->Objects[ii];
  510. if (Ov != NULL)
  511. {
  512. delete Ov;
  513. Ov = NULL;
  514. }
  515. }
  516. }
  517. //---------------------------------------------------------------------------
  518. TVmsSizeType* APP_GetVmsSizeTypeObject(TcxComboBox *cboBox)
  519. {
  520. TStrings *pStrItems;
  521. TVmsSizeType *Ov = NULL;
  522. int nItemIndex;
  523. pStrItems = ((TcxComboBox *)cboBox)->Properties->Items;
  524. nItemIndex= ((TcxComboBox *)cboBox)->ItemIndex;
  525. if (nItemIndex < 0)
  526. {
  527. return Ov;
  528. }
  529. Ov = (TVmsSizeType *)pStrItems->Objects[nItemIndex];
  530. if (Ov == NULL)
  531. {
  532. Ov = NULL;
  533. }
  534. return Ov;
  535. }
  536. //---------------------------------------------------------------------------
  537. void APP_ImageClear(TCanvas *c, int offX, int offY, int w, int h, TColor color)
  538. {
  539. try
  540. {
  541. c->Pen->Color = clWhite;
  542. c->Pen->Width = 0;
  543. c->Pen->Style = psClear;
  544. c->Brush->Style = bsSolid;
  545. c->Brush->Color = color;
  546. c->Rectangle(offX, offY, w+offX+2, h+offY+2);
  547. }
  548. catch(...)
  549. {
  550. }
  551. }
  552. //---------------------------------------------------------------------------
  553. #include <DateUtils.hpp>
  554. TDateTime APP_StrToDateTime(String AStrDateTime)
  555. {
  556. TDateTime dtReturnValue = NULL;
  557. if (AStrDateTime.IsEmpty()) return dtReturnValue;
  558. if (AStrDateTime.Length() != 14) return dtReturnValue;
  559. AnsiString sDateTime = AnsiString(AStrDateTime);
  560. try
  561. {
  562. #if 0
  563. sDateTime.printf(L"%s-%s-%s %s:%s:%s",
  564. AStrDateTime.SubString( 1, 4).c_str(),
  565. AStrDateTime.SubString( 5, 2).c_str(),
  566. AStrDateTime.SubString( 7, 2).c_str(),
  567. AStrDateTime.SubString( 9, 2).c_str(),
  568. AStrDateTime.SubString(11, 2).c_str(),
  569. AStrDateTime.SubString(13, 2).c_str());
  570. dtReturnValue = StrToDateTime(sDateTime);
  571. #endif
  572. // swscanf(sRgb.c_str(), L"%d,%d,%d", &r, &g, &b);
  573. int year, month, day, hour, minute, second;
  574. sscanf(sDateTime.c_str(), "%4d%2d%2d%2d%2d%2d", &year, &month, &day, &hour, &minute, &second);
  575. dtReturnValue = EncodeDateTime(year, month, day, hour, minute, second, 0);
  576. }
  577. catch(...)
  578. {
  579. }
  580. return dtReturnValue;
  581. }
  582. //---------------------------------------------------------------------------