VMSWBACKF.cpp 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "AppGlobalF.h"
  4. #include "ITSSkinF.h"
  5. #include "ITSUtilF.h"
  6. #include "WindowMsgF.h"
  7. #pragma hdrstop
  8. #include "VMSWBACKF.h"
  9. //---------------------------------------------------------------------------
  10. #pragma package(smart_init)
  11. #pragma link "cxContainer"
  12. #pragma link "cxControls"
  13. #pragma link "cxDropDownEdit"
  14. #pragma link "cxEdit"
  15. #pragma link "cxGraphics"
  16. #pragma link "cxLookAndFeelPainters"
  17. #pragma link "cxLookAndFeels"
  18. #pragma link "cxMaskEdit"
  19. #pragma link "cxTextEdit"
  20. #pragma link "dxSkinBlack"
  21. #pragma link "dxSkinMcSkin"
  22. #pragma link "dxSkinsCore"
  23. #pragma link "dxSkinBlue"
  24. #pragma link "dxSkinCaramel"
  25. #pragma link "dxSkinCoffee"
  26. #pragma link "dxSkinDarkRoom"
  27. #pragma link "dxSkinDarkSide"
  28. #pragma link "dxSkinFoggy"
  29. #pragma link "dxSkinGlassOceans"
  30. #pragma link "dxSkiniMaginary"
  31. #pragma link "dxSkinLilian"
  32. #pragma link "dxSkinLiquidSky"
  33. #pragma link "dxSkinLondonLiquidSky"
  34. #pragma link "dxSkinMoneyTwins"
  35. #pragma link "dxSkinOffice2007Black"
  36. #pragma link "dxSkinOffice2007Blue"
  37. #pragma link "dxSkinOffice2007Green"
  38. #pragma link "dxSkinOffice2007Pink"
  39. #pragma link "dxSkinOffice2007Silver"
  40. #pragma link "dxSkinOffice2010Black"
  41. #pragma link "dxSkinOffice2010Blue"
  42. #pragma link "dxSkinOffice2010Silver"
  43. #pragma link "dxSkinSeven"
  44. #pragma link "dxSkinSharp"
  45. #pragma link "dxSkinSilver"
  46. #pragma link "dxSkinStardust"
  47. #pragma resource "*.dfm"
  48. //TVMSBACKM *VMSBACKM = NULL;
  49. //---------------------------------------------------------------------------
  50. __fastcall TVMSWBACK::TVMSWBACK(TComponent* AOwner, HWND AHandle, String ACaption, int AScreenIdx)
  51. : TForm(AOwner)
  52. {
  53. FListForm = new TList();
  54. FScreenName = ACaption;
  55. FScreenIndex = AScreenIdx;
  56. FPlay = false;
  57. FMinWidth = 1000;
  58. FMinHeight = 1000;
  59. FMaxWidth = 0;
  60. FMaxHeight = 0;
  61. FWndParent = AHandle;
  62. Caption = ACaption;
  63. FDisplayMode = 0;
  64. FViewWidth = 320;
  65. }
  66. //---------------------------------------------------------------------------
  67. void __fastcall TVMSWBACK::FormCreate(TObject *Sender)
  68. {
  69. ScrollBox->ParentColor = true;
  70. }
  71. //---------------------------------------------------------------------------
  72. void __fastcall TVMSWBACK::FormShow(TObject *Sender)
  73. {
  74. Refresh();
  75. ScrollBox->Align = alClient;
  76. TmrShow->Enabled = true;
  77. }
  78. //---------------------------------------------------------------------------
  79. void __fastcall TVMSWBACK::TmrShowTimer(TObject *Sender)
  80. {
  81. TmrShow->Enabled = false;
  82. }
  83. //---------------------------------------------------------------------------
  84. void __fastcall TVMSWBACK::ScrollBoxClick(TObject *Sender)
  85. {
  86. ScrollBox->SetFocus();
  87. }
  88. //---------------------------------------------------------------------------
  89. void __fastcall TVMSWBACK::ScrollBoxMouseWheel(TObject *Sender, TShiftState Shift, int WheelDelta, TPoint &MousePos, bool &Handled)
  90. {
  91. ScrollBox->VertScrollBar->Position -= WheelDelta;
  92. }
  93. //---------------------------------------------------------------------------
  94. void __fastcall TVMSWBACK::SetPlay(bool APlay)
  95. {
  96. //AnsiString sTrace;
  97. //if (APlay) sTrace = Caption + " TVMSWBACK: SetPlay = Active";
  98. //else sTrace = Caption + " TVMSWBACK: SetPlay = DeActive";
  99. //ITSUtil_Trace(sTrace.c_str());
  100. try
  101. {
  102. LockWindowUpdate(Handle);
  103. for(int ii = 0; ii < FListForm->Count; ii++)
  104. {
  105. TVMSWCAM0 *pForm = (TVMSWCAM0*)FListForm->Items[ii];
  106. pForm->Play = APlay;
  107. }
  108. }
  109. __finally
  110. {
  111. LockWindowUpdate(0);
  112. }
  113. }
  114. //---------------------------------------------------------------------------
  115. void __fastcall TVMSWBACK::FormResize(TObject *Sender)
  116. {
  117. RecalFormPosition();
  118. }
  119. //---------------------------------------------------------------------------
  120. void __fastcall TVMSWBACK::RecalFormPosition()
  121. {
  122. int h = 0;
  123. for (int ii = 0; ii < FpnlForm->ControlCount; ii++)
  124. {
  125. if (FpnlForm->Controls[ii]->BoundsRect.Bottom > h)
  126. h = FpnlForm->Controls[ii]->BoundsRect.Bottom;
  127. }
  128. FpnlForm->Height = h+50;
  129. ScrollBox->HorzScrollBar->Range = 0;
  130. ScrollBox->VertScrollBar->Range = FpnlForm->Height;
  131. }
  132. //---------------------------------------------------------------------------
  133. void __fastcall TVMSWBACK::RefreshVmsStatus()
  134. {
  135. try
  136. {
  137. for(int ii = 0; ii < FListForm->Count; ii++)
  138. {
  139. TVMSWCAM0 *pForm = (TVMSWCAM0*)FListForm->Items[ii];
  140. pForm->RefreshVmsStatus();
  141. }
  142. }
  143. catch(Exception &e)
  144. {
  145. }
  146. }
  147. //---------------------------------------------------------------------------
  148. void __fastcall TVMSWBACK::RefreshVmsMessage()
  149. {
  150. try
  151. {
  152. for(int ii = 0; ii < FListForm->Count; ii++)
  153. {
  154. TVMSWCAM0 *pForm = (TVMSWCAM0*)FListForm->Items[ii];
  155. pForm->RefreshVmsMessage();
  156. }
  157. }
  158. catch(Exception &e)
  159. {
  160. }
  161. }
  162. //---------------------------------------------------------------------------
  163. bool __fastcall TVMSWBACK::AddVmsForm(String AVmsNmbr)
  164. {
  165. TVmsCtlr *pObj = VmsCtlrManager->FLists.Find(AVmsNmbr);
  166. if (!pObj) return false;
  167. if (pObj->WIDTH > FMaxWidth) FMaxWidth = pObj->WIDTH;
  168. if (pObj->WIDTH < FMinWidth) FMinWidth = pObj->WIDTH;
  169. if (pObj->HEIGHT > FMaxHeight) FMaxHeight = pObj->HEIGHT;
  170. if (pObj->HEIGHT < FMinHeight) FMinHeight = pObj->HEIGHT;
  171. TVMSWCAM0 *pForm = new TVMSWCAM0(this, pObj);
  172. pForm->SetFormSize(pObj->WIDTH);
  173. pForm->Parent = FpnlForm;
  174. pForm->FScrollBox = ScrollBox;
  175. pForm->FWndParent = Handle;
  176. pForm->Show();
  177. FListForm->Add(pForm);
  178. return true;
  179. }
  180. //---------------------------------------------------------------------------
  181. void __fastcall TVMSWBACK::FpnlFormClick(TObject *Sender)
  182. {
  183. ScrollBox->SetFocus();
  184. }
  185. //---------------------------------------------------------------------------
  186. void __fastcall TVMSWBACK::OnVmsSelectMessage(TMessage &Msg)
  187. {
  188. if (FWndParent)
  189. {
  190. POST_MSG(FWndParent, WM_VMS_SELECT, (WPARAM)Msg.WParam, (LPARAM)Msg.LParam);
  191. }
  192. }
  193. //---------------------------------------------------------------------------
  194. void __fastcall TVMSWBACK::OnVmsSelectDblClickMessage(TMessage &Msg)
  195. {
  196. if (FWndParent)
  197. {
  198. POST_MSG(FWndParent, WM_VMS_SELECT_DBLCLICK, (WPARAM)Msg.WParam, (LPARAM)Msg.LParam);
  199. }
  200. }
  201. //---------------------------------------------------------------------------
  202. void __fastcall TVMSWBACK::FormDestroy(TObject *Sender)
  203. {
  204. ClearFormList();
  205. SAFE_DELETE(FListForm);
  206. }
  207. //---------------------------------------------------------------------------
  208. void __fastcall TVMSWBACK::SetFormSize(int AWidth)
  209. {
  210. try
  211. {
  212. LockWindowUpdate(Handle);
  213. for(int ii = 0; ii < FListForm->Count; ii++)
  214. {
  215. TVMSWCAM0 *pForm = (TVMSWCAM0*)FListForm->Items[ii];
  216. pForm->SetFormSize(AWidth);
  217. FViewWidth = pForm->Width;
  218. }
  219. }
  220. __finally
  221. {
  222. LockWindowUpdate(0);
  223. }
  224. }
  225. //---------------------------------------------------------------------------
  226. void __fastcall TVMSWBACK::ClearFormList()
  227. {
  228. try
  229. {
  230. LockWindowUpdate(Handle);
  231. for(int ii = 0; ii < FListForm->Count; ii++)
  232. {
  233. TVMSWCAM0 *pForm = (TVMSWCAM0*)FListForm->Items[ii];
  234. //pForm->CamStop();
  235. pForm->Hide();
  236. SAFE_DELETE(pForm);
  237. }
  238. FListForm->Clear();
  239. }
  240. __finally
  241. {
  242. LockWindowUpdate(0);
  243. }
  244. }
  245. //---------------------------------------------------------------------------
  246. void __fastcall TVMSWBACK::CamPlay()
  247. {
  248. try
  249. {
  250. LockWindowUpdate(Handle);
  251. for(int ii = 0; ii < FListForm->Count; ii++)
  252. {
  253. TVMSWCAM0 *pForm = (TVMSWCAM0*)FListForm->Items[ii];
  254. pForm->CamPlay();
  255. }
  256. }
  257. __finally
  258. {
  259. LockWindowUpdate(0);
  260. }
  261. }
  262. //---------------------------------------------------------------------------
  263. void __fastcall TVMSWBACK::CamStop()
  264. {
  265. try
  266. {
  267. LockWindowUpdate(Handle);
  268. for(int ii = 0; ii < FListForm->Count; ii++)
  269. {
  270. TVMSWCAM0 *pForm = (TVMSWCAM0*)FListForm->Items[ii];
  271. pForm->CamStop();
  272. }
  273. }
  274. __finally
  275. {
  276. LockWindowUpdate(0);
  277. }
  278. }
  279. //---------------------------------------------------------------------------