IdAntiFreeze.pas 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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} // TODO: does RTLVersion1032 exist?
  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_AndroidArm32} or pidAndroidArm32{$ELSE}
  83. {$IFDEF HAS_ComponentPlatformsAttribute_Android32Arm} or pidAndroid32Arm{$ELSE}
  84. {$IFDEF HAS_ComponentPlatformsAttribute_Android} or pidAndroid{$ENDIF}{$ENDIF}{$ENDIF}
  85. {$IFDEF HAS_ComponentPlatformsAttribute_Linux32} or pidLinux32{$ENDIF}
  86. {$IFDEF HAS_ComponentPlatformsAttribute_iOS_Device32} or pidiOSDevice32{$ELSE}
  87. {$IFDEF HAS_ComponentPlatformsAttribute_iOS_Device} or pidiOSDevice{$ENDIF}{$ENDIF}
  88. {$IFDEF HAS_ComponentPlatformsAttribute_Linux64} or pidLinux64{$ENDIF}
  89. {$IFDEF HAS_ComponentPlatformsAttribute_WinNX32} or pidWinNX32{$ENDIF}
  90. {$IFDEF HAS_ComponentPlatformsAttribute_WinIoT32} or pidWinIoT32{$ENDIF}
  91. {$IFDEF HAS_ComponentPlatformsAttribute_iOS_Device64} or pidiOSDevice64{$ENDIF}
  92. {$IFDEF HAS_ComponentPlatformsAttribute_WinARM32} or pidWinARM32{$ELSE}
  93. {$IFDEF HAS_ComponentPlatformsAttribute_Win32ARM} or pidWin32ARM{$ELSE}
  94. {$IFDEF HAS_ComponentPlatformsAttribute_WinARM} or pidWinARM{$ENDIF}{$ENDIF}{$ENDIF}
  95. {$IFDEF HAS_ComponentPlatformsAttribute_OSXNX64} or pidOSXNX64{$ELSE}
  96. {$IFDEF HAS_ComponentPlatformsAttribute_OSX64} or pidOSX64{$ENDIF}{$ENDIF}
  97. {$IFDEF HAS_ComponentPlatformsAttribute_LinuxArm32} or pidLinuxArm32{$ELSE}
  98. {$IFDEF HAS_ComponentPlatformsAttribute_Linux32Arm} or pidLinux32Arm{$ENDIF}{$ENDIF}
  99. {$IFDEF HAS_ComponentPlatformsAttribute_LinuxArm64} or pidLinuxArm64{$ELSE}
  100. {$IFDEF HAS_ComponentPlatformsAttribute_Linux64Arm} or pidLinux64Arm{$ENDIF}{$ENDIF}
  101. {$IFDEF HAS_ComponentPlatformsAttribute_AndroidArm64} or pidAndroidArm64{$ELSE}
  102. {$IFDEF HAS_ComponentPlatformsAttribute_Android64Arm} or pidAndroid64Arm{$ELSE}
  103. {$IFDEF HAS_ComponentPlatformsAttribute_Android64} or pidAndroid64{$ENDIF}{$ENDIF}{$ENDIF}
  104. {$IFDEF HAS_ComponentPlatformsAttribute_iOS_Simulator64} or pidiOSSimulator64{$ENDIF}
  105. {$IFDEF HAS_ComponentPlatformsAttribute_OSXArm64} or pidOSXArm64{$ENDIF}
  106. {$IFDEF HAS_ComponentPlatformsAttribute_WinArm64} or pidWinArm64{$ENDIF}
  107. {$IFDEF HAS_ComponentPlatformsAttribute_iOS_SimulatorArm64} or pidiOSSimulatorArm64{$ENDIF}
  108. {$ENDIF}
  109. )]
  110. {$ENDIF}
  111. TIdAntiFreeze = class(TIdAntiFreezeBase)
  112. public
  113. procedure Process; override;
  114. end;
  115. implementation
  116. uses
  117. {$IFDEF WIDGET_KYLIX}
  118. QForms,
  119. {$ENDIF}
  120. {$IFDEF WIDGET_VCL_LIKE}
  121. Forms,
  122. {$ENDIF}
  123. {$IFDEF WINDOWS}
  124. {$IFNDEF FMX}
  125. Messages,
  126. Windows,
  127. {$ENDIF}
  128. {$ENDIF}
  129. {$IFDEF WIDGET_WINFORMS}
  130. System.Windows.Forms,
  131. {$ENDIF}
  132. IdGlobal;
  133. {$IFDEF UNIX}
  134. procedure TIdAntiFreeze.Process;
  135. begin
  136. //TODO: Handle ApplicationHasPriority
  137. Application.ProcessMessages;
  138. end;
  139. {$ENDIF}
  140. {$IFDEF WINDOWS}
  141. {$IFNDEF FMX}
  142. procedure TIdAntiFreeze.Process;
  143. var
  144. LMsg: TMsg;
  145. begin
  146. if ApplicationHasPriority then begin
  147. Application.ProcessMessages;
  148. end else begin
  149. // This guarantees it will not ever call Application.Idle
  150. if PeekMessage(LMsg, 0, 0, 0, PM_NOREMOVE) then begin
  151. Application.HandleMessage;
  152. end;
  153. end;
  154. end;
  155. {$ELSE}
  156. procedure TIdAntiFreeze.Process;
  157. begin
  158. //TODO: Handle ApplicationHasPriority
  159. Application.ProcessMessages;
  160. end;
  161. {$ENDIF}
  162. {$ENDIF}
  163. {$IFDEF WIDGET_WINFORMS}
  164. procedure TIdAntiFreeze.Process;
  165. begin
  166. //TODO: Handle ApplicationHasPriority
  167. Application.DoEvents;
  168. end;
  169. {$ENDIF}
  170. end.