IdAntiFreeze.pas 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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. { Directive needed for generating a legacy non-UnitScoped C++Builder HPP }
  47. {$IFDEF HAS_DIRECTIVE_HPPEMIT_LEGACYHPP}
  48. {$HPPEMIT LEGACYHPP}
  49. {$ENDIF}
  50. { Directive needed for C++Builder HPP to force static linking to this unit }
  51. {$IFDEF HAS_DIRECTIVE_HPPEMIT_LINKUNIT}
  52. {$HPPEMIT LINKUNIT}
  53. {$ELSE}
  54. {$IFDEF WINDOWS}
  55. {$HPPEMIT '#pragma link "IdAntiFreeze"'} {Do not Localize}
  56. {$ENDIF}
  57. {$IFDEF UNIX}
  58. {$HPPEMIT '#pragma link "IdAntiFreeze.o"'} {Do not Localize}
  59. {$ENDIF}
  60. {$ENDIF}
  61. {$IFDEF VCL_10_3_OR_ABOVE}
  62. // until Delphi 10.3.2 can be detected in IdCompilerDefines.inc,
  63. // use {$IF DECLARED(...) here to enable the new platform values...)
  64. {$IFNDEF VCL_10_3_UPDATE2_OR_ABOVE} // TODO: does RTLVersion1032 exist?
  65. {$IF DECLARED(pidAllPlatforms)}
  66. {$DEFINE HAS_ComponentPlatformsAttribute_AllPlatforms}
  67. {$DEFINE HAS_ComponentPlatformsAttribute_OSX64}
  68. {$IFEND}
  69. {$ENDIF}
  70. {$ENDIF}
  71. type
  72. {$IFDEF HAS_ComponentPlatformsAttribute}
  73. [ComponentPlatformsAttribute(
  74. {$IFDEF HAS_ComponentPlatformsAttribute_AllPlatforms}pidAllPlatforms
  75. {$ELSE}
  76. pidWin32
  77. {$IFDEF HAS_ComponentPlatformsAttribute_Win64} or pidWin64{$ENDIF}
  78. {$IFDEF HAS_ComponentPlatformsAttribute_OSX32} or pidOSX32{$ENDIF}
  79. {$IFDEF HAS_ComponentPlatformsAttribute_iOS_Simulator32}or pidiOSSimulator32{$ELSE}
  80. {$IFDEF HAS_ComponentPlatformsAttribute_iOS_Simulator} or pidiOSSimulator{$ENDIF}{$ENDIF}
  81. {$IFDEF HAS_ComponentPlatformsAttribute_AndroidArm32} or pidAndroidArm32{$ELSE}
  82. {$IFDEF HAS_ComponentPlatformsAttribute_Android32Arm} or pidAndroid32Arm{$ELSE}
  83. {$IFDEF HAS_ComponentPlatformsAttribute_Android} or pidAndroid{$ENDIF}{$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_Win32ARM} or pidWin32ARM{$ELSE}
  93. {$IFDEF HAS_ComponentPlatformsAttribute_WinARM} or pidWinARM{$ENDIF}{$ENDIF}{$ENDIF}
  94. {$IFDEF HAS_ComponentPlatformsAttribute_OSXNX64} or pidOSXNX64{$ELSE}
  95. {$IFDEF HAS_ComponentPlatformsAttribute_OSX64} or pidOSX64{$ENDIF}{$ENDIF}
  96. {$IFDEF HAS_ComponentPlatformsAttribute_LinuxArm32} or pidLinuxArm32{$ELSE}
  97. {$IFDEF HAS_ComponentPlatformsAttribute_Linux32Arm} or pidLinux32Arm{$ENDIF}{$ENDIF}
  98. {$IFDEF HAS_ComponentPlatformsAttribute_LinuxArm64} or pidLinuxArm64{$ELSE}
  99. {$IFDEF HAS_ComponentPlatformsAttribute_Linux64Arm} or pidLinux64Arm{$ENDIF}{$ENDIF}
  100. {$IFDEF HAS_ComponentPlatformsAttribute_AndroidArm64} or pidAndroidArm64{$ELSE}
  101. {$IFDEF HAS_ComponentPlatformsAttribute_Android64Arm} or pidAndroid64Arm{$ELSE}
  102. {$IFDEF HAS_ComponentPlatformsAttribute_Android64} or pidAndroid64{$ENDIF}{$ENDIF}{$ENDIF}
  103. {$IFDEF HAS_ComponentPlatformsAttribute_iOS_Simulator64} or pidiOSSimulator64{$ENDIF}
  104. {$IFDEF HAS_ComponentPlatformsAttribute_OSXArm64} or pidOSXArm64{$ENDIF}
  105. {$IFDEF HAS_ComponentPlatformsAttribute_WinArm64} or pidWinArm64{$ENDIF}
  106. {$IFDEF HAS_ComponentPlatformsAttribute_iOS_SimulatorArm64} or pidiOSSimulatorArm64{$ENDIF}
  107. {$ENDIF}
  108. )]
  109. {$ENDIF}
  110. TIdAntiFreeze = class(TIdAntiFreezeBase)
  111. public
  112. procedure Process; override;
  113. end;
  114. implementation
  115. uses
  116. {$IFDEF WIDGET_KYLIX}
  117. QForms,
  118. {$ENDIF}
  119. {$IFDEF WIDGET_VCL_LIKE}
  120. Forms,
  121. {$ENDIF}
  122. {$IFDEF WINDOWS}
  123. {$IFNDEF FMX}
  124. Windows,
  125. {$ENDIF}
  126. {$ENDIF}
  127. {$IFDEF WIDGET_WINFORMS}
  128. System.Windows.Forms,
  129. {$ENDIF}
  130. IdGlobal;
  131. {$IFDEF UNIX}
  132. procedure TIdAntiFreeze.Process;
  133. begin
  134. //TODO: Handle ApplicationHasPriority
  135. Application.ProcessMessages;
  136. end;
  137. {$ENDIF}
  138. {$IFDEF WINDOWS}
  139. {$IFNDEF FMX}
  140. procedure TIdAntiFreeze.Process;
  141. var
  142. LMsg: TMsg;
  143. begin
  144. if ApplicationHasPriority then begin
  145. Application.ProcessMessages;
  146. end else begin
  147. // This guarantees it will not ever call Application.Idle
  148. if PeekMessage(LMsg, 0, 0, 0, PM_NOREMOVE) then begin
  149. Application.HandleMessage;
  150. end;
  151. end;
  152. end;
  153. {$ELSE}
  154. procedure TIdAntiFreeze.Process;
  155. begin
  156. //TODO: Handle ApplicationHasPriority
  157. Application.ProcessMessages;
  158. end;
  159. {$ENDIF}
  160. {$ENDIF}
  161. {$IFDEF WIDGET_WINFORMS}
  162. procedure TIdAntiFreeze.Process;
  163. begin
  164. //TODO: Handle ApplicationHasPriority
  165. Application.DoEvents;
  166. end;
  167. {$ENDIF}
  168. end.