IdAntiFreeze.pas 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. {
  2. $Project$
  3. $Workfile$
  4. $Revision$
  5. $DateUTC$
  6. $Id$
  7. This file is part of the Indy (Internet Direct) project, and is offered
  8. under the dual-licensing agreement described on the Indy website.
  9. (http://www.indyproject.org/)
  10. Copyright:
  11. (c) 1993-2005, Chad Z. Hower and the Indy Pit Crew. All rights reserved.
  12. }
  13. {
  14. $Log$
  15. }
  16. {
  17. Rev 1.6 2004.02.03 4:16:42 PM czhower
  18. For unit name changes.
  19. Rev 1.5 2004.01.01 3:13:32 PM czhower
  20. Updated comment.
  21. Rev 1.4 2003.12.31 10:30:24 PM czhower
  22. Comment update.
  23. Rev 1.3 2003.12.31 7:25:14 PM czhower
  24. Now works in .net
  25. Rev 1.2 10/4/2003 9:52:08 AM GGrieve
  26. add IdCoreGlobal to uses list
  27. Rev 1.1 2003.10.01 1:12:30 AM czhower
  28. .Net
  29. Rev 1.0 11/13/2002 08:37:36 AM JPMugaas
  30. }
  31. unit IdAntiFreeze;
  32. {
  33. NOTE - This unit must NOT appear in any Indy uses clauses. This is a ONE way
  34. relationship and is linked in IF the user uses this component. This is done to
  35. preserve the isolation from the massive FORMS unit.
  36. Because it links to Forms:
  37. - The Application.ProcessMessages cannot be done in IdCoreGlobal as an OS
  38. independent function, and thus this unit is allowed to violate the IFDEF
  39. restriction.
  40. }
  41. interface
  42. {$I IdCompilerDefines.inc}
  43. uses
  44. Classes,
  45. IdAntiFreezeBase,
  46. IdBaseComponent;
  47. { Directive needed for generating a legacy non-UnitScoped C++Builder HPP }
  48. {$IFDEF HAS_DIRECTIVE_HPPEMIT_LEGACYHPP}
  49. {$HPPEMIT LEGACYHPP}
  50. {$ENDIF}
  51. { Directive needed for C++Builder HPP to force static linking to this unit }
  52. {$IFDEF HAS_DIRECTIVE_HPPEMIT_LINKUNIT}
  53. {$HPPEMIT LINKUNIT}
  54. {$ELSE}
  55. {$IFDEF WINDOWS}
  56. {$HPPEMIT '#pragma link "IdAntiFreeze"'} {Do not Localize}
  57. {$ENDIF}
  58. {$IFDEF UNIX}
  59. {$HPPEMIT '#pragma link "IdAntiFreeze.o"'} {Do not Localize}
  60. {$ENDIF}
  61. {$ENDIF}
  62. {$IFDEF VCL_10_3_OR_ABOVE}
  63. // until Delphi 10.3.2 can be detected in IdCompilerDefines.inc,
  64. // use {$IF DECLARED(...) here to enable the new platform values...)
  65. {$IFNDEF VCL_10_3_UPDATE2_OR_ABOVE}
  66. {$IF DECLARED(pidAllPlatforms)}
  67. {$DEFINE HAS_ComponentPlatformsAttribute_AllPlatforms}
  68. {$DEFINE HAS_ComponentPlatformsAttribute_OSX64}
  69. {$IFEND}
  70. {$ENDIF}
  71. {$ENDIF}
  72. type
  73. {$IFDEF HAS_ComponentPlatformsAttribute}
  74. [ComponentPlatformsAttribute(
  75. {$IFDEF HAS_ComponentPlatformsAttribute_AllPlatforms}pidAllPlatforms
  76. {$ELSE}
  77. pidWin32
  78. {$IFDEF HAS_ComponentPlatformsAttribute_Win64} or pidWin64{$ENDIF}
  79. {$IFDEF HAS_ComponentPlatformsAttribute_OSX32} or pidOSX32{$ENDIF}
  80. {$IFDEF HAS_ComponentPlatformsAttribute_iOS_Simulator32}or pidiOSSimulator32{$ELSE}
  81. {$IFDEF HAS_ComponentPlatformsAttribute_iOS_Simulator} or pidiOSSimulator{$ENDIF}{$ENDIF}
  82. {$IFDEF HAS_ComponentPlatformsAttribute_Android32Arm} or pidAndroid32Arm{$ELSE}
  83. {$IFDEF HAS_ComponentPlatformsAttribute_Android} or pidAndroid{$ENDIF}{$ENDIF}
  84. {$IFDEF HAS_ComponentPlatformsAttribute_Linux32} or pidLinux32{$ENDIF}
  85. {$IFDEF HAS_ComponentPlatformsAttribute_iOS_Device32} or pidiOSDevice32{$ELSE}
  86. {$IFDEF HAS_ComponentPlatformsAttribute_iOS_Device} or pidiOSDevice{$ENDIF}{$ENDIF}
  87. {$IFDEF HAS_ComponentPlatformsAttribute_Linux64} or pidLinux64{$ENDIF}
  88. {$IFDEF HAS_ComponentPlatformsAttribute_WinNX32} or pidWinNX32{$ENDIF}
  89. {$IFDEF HAS_ComponentPlatformsAttribute_WinIoT32} or pidWinIoT32{$ENDIF}
  90. {$IFDEF HAS_ComponentPlatformsAttribute_iOS_Device64} or pidiOSDevice64{$ENDIF}
  91. {$IFDEF HAS_ComponentPlatformsAttribute_WinARM32} or pidWinARM32{$ELSE}
  92. {$IFDEF HAS_ComponentPlatformsAttribute_WinARM} or pidWinARM{$ENDIF}{$ENDIF}
  93. {$IFDEF HAS_ComponentPlatformsAttribute_OSXNX64} or pidOSXNX64{$ELSE}
  94. {$IFDEF HAS_ComponentPlatformsAttribute_OSX64} or pidOSX64{$ENDIF}{$ENDIF}
  95. {$IFDEF HAS_ComponentPlatformsAttribute_Linux32Arm} or pidLinux32Arm{$ENDIF}
  96. {$IFDEF HAS_ComponentPlatformsAttribute_Linux64Arm} or pidLinux64Arm{$ENDIF}
  97. {$IFDEF HAS_ComponentPlatformsAttribute_Android64Arm} or pidAndroid64Arm{$ELSE}
  98. {$IFDEF HAS_ComponentPlatformsAttribute_Android64} or pidAndroid64{$ENDIF}{$ENDIF}
  99. {$IFDEF HAS_ComponentPlatformsAttribute_iOS_Simulator64} or pidiOSSimulator64{$ENDIF}
  100. {$ENDIF}
  101. )]
  102. {$ENDIF}
  103. TIdAntiFreeze = class(TIdAntiFreezeBase)
  104. public
  105. procedure Process; override;
  106. end;
  107. implementation
  108. uses
  109. {$IFDEF WIDGET_KYLIX}
  110. QForms,
  111. {$ENDIF}
  112. {$IFDEF WIDGET_VCL_LIKE}
  113. Forms,
  114. {$ENDIF}
  115. {$IFDEF WINDOWS}
  116. {$IFNDEF FMX}
  117. Messages,
  118. Windows,
  119. {$ENDIF}
  120. {$ENDIF}
  121. {$IFDEF WIDGET_WINFORMS}
  122. System.Windows.Forms,
  123. {$ENDIF}
  124. IdGlobal;
  125. {$IFDEF UNIX}
  126. procedure TIdAntiFreeze.Process;
  127. begin
  128. //TODO: Handle ApplicationHasPriority
  129. Application.ProcessMessages;
  130. end;
  131. {$ENDIF}
  132. {$IFDEF WINDOWS}
  133. {$IFNDEF FMX}
  134. procedure TIdAntiFreeze.Process;
  135. var
  136. LMsg: TMsg;
  137. begin
  138. if ApplicationHasPriority then begin
  139. Application.ProcessMessages;
  140. end else begin
  141. // This guarantees it will not ever call Application.Idle
  142. if PeekMessage(LMsg, 0, 0, 0, PM_NOREMOVE) then begin
  143. Application.HandleMessage;
  144. end;
  145. end;
  146. end;
  147. {$ELSE}
  148. procedure TIdAntiFreeze.Process;
  149. begin
  150. //TODO: Handle ApplicationHasPriority
  151. Application.ProcessMessages;
  152. end;
  153. {$ENDIF}
  154. {$ENDIF}
  155. {$IFDEF WIDGET_WINFORMS}
  156. procedure TIdAntiFreeze.Process;
  157. begin
  158. //TODO: Handle ApplicationHasPriority
  159. Application.DoEvents;
  160. end;
  161. {$ENDIF}
  162. end.