PageRenderTime 67ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/mckObjs.pas

http://github.com/rofl0r/KOL
Pascal | 2466 lines | 2129 code | 155 blank | 182 comment | 191 complexity | c93219512da4ee8549868c5039b6a414 MD5 | raw file
  1. {=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  2. KKKKK KKKKK OOOOOOOOO LLLLL
  3. KKKKK KKKKK OOOOOOOOOOOOO LLLLL
  4. KKKKK KKKKK OOOOO OOOOO LLLLL
  5. KKKKK KKKKK OOOOO OOOOO LLLLL
  6. KKKKKKKKKK OOOOO OOOOO LLLLL
  7. KKKKK KKKKK OOOOO OOOOO LLLLL
  8. KKKKK KKKKK OOOOO OOOOO LLLLL
  9. KKKKK KKKKK OOOOOOOOOOOOO LLLLLLLLLLLLL kkkkk
  10. KKKKK KKKKK OOOOOOOOO LLLLLLLLLLLLL kkkkk
  11. kkkkk
  12. mmmmm mmmmm mmmmmm cccccccccccc kkkkk kkkkk
  13. mmmmmmmm mmmmm mmmmm cccccc ccccc kkkkk kkkkk
  14. mmmmmmmm mmmmm mmmmm cccccc kkkkkkkk
  15. mmmmm mmmmm mmmmm cccccc ccccc kkkkk kkkkk
  16. mmmmm mmmmm mmmmm cccccccccccc kkkkk kkkkk
  17. Key Objects Library (C) 2000 by Kladov Vladimir.
  18. KOL Mirror Classes Kit (C) 2000 by Kladov Vladimir.
  19. }
  20. unit mckObjs;
  21. interface
  22. {$I KOLDEF.INC}
  23. uses KOL, Classes, Forms, Controls, Dialogs, Windows, Messages, extctrls,
  24. stdctrls, comctrls, SysUtils, Graphics, mirror, ShellAPI,
  25. buttons, mckFileFilterEditor,
  26. //////////////////////////////////////////
  27. {$IFDEF _D6orHigher} //
  28. DesignIntf, DesignEditors //
  29. {$ELSE} //
  30. //////////////////////////////////////////
  31. DsgnIntf
  32. //////////////////////////////////////////
  33. {$ENDIF} //
  34. //////////////////////////////////////////
  35. {$IFNDEF _D2} {$IFNDEF _d3}, imglist {$ENDIF} {$ENDIF},
  36. TypInfo, menus;
  37. type
  38. //============================================================================
  39. //---- MIRROR FOR A TIMER ----
  40. //---- ÇÅÐÊÀËÎ ÄËß ÒÀÉÌÅÐÀ ----
  41. TKOLTimer = class(TKOLObj)
  42. private
  43. FEnabled: Boolean;
  44. FInterval: Integer;
  45. FOnTimer: TOnEvent;
  46. FPeriodic: Boolean;
  47. FMultimedia: Boolean;
  48. FResolution: Integer;
  49. procedure SetEnabled(const Value: Boolean);
  50. procedure SetInterval(const Value: Integer);
  51. procedure SetOnTimer(const Value: TOnEvent);
  52. procedure SetMultimedia(const Value: Boolean);
  53. procedure SetPeriodic(const Value: Boolean);
  54. procedure SetResolution(const Value: Integer);
  55. protected
  56. procedure SetupFirst( SL: TStringList; const AName, AParent, Prefix: String );
  57. override;
  58. procedure AssignEvents( SL: TStringList; const AName: String ); override;
  59. procedure SetupLast( SL: TStringList; const AName, AParent, Prefix: String );
  60. override;
  61. public
  62. function TypeName: String; override;
  63. constructor Create( AOwner: TComponent ); override;
  64. published
  65. property Interval: Integer read FInterval write SetInterval;
  66. property Enabled: Boolean read FEnabled write SetEnabled;
  67. property OnTimer: TOnEvent read FOnTimer write SetOnTimer;
  68. property Multimedia: Boolean read FMultimedia write SetMultimedia;
  69. property Resolution: Integer read FResolution write SetResolution;
  70. property Periodic: Boolean read FPeriodic write SetPeriodic;
  71. end;
  72. //============================================================================
  73. //---- MIRROR FOR A THREAD ----
  74. //---- ÇÅÐÊÀËÎ ÄËß ÍÈÒÈ ----
  75. TPriorityClass = ( pcNormal, pcIdle, pcHigh, pcRealTime );
  76. TThreadPriority = ( tpNormal, tpBelowNormal, tpLowest, tpIdle, tpAboveNormal,
  77. tpHighest, tpCritical );
  78. TKOLThread = class(TKOLObj)
  79. private
  80. FPriorityClass: TPriorityClass;
  81. FThreadPriority: TThreadPriority;
  82. FOnExecute: TOnThreadExecute;
  83. FOnSuspend: TObjectMethod;
  84. FOnResume: TOnEvent;
  85. FstartSuspended: Boolean;
  86. F_AutoFree: Boolean;
  87. procedure SetPriorityClass(const Value: TPriorityClass);
  88. procedure SetThreadPriority(const Value: TThreadPriority);
  89. procedure SetOnExecute(const Value: TOnThreadExecute);
  90. procedure SetOnSuspend(const Value: TObjectMethod);
  91. procedure SetOnResume(const Value: TOnEvent);
  92. procedure SetstartSuspended(const Value: Boolean);
  93. procedure SetAutoFree(const Value: Boolean);
  94. protected
  95. procedure SetupFirst( SL: TStringList; const AName, AParent, Prefix: String ); override;
  96. procedure AssignEvents( SL: TStringList; const AName: String ); override;
  97. function NotAutoFree: Boolean; override;
  98. function BestEventName: String; override;
  99. public
  100. published
  101. property PriorityClass: TPriorityClass read FPriorityClass write SetPriorityClass;
  102. property ThreadPriority: TThreadPriority read FThreadPriority write SetThreadPriority;
  103. property OnExecute: TOnThreadExecute read FOnExecute write SetOnExecute;
  104. property OnSuspend: TObjectMethod read FOnSuspend write SetOnSuspend;
  105. property OnResume: TOnEvent read FOnResume write SetOnResume;
  106. property startSuspended: Boolean read FstartSuspended write SetstartSuspended;
  107. property AutoFree: Boolean read F_AutoFree write SetAutoFree;
  108. end;
  109. //============================================================================
  110. //---- MIRROR FOR AN IMAGELIST ----
  111. //---- ÇÅÐÊÀËÎ ÄËß ÑÏÈÑÊÀ ÐÈÑÓÍÊÎÂ ----
  112. TKOLImageList = class(TKOLObj)
  113. private
  114. FImgWidth: Integer;
  115. FImgHeight: Integer;
  116. FCount: Integer;
  117. FBitmap: TBitmap;
  118. FSystemImageList: Boolean;
  119. FTransparentColor: TColor;
  120. FColors: TImageListColors;
  121. FMasked: Boolean;
  122. FBkColor: TColor;
  123. procedure SetImgHeight(Value: Integer);
  124. procedure SetImgWidth(Value: Integer);
  125. procedure SetCount(const Value: Integer);
  126. procedure SetBitmap(const Value: TBitmap);
  127. procedure SetSystemImageList(const Value: Boolean);
  128. function GetBitmap: TBitmap;
  129. procedure SetTransparentColor(const Value: TColor);
  130. function GetTransparentColor: TColor;
  131. procedure SetColors(const Value: TImageListColors);
  132. procedure SetMasked(const Value: Boolean);
  133. procedure SetBkColor(const Value: TColor);
  134. function GetImageListHandle: THandle;
  135. procedure AssignBitmapToKOLImgList;
  136. protected
  137. FKOLImgList: PImageList;
  138. procedure SetupFirst( SL: TStringList; const AName, AParent, Prefix: String ); override;
  139. procedure SetupLast( SL: TStringList; const AName, AParent, Prefix: String );
  140. override;
  141. //procedure BitmapChanged( Sender: TObject );
  142. public
  143. constructor Create( AOwner: TComponent ); override;
  144. destructor Destroy; override;
  145. procedure Clear;
  146. procedure Assign( Value: TPersistent ); override;
  147. property Handle: THandle read GetImageListHandle;
  148. published
  149. property ImgWidth: Integer read FImgWidth write SetImgWidth;
  150. property ImgHeight: Integer read FImgHeight write SetImgHeight;
  151. property Count: Integer read FCount write SetCount;
  152. property bitmap: TBitmap read GetBitmap write SetBitmap;
  153. property TransparentColor: TColor read GetTransparentColor write SetTransparentColor;
  154. property systemimagelist: Boolean read FSystemImageList write SetSystemImageList;
  155. property Colors: TImageListColors read FColors write SetColors;
  156. property Masked: Boolean read FMasked write SetMasked;
  157. property BkColor: TColor read FBkColor write SetBkColor;
  158. end;
  159. TKOLImageListEditor = class(TComponentEditor)
  160. private
  161. protected
  162. public
  163. procedure Edit; override;
  164. procedure ExecuteVerb(Index: Integer); override;
  165. function GetVerb(Index: Integer): string; override;
  166. function GetVerbCount: Integer; override;
  167. end;
  168. //----------------------------------------------------------------------------
  169. //---- MIRROR FOR OPENSAVE FILE DIALOG ----
  170. //---- ÇÅÐÊÀËÎ ÄËß ÄÈÀËÎÃÀ ÂÛÁÎÐÀ ÔÀÉËÀ ----
  171. TKOLOpenSaveDialog = class(TKOLObj)
  172. private
  173. FOptions: TOpenSaveOptions;
  174. FInitialDir: String;
  175. FFilter: String;
  176. FFilterIndex: Integer;
  177. FTitle: String;
  178. FDefExtension: String;
  179. FOpenDialog: Boolean;
  180. FTemplateName: String;
  181. procedure SetOptions(const Value: TOpenSaveOptions);
  182. procedure SetInitialDir(const Value: String);
  183. procedure SetFilter(const Value: String);
  184. procedure SetFilterIndex(const Value: Integer);
  185. procedure SetTitle(const Value: String);
  186. procedure SetDefExtension(const Value: String);
  187. procedure SetOpenDialog(const Value: Boolean);
  188. procedure SetTemplateName(const Value: String);
  189. protected
  190. procedure SetupFirst( SL: TStringList; const AName, AParent, Prefix: String ); override;
  191. procedure SetupLast( SL: TStringList; const AName, AParent, Prefix: String ); override;
  192. public
  193. constructor Create( AOwner: TComponent ); override;
  194. published
  195. property Options: TOpenSaveOptions read FOptions write SetOptions;
  196. property Title: String read FTitle write SetTitle;
  197. property TemplateName: String read FTemplateName write SetTemplateName;
  198. property InitialDir: String read FInitialDir write SetInitialDir;
  199. property Filter: String read FFilter write SetFilter;
  200. property FilterIndex: Integer read FFilterIndex write SetFilterIndex;
  201. property DefExtension: String read FDefExtension write SetDefExtension;
  202. property OpenDialog: Boolean read FOpenDialog write SetOpenDialog;
  203. property Localizy;
  204. end;
  205. TKOLFileFilter = class( TStringProperty )
  206. private
  207. protected
  208. public
  209. function GetAttributes: TPropertyAttributes; override;
  210. procedure Edit; override;
  211. end;
  212. //----------------------------------------------------------------------------
  213. //---- MIRROR FOR OPENDIR DIALOG ----
  214. //---- ÇÅÐÊÀËÎ ÄËß ÄÈÀËÎÃÀ ÂÛÁÎÐÀ ÄÈÐÅÊÒÎÐÈß ----
  215. TKOLOpenDirDialog = class( TKOLObj )
  216. private
  217. FTitle: String;
  218. FOptions: TOpenDirOptions;
  219. FInitialPath: String;
  220. FCenterOnScreen: Boolean;
  221. FOnSelChanged: TOnODSelChange;
  222. procedure SetTitle(const Value: String);
  223. procedure SetOptions(const Value: TOpenDirOptions);
  224. procedure SetInitialPath(const Value: String);
  225. procedure SetCenterOnScreen(const Value: Boolean);
  226. procedure SetOnSelChanged(const Value: TOnODSelChange);
  227. protected
  228. procedure SetupFirst( SL: TStringList; const AName, AParent, Prefix: String ); override;
  229. procedure SetupLast( SL: TStringList; const AName, AParent, Prefix: String ); override;
  230. procedure AssignEvents( SL: TStringList; const AName: String ); override;
  231. public
  232. constructor Create( AOwner: TComponent ); override;
  233. published
  234. property Title: String read FTitle write SetTitle;
  235. property Options: TOpenDirOptions read FOptions write SetOptions;
  236. property InitialPath: String read FInitialPath write SetInitialPath;
  237. property CenterOnScreen: Boolean read FCenterOnScreen write SetCenterOnScreen;
  238. property OnSelChanged: TOnODSelChange read FOnSelChanged write SetOnSelChanged;
  239. property Localizy;
  240. end;
  241. //----------------------------------------------------------------------------
  242. //---- MIRROR FOR COLOR CHOOSING DIALOG ----
  243. //---- ÇÅÐÊÀËÎ ÄËß ÄÈÀËÎÃÀ ÂÛÁÎÐÀ ÖÂÅÒÀ ----
  244. TKOLColorDialog = class( TKOLObj )
  245. private
  246. FColorCustomOption: TColorCustomOption;
  247. FCustomColors: array[ 1..16 ] of TColor;
  248. procedure SetColorCustomOption(const Value: TColorCustomOption);
  249. function GetCustomColor( const Index: Integer ): TColor;
  250. procedure SetCustomColor(const Index: Integer; const Value: TColor);
  251. protected
  252. procedure SetupFirst( SL: TStringList; const AName, AParent, Prefix: String ); override;
  253. public
  254. constructor Create( AOwner: TComponent ); override;
  255. published
  256. property ColorCustomOption: TColorCustomOption read FColorCustomOption write SetColorCustomOption;
  257. property CustomColor1: TColor index 1 read GetCustomColor write SetCustomColor;
  258. property CustomColor2: TColor index 2 read GetCustomColor write SetCustomColor;
  259. property CustomColor3: TColor index 3 read GetCustomColor write SetCustomColor;
  260. property CustomColor4: TColor index 4 read GetCustomColor write SetCustomColor;
  261. property CustomColor5: TColor index 5 read GetCustomColor write SetCustomColor;
  262. property CustomColor6: TColor index 6 read GetCustomColor write SetCustomColor;
  263. property CustomColor7: TColor index 7 read GetCustomColor write SetCustomColor;
  264. property CustomColor8: TColor index 8 read GetCustomColor write SetCustomColor;
  265. property CustomColor9: TColor index 9 read GetCustomColor write SetCustomColor;
  266. property CustomColor10: TColor index 10 read GetCustomColor write SetCustomColor;
  267. property CustomColor11: TColor index 11 read GetCustomColor write SetCustomColor;
  268. property CustomColor12: TColor index 12 read GetCustomColor write SetCustomColor;
  269. property CustomColor13: TColor index 13 read GetCustomColor write SetCustomColor;
  270. property CustomColor14: TColor index 14 read GetCustomColor write SetCustomColor;
  271. property CustomColor15: TColor index 15 read GetCustomColor write SetCustomColor;
  272. property CustomColor16: TColor index 16 read GetCustomColor write SetCustomColor;
  273. end;
  274. //----------------------------------------------------------------------------
  275. //---- MIRROR FOR TRAY ICON ----
  276. //---- ÇÅÐÊÀËÎ ÄËß ÈÊÎÍÊÈ Â ÒÐÅÅ ----
  277. TKOLTrayIcon = class( TKOLObj )
  278. private
  279. FIcon: TIcon;
  280. FActive: Boolean;
  281. FTooltip: String;
  282. FAutoRecreate: Boolean;
  283. FOnMouse: TOnTrayIconMouse;
  284. FNoAutoDeactivate: Boolean;
  285. procedure SetIcon(const Value: TIcon);
  286. procedure SetActive(const Value: Boolean);
  287. procedure SetTooltip(const Value: String);
  288. procedure SetAutoRecreate(const Value: Boolean);
  289. procedure SetOnMouse(const Value: TOnTrayIconMouse);
  290. procedure SetNoAutoDeactivate(const Value: Boolean);
  291. protected
  292. procedure SetupFirst( SL: TStringList; const AName, AParent, Prefix: String ); override;
  293. procedure SetupLast( SL: TStringList; const AName, AParent, Prefix: String ); override;
  294. procedure AssignEvents( SL: TStringList; const AName: String ); override;
  295. public
  296. constructor Create( AOwner: TComponent ); override;
  297. destructor Destroy; override;
  298. published
  299. property Icon: TIcon read FIcon write SetIcon;
  300. property Active: Boolean read FActive write SetActive;
  301. property NoAutoDeactivate: Boolean read FNoAutoDeactivate write SetNoAutoDeactivate;
  302. property Tooltip: String read FTooltip write SetTooltip;
  303. property AutoRecreate: Boolean read FAutoRecreate write SetAutoRecreate;
  304. property OnMouse: TOnTrayIconMouse read FOnMouse write SetOnMouse;
  305. property Localizy;
  306. end;
  307. type KOLTPixelFormat = KOL.TPixelFormat;
  308. function CountSystemColorsUsedInBitmap( Bmp: KOL.PBitmap ): KOLTPixelFormat;
  309. //function SaveBitmap( Bitmap: TBitmap; const Path: String ): Boolean;
  310. procedure GenerateBitmapResource( Bitmap: TBitmap; const RsrcName, FileName: String;
  311. var Updated: Boolean );
  312. procedure GenerateIconResource( Icon: TIcon; const RsrcName, FileName: String;
  313. var Updated: Boolean );
  314. procedure RemoveSelection( FD: IFormDesigner );
  315. function String2Pascal( S: String ): String;
  316. //function GetBmpPixel( Bitmap: TBitmap; X, Y: Integer ): TColor;
  317. procedure Register;
  318. implementation
  319. procedure Register;
  320. begin
  321. RegisterComponents( 'KOL', [ TKOLTimer, TKOLThread, TKOLImageList, TKOLMainMenu, TKOLPopupMenu,
  322. TKOLOpenSaveDialog, TKOLOpenDirDialog, TKOLColorDialog,
  323. TKOLTrayIcon ] );
  324. RegisterComponentEditor( TKOLImageList, TKOLImageListEditor );
  325. RegisterPropertyEditor( TypeInfo( String ), TKOLOpenSaveDialog, 'Filter',
  326. TKOLFileFilter );
  327. RegisterPropertyEditor( TypeInfo( TOnODSelChange ), TKOLOpenDirDialog, 'OnSelChanged', TKOLOnEventPropEditor );
  328. RegisterPropertyEditor( TypeInfo( TOnTrayIconMouse ), nil, '', TKOLOnEventPropEditor );
  329. end;
  330. function String2Pascal( S: String ): String;
  331. begin
  332. asm
  333. jmp @@e_signature
  334. DB '#$signature$#', 0
  335. DB 'String2Pascal', 0
  336. @@e_signature:
  337. end;
  338. if Length( S ) > 0 then
  339. begin
  340. Result := '';
  341. while S <> '' do
  342. begin
  343. if Result <> '' then
  344. Result := Result + ' + ';
  345. Result := Result + String2PascalStrExpr( Copy( S, 1, 255 ) );
  346. S := Copy( S, 256, MaxInt );
  347. end;
  348. end
  349. else
  350. Result := '''''';
  351. end;
  352. procedure RemoveSelection( FD: IFormDesigner );
  353. {$IFDEF _D2orD3}
  354. var L: TComponentList;
  355. {$ENDIF}
  356. begin
  357. asm
  358. jmp @@e_signature
  359. DB '#$signature$#', 0
  360. DB 'RemoveSelection', 0
  361. @@e_signature:
  362. end;
  363. try
  364. {$IFDEF _D5orHigher}
  365. FD.NoSelection;
  366. {$ELSE}
  367. {$IFDEF _D2orD3}
  368. L := TComponentList.Create;
  369. FD.SetSelections( L );
  370. L.Free;
  371. {$ELSE _D4}
  372. FD.SetSelections( nil );
  373. {$ENDIF}
  374. {$ENDIF}
  375. except
  376. Rpt( '*/\* EXCEPTION - Could not remove current selection' );
  377. end;
  378. end;
  379. function ColorsAreSystem16( ColorList: PList ): Boolean;
  380. const SysColors: array[ 0..15 ] of TColor = ( 0, $800000, $8000, $808000, $80,
  381. $800080, $8080, $808080, $C0C0C0, $FF0000, $FF00, $FFFF00, $FF, $FF00FF,
  382. $FFFF, $FFFFFF );
  383. var I, J: Integer;
  384. C: TColor;
  385. Found: Boolean;
  386. begin
  387. Result := TRUE;
  388. for I := 0 to ColorList.Count-1 do
  389. begin
  390. C := TColor( ColorList.Items[ I ] );
  391. Found := FALSE;
  392. for J := 0 to 15 do
  393. if SysColors[ J ] = C then
  394. begin
  395. Found := TRUE;
  396. break;
  397. end;
  398. if not Found then
  399. begin
  400. Rpt( '***** Color ' + Int2Hex( C, 8 ) + ' not found in system 16 colors' );
  401. Result := FALSE;
  402. Exit;
  403. end;
  404. end;
  405. end;
  406. function ColorsAreSystem256( ColorList: PList ): Boolean;
  407. const SysColors8bit: array[ 0..255 ] of DWORD = ( $000000,
  408. $C0DCC0, $800000, $808000, $008000, $008080, $000080, $800080, $808080,
  409. $00FF00, $0000FF, $00FFFF, $C0DCC0, $000040, $400040, $000000, $A0A0A4,
  410. $C0C0C0, $C0DCC0, $FFFBF0, $FFFBF0, $FFFBF0, $FFFBF0, $FFFFFF, $FF0000,
  411. $FFFF00, $FF00FF, $FFFFFF, $A6CAF0, $402000, $004040, $202040, $202040,
  412. $606040, $404040, $E08080, $E00080, $C0DCC0, $A0A0A4, $800000, $C02000,
  413. $404000, $A04000, $E04000, $406000, $A06000, $E06000, $40A000, $202040,
  414. $404040, $404040, $E06040, $A6CAF0, $C0DCC0, $40E000, $800000, $004000,
  415. $604000, $C04000, $006000, $606000, $C06000, $00A000, $60A000, $A0A000,
  416. $E0A000, $40C000, $A0C000, $E0C000, $A0E000, $00E040, $600040, $C00040,
  417. $0000FF, $604040, $C04040, $006040, $606040, $C06040, $00A040, $C0A000,
  418. $00C000, $60C000, $C0C000, $60E000, $C0E000, $0000FF, $A00040, $E00040,
  419. $404040, $A04040, $E04040, $406040, $A06040, $E06040, $40A040, $60A040,
  420. $C0A040, $00C040, $60C040, $C0C040, $40E040, $A0E040, $E0E040, $400080,
  421. $A00080, $E00080, $404080, $A04080, $E04080, $406080, $A06080, $A0A040,
  422. $E0A040, $40C040, $A0C040, $E0C040, $60E040, $C0E040, $000080, $600080,
  423. $C00080, $004080, $604080, $C04080, $006080, $606080, $C06080, $00A080,
  424. $A0C080, $E0C080, $40E080, $C0E080, $FF00FF, $A04080, $C00080, $404080,
  425. $C04080, $006080, $604080, $C06080, $40A080, $A0A0A4, $E0A080, $40C080,
  426. $C0C080, $00E080, $A0E080, $E000C0, $00A080, $A00080, $000080, $600080,
  427. $E00080, $406080, $A06080, $E04080, $60A080, $C0A080, $00C080, $40C080,
  428. $A0C080, $E0C080, $40E080, $A0E080, $E0E080, $400080, $A000C0, $004080,
  429. $6040C0, $C040C0, $0060C0, $606080, $C060C0, $00A0C0, $60A0C0, $60C080,
  430. $C0C080, $00E080, $60C080, $C0E080, $0000C0, $6000C0, $C000C0, $4040C0,
  431. $A040C0, $E040C0, $4060C0, $A060C0, $E06080, $40A0C0, $A0A0C0, $C0A0C0,
  432. $00A0C0, $60A0C0, $C0A0C0, $00C0C0, $60C0C0, $C0C0C0, $00FFFF, $60E080,
  433. $C0DCC0, $4000C0, $A000C0, $4040C0, $A040C0, $FF00FF, $4060C0, $E0A0C0,
  434. $40A0C0, $A0A0C0, $E0A0C0, $40C0C0, $A0C0C0, $E0A0C0, $40C0C0, $C0DCC0,
  435. $FFFBF0, $6000C0, $0040C0, $6040C0, $C040C0, $0060C0, $6060C0, $A060C0,
  436. $E060C0, $40A0C0, $A6CAF0, $E0A0C0, $40C0C0, $A6CAF0, $FFFBF0, $60C0C0,
  437. $FFFFFF, $60E080, $6060C0, $A6CAF0, $606040, $808080, $C0C0C0, $C060C0,
  438. $00A0C0, $60A0C0, $A6CAF0, $00FFFF, $60C0C0, $A6CAF0, $00FFFF, $A6CAF0,
  439. $E06080, $E0E080, $E060C0, $A00040, $808080, $A0A0A4, $C0C0C0 );
  440. var I, J: Integer;
  441. C: DWORD;
  442. begin
  443. Result := FALSE;
  444. for I := 0 to ColorList.Count-1 do
  445. begin
  446. C := DWORD( ColorList.Items[ I ] );
  447. for J := 0 to 255 do
  448. begin
  449. if SysColors8bit[ J ] = C then
  450. begin
  451. C := 0;
  452. break;
  453. end;
  454. end;
  455. if C <> 0 then
  456. begin
  457. Rpt( '~~~ color not found: ' + Int2Hex( C, 6 ) );
  458. Exit;
  459. end;
  460. end;
  461. Result := TRUE;
  462. end;
  463. function ColorsAre64K( ColorList: PList ): Boolean;
  464. var I: Integer;
  465. C: DWORD;
  466. begin
  467. Result := FALSE;
  468. for I := 0 to ColorList.Count-1 do
  469. begin
  470. C := DWORD( ColorList.Items[ I ] );
  471. if (C and $E0C0E0) <> C then
  472. begin
  473. Rpt( '~~~ color not found: ' + Int2Hex( C, 6 ) );
  474. Exit;
  475. end;
  476. end;
  477. Result := TRUE;
  478. end;
  479. function CountSystemColorsUsedInBitmap( Bmp: KOL.PBitmap ): KOL.TPixelFormat;
  480. var Y, X: Integer;
  481. L: PDWORD;
  482. ColorList: KOL.PList;
  483. C: TColor;
  484. R, G, B: Byte;
  485. begin
  486. ColorList := NewList;
  487. ColorList.Capacity := 65537;
  488. TRY
  489. for Y := 0 to Bmp.Height - 1 do
  490. begin
  491. L := Bmp.ScanLine[ Y ];
  492. for X := 0 to Bmp.Width - 1 do
  493. begin
  494. C := L^ and $FFFFFF;
  495. if (C and $E0C0E0) <> C then
  496. begin
  497. R := C and $FF;
  498. G := (C and $FF00) shr 8;
  499. B := C shr 16;
  500. if ((R and $E0) <> R) and (R <> $FF) or
  501. ((G and $C0) <> G) and (G <> $FF) or
  502. ((B and $E0) <> B) and (B <> $FF) then
  503. begin
  504. Result := KOL.pf24bit;
  505. Rpt( '~~~ color not found: ' + Int2Hex( C, 6 ) );
  506. Exit;
  507. end;
  508. end;
  509. if ColorList.IndexOf( Pointer( C ) ) < 0 then
  510. begin
  511. ColorList.Add( Pointer( C ) );
  512. if ColorList.Count > 65536 then
  513. begin
  514. Result := KOL.pf24bit;
  515. Rpt( '~~~~~ pf24bit (break) ~~~~~ (' + Int2Str( ColorList.Count ) + ')' );
  516. Exit;
  517. end;
  518. end;
  519. Inc( L );
  520. end;
  521. end;
  522. //Rpt( '------ Colors in bitmap: ' + Int2Str( ColorList.Count ) );
  523. if (ColorList.Count <= 2) and
  524. ((ColorList.Count = 0) or
  525. (ColorList.Count > 0) and (DWORD(ColorList.Items[ 0 ]) and $FFFFFF = $FFFFFF) and
  526. ((ColorList.Count < 2) or
  527. (ColorList.Count = 2) and (DWORD( ColorList.Items[ 1 ] ) and $FFFFFF = 0) )) then
  528. begin
  529. Result := KOL.pf1bit;
  530. Rpt( '~~~~~ pf1bit ~~~~~' );
  531. end else if (ColorList.Count <= 16) and ColorsAreSystem16( ColorList ) then
  532. begin
  533. Result := KOL.pf4bit;
  534. Rpt( '~~~~~ pf4bit ~~~~~' );
  535. end else if (ColorList.Count <= 256) and ColorsAreSystem256( ColorList ) then
  536. begin
  537. Result := KOL.pf8bit;
  538. Rpt( '~~~~~ pf8bit ~~~~~' );
  539. end else if (ColorList.Count <= 65536) and ColorsAre64K( ColorList ) then
  540. begin
  541. Result := KOL.pf16bit;
  542. Rpt( '~~~~~ pf16bit ~~~~~' );
  543. end
  544. else
  545. begin
  546. Result := KOL.pf24bit;
  547. Rpt( '~~~~~ pf24bit ~~~~~ (' + Int2Str( ColorList.Count ) + ')' );
  548. end;
  549. FINALLY
  550. ColorList.Free;
  551. END;
  552. end;
  553. {$IFDEF _D2}
  554. procedure GenerateBitmapResource( Bitmap: TBitmap; const RsrcName, FileName: String;
  555. var Updated: Boolean );
  556. var RL: TStringList;
  557. Buf1, Buf2: PChar;
  558. I, J: Integer;
  559. F: THandle;
  560. S: String;
  561. KOLBmp: KOL.PBitmap;
  562. begin
  563. asm
  564. jmp @@e_signature
  565. DB '#$signature$#', 0
  566. DB 'GenerateBitmapResource', 0
  567. @@e_signature:
  568. end;
  569. KOLBmp := NewDIBBitmap( Bitmap.Width, Bitmap.Height, KOL.pf32bit );
  570. BitBlt( KOLBmp.Canvas.Handle, 0, 0, Bitmap.Width, Bitmap.Height,
  571. Bitmap.Canvas.Handle, 0, 0, SRCCOPY );
  572. KOLBmp.HandleType := KOL.bmDIB;
  573. KOLBmp.PixelFormat := KOL.pf32bit;
  574. KOLBmp.PixelFormat := CountSystemColorsUsedInBitmap( KOLBmp );
  575. KOLBmp.SaveToFile( ProjectSourcePath + FileName + '.bmp' );
  576. Buf1 := nil;
  577. Buf2 := nil;
  578. I := 0;
  579. J := 0;
  580. S := ProjectSourcePath + FileName + '.res';
  581. if FileExists( S ) then
  582. begin
  583. I := FileSize( S );
  584. if I > 0 then
  585. begin
  586. GetMem( Buf1, I );
  587. F := KOL.FileCreate( S, ofOpenRead or ofShareDenyWrite or ofOpenExisting );
  588. if F <> THandle( -1 ) then
  589. begin
  590. KOL.FileRead( F, Buf1^, I );
  591. KOL.FileClose( F );
  592. end;
  593. end;
  594. end;
  595. RL := TStringList.Create;
  596. RL.Add( UpperCase( RsrcName ) + ' BITMAP "' + FileName + '.bmp"' );
  597. RL.SaveToFile( ProjectSourcePath + FileName + '.rc' );
  598. RL.Free;
  599. if not FileExists( ProjectSourcePath + FileName + '.rc' ) then
  600. begin
  601. ShowMessage( 'Can not save file: ' + ProjectSourcePath + FileName + '.rc' );
  602. Exit;
  603. end;
  604. {ShellExecute( 0, 'open', PChar( ExtractFilePath( Application.ExeName ) + 'brcc32.exe' ),
  605. PChar( ProjectSourcePath + FileName + '.rc' ), PChar( ProjectSourcePath ),
  606. SW_HIDE );}
  607. Rpt( 'Compiling resource ' + ProjectSourcePath + FileName + '.rc' );
  608. if not ExecuteWait( ExtractFilePath( Application.ExeName ) + 'brcc32.exe',
  609. '"' + ProjectSourcePath + FileName + '.rc"',
  610. ProjectSourcePath, SW_HIDE, INFINITE, nil ) then
  611. begin
  612. Rpt( 'Can not compile resource with ' + ExtractFilePath( Application.ExeName ) + 'brcc32.exe' );
  613. end;
  614. if FileExists( S ) then
  615. begin
  616. J := FileSize( S );
  617. if J > 0 then
  618. begin
  619. GetMem( Buf2, J );
  620. F := KOL.FileCreate( S, ofOpenRead or ofShareDenyWrite or ofOpenExisting );
  621. if F <> THandle( -1 ) then
  622. begin
  623. KOL.FileRead( F, Buf2^, J );
  624. KOL.FileClose( F );
  625. end;
  626. end;
  627. end;
  628. if (Buf1 = nil) or (I <> J) or
  629. (Buf2 <> nil) and not CompareMem( Buf1, Buf2, J ) then
  630. begin
  631. Rpt( 'Resource ' + FileName + ' changed.' );
  632. Updated := TRUE;
  633. end;
  634. if Buf1 <> nil then FreeMem( Buf1 );
  635. if Buf2 <> nil then FreeMem( Buf2 );
  636. end;
  637. {$ELSE not _D2}
  638. // This version of GenerateBitmapResource provided by Alex Pravdin.
  639. // It does not use brcc32.exe, and creates res-file directly, so
  640. // it is fast and has no restrictions on bitmap format at all.
  641. procedure GenerateBitmapResource( Bitmap: TBitmap; const RsrcName, FileName:
  642. String; var Updated: Boolean );
  643. var
  644. HD1: packed record // First part of RESOURCEHEADER structure before
  645. // Unicode string contained bitmap resource name
  646. DataSize: cardinal;
  647. HeaderSize: cardinal;
  648. NFFFF: word;
  649. DataType: word;
  650. end;
  651. HD2: packed record // Second part of RESOURCEHEADER
  652. DataVersion: cardinal;
  653. MemFlags: word;
  654. PrimaryLang: byte;
  655. SubLang: byte;
  656. Version: cardinal;
  657. Charact: cardinal;
  658. end;
  659. br, hFR, hFtm, DIBLen, WLen, RLen, tm: DWORD;
  660. Buf1, Buf2: PByteArray;
  661. FE: boolean;
  662. Res, Bmp: string;
  663. tmStr: WideString;
  664. KOLBmp: KOL.PBitmap;
  665. KOLPF: KOL.TPixelFormat;
  666. begin
  667. asm
  668. jmp @@e_signature
  669. DB '#$signature$#', 0
  670. DB 'GenerateBitmapResource', 0
  671. @@e_signature:
  672. end;
  673. Res := ProjectSourcePath + FileName + '.res';
  674. Bmp := ProjectSourcePath + FileName + '.bmp';
  675. FE := FileExists( Res );
  676. //Bitmap.SaveToFile( Bmp );
  677. KOLBmp := KOL.NewDIBBitmap( Bitmap.Width, Bitmap.Height, KOL.pf32bit );
  678. BitBlt( KOLBmp.Canvas.Handle, 0, 0, Bitmap.Width, Bitmap.Height,
  679. Bitmap.Canvas.Handle, 0, 0, SRCCOPY );
  680. KOLBmp.HandleType := KOL.bmDIB;
  681. KOLBmp.PixelFormat := KOL.pf32bit;
  682. KOLPF := CountSystemColorsUsedInBitmap( KOLBmp );
  683. KOLBmp.PixelFormat := KOLPF;
  684. KOLBmp.SaveToFile( Bmp );
  685. KOLBmp.Free;
  686. if FE then
  687. begin
  688. DeleteFile( PChar( Res + '_tmp' ) );
  689. CopyFile( PChar(Res), PChar( (Res+'_tmp') ), False );
  690. end;
  691. hFR := CreateFile( PChar(Res), GENERIC_READ or GENERIC_WRITE, FILE_SHARE_READ,
  692. nil, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0 );
  693. if hFR = INVALID_HANDLE_VALUE then begin
  694. Rpt( 'Can not create file ' + Res + #13#10'Error: ' + SysErrorMessage( GetLastError ) );
  695. Exit;
  696. end;
  697. hFtm := CreateFile( PChar(Bmp), GENERIC_READ, FILE_SHARE_READ, nil,
  698. OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 );
  699. DIBLen := GetFileSize( hFtm, nil ) - 14{SizeOf( TBITMAPFILEHEADER )};
  700. WLen := ( Length( RsrcName ) + 1 ) * 2;
  701. HD1.DataSize := DIBLen;
  702. HD1.HeaderSize := 12{SizeOf( HD1 )} + 16{SizeOf( HD2 )} + WLen;
  703. HD1.NFFFF := $FFFF;
  704. HD1.DataType := 2; // RT_BITMAP
  705. HD2.DataVersion := 0;
  706. HD2.MemFlags := 0;
  707. HD2.PrimaryLang := LANG_NEUTRAL;
  708. HD2.SubLang := SUBLANG_DEFAULT;
  709. HD2.Version := 0;
  710. HD2.Charact := 0;
  711. RLen := HD1.HeaderSize + DIBLen + 32;
  712. GetMem( Buf1, RLen );
  713. FillChar( Buf1[0], RLen, 0 );
  714. Buf1[4]:=$20; Buf1[8]:=$FF; Buf1[9]:=$FF; Buf1[12]:=$FF; Buf1[13]:=$FF;
  715. tmStr := UpperCase( RsrcName ) + #0;
  716. CopyMemory( @Buf1[32], @HD1, 12 );
  717. CopyMemory( @Buf1[32+12], @tmStr[1], WLen );
  718. CopyMemory( @Buf1[32+12+WLen], @HD2, 16 );
  719. SetFilePointer( hFtm, 14{SizeOf( TBITMAPFILEHEADER )}, nil, FILE_BEGIN);
  720. ReadFile( hFtm, Buf1[32+12+16+WLen], DIBLen, br, nil );
  721. WriteFile( hFR, Buf1[0], RLen, br, nil );
  722. CloseHandle( hFtm );
  723. CloseHandle( hFR );
  724. DeleteFile( Bmp );
  725. if FE then begin
  726. hFtm := CreateFile( PChar( (Res+'_tmp') ), GENERIC_READ,
  727. FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 );
  728. tm := GetFileSize( hFtm, nil );
  729. GetMem( Buf2, tm );
  730. ReadFile( hFtm, Buf2[0], tm, br, nil );
  731. CloseHandle( hFtm );
  732. DeleteFile( Res + '_tmp' );
  733. if ( RLen <> tm ) or (not CompareMem( @Buf1[0], @Buf2[0], Min( RLen,
  734. tm ) )) then begin
  735. Rpt( 'Resource ' + Res + ' changed.' );
  736. Updated := True;
  737. end;
  738. FreeMem( Buf2 );
  739. end;
  740. FreeMem( Buf1 );
  741. end;
  742. {$ENDIF}
  743. function SaveIcon( Icon: TIcon; const Path: String ): Boolean;
  744. var MS, MS2: TMemoryStream;
  745. begin
  746. asm
  747. jmp @@e_signature
  748. DB '#$signature$#', 0
  749. DB 'SaveIcon', 0
  750. @@e_signature:
  751. end;
  752. Result := TRUE;
  753. MS := TMemoryStream.Create;
  754. MS2 := TMemoryStream.Create;
  755. try
  756. Icon.SaveToStream( MS );
  757. if FileExists( Path ) then
  758. begin
  759. MS2.LoadFromFile( Path );
  760. if (MS.Size = MS2.Size) and CompareMem( MS.Memory, MS2.Memory, MS.Size ) then
  761. Exit;
  762. if FileExists( Path + '.$$$' ) then
  763. DeleteFile( Path + '.$$$' );
  764. MoveFile( PChar( Path ), PChar( Path + '.$$$' ) );
  765. end;
  766. MS.Position := 0;
  767. MS.SaveToFile( Path );
  768. //Result := True;
  769. //Rpt( 'Icon stored to ' + Path );
  770. finally
  771. MS.Free;
  772. MS2.Free;
  773. end;
  774. end;
  775. procedure GenerateIconResource( Icon: TIcon; const RsrcName, FileName: String;
  776. var Updated: Boolean );
  777. var RL: TStringList;
  778. Buf1, Buf2: PChar;
  779. S: String;
  780. I, J: Integer;
  781. F: THandle;
  782. begin
  783. asm
  784. jmp @@e_signature
  785. DB '#$signature$#', 0
  786. DB 'GenerateIconResource', 0
  787. @@e_signature:
  788. end;
  789. {if not SaveIcon( Icon, ProjectSourcePath + FileName + '.ico' )
  790. and FileExists( ProjectSourcePath + FileName + '.res' ) then Exit;}
  791. if not SaveIcon( Icon, ProjectSourcePath + FileName + '.ico' ) then
  792. Exit;
  793. RL := TStringList.Create;
  794. RL.Add( UpperCase( RsrcName ) + ' ICON "' + FileName + '.ico"' );
  795. RL.SaveToFile( ProjectSourcePath + FileName + '.rc' );
  796. RL.Free;
  797. Buf1 := nil;
  798. Buf2 := nil;
  799. I := 0; J := 0;
  800. S := ProjectSourcePath + FileName + '.res';
  801. if FileExists( S ) then
  802. begin
  803. I := FileSize( S );
  804. if I > 0 then
  805. begin
  806. GetMem( Buf1, I );
  807. F := KOL.FileCreate( S, ofOpenRead or ofShareDenyWrite or ofOpenExisting );
  808. if F <> THandle( -1 ) then
  809. begin
  810. KOL.FileRead( F, Buf1^, I );
  811. KOL.FileClose( F );
  812. end;
  813. end;
  814. end;
  815. {ShellExecute( 0, 'open', PChar( ExtractFilePath( Application.ExeName ) + 'brcc32.exe' ),
  816. PChar( ProjectSourcePath + FileName + '.rc' ), PChar( ProjectSourcePath ),
  817. SW_HIDE );}
  818. ExecuteWait( ExtractFilePath( Application.ExeName ) + 'brcc32.exe',
  819. '"' + ProjectSourcePath + FileName + '.rc"',
  820. ProjectSourcePath, SW_HIDE, INFINITE, nil );
  821. if FileExists( S ) then
  822. begin
  823. J := FileSize( S );
  824. if J > 0 then
  825. begin
  826. GetMem( Buf2, J );
  827. F := KOL.FileCreate( S, ofOpenRead or ofShareDenyWrite or ofOpenExisting );
  828. if F <> THandle( -1 ) then
  829. begin
  830. KOL.FileRead( F, Buf2^, J );
  831. KOL.FileClose( F );
  832. end;
  833. end;
  834. end;
  835. if (Buf1 = nil) or (I <> J) or
  836. (Buf2 <> nil) and not CompareMem( Buf1, Buf2, J ) then
  837. begin
  838. Updated := TRUE;
  839. end;
  840. if Buf1 <> nil then FreeMem( Buf1 );
  841. if Buf2 <> nil then FreeMem( Buf2 );
  842. end;
  843. { TKOLTimer }
  844. procedure TKOLTimer.AssignEvents(SL: TStringList; const AName: String);
  845. begin
  846. asm
  847. jmp @@e_signature
  848. DB '#$signature$#', 0
  849. DB 'TKOLTimer.AssignEvents', 0
  850. @@e_signature:
  851. end;
  852. inherited;
  853. DoAssignEvents( SL, AName, [ 'OnTimer' ], [ @OnTimer ] );
  854. end;
  855. constructor TKOLTimer.Create(AOwner: TComponent);
  856. begin
  857. asm
  858. jmp @@e_signature
  859. DB '#$signature$#', 0
  860. DB 'TKOLTimer.Create', 0
  861. @@e_signature:
  862. end;
  863. inherited;
  864. fInterval := 1000;
  865. fEnabled := True;
  866. FPeriodic := TRUE;
  867. FResolution := 0;
  868. end;
  869. procedure TKOLTimer.SetEnabled(const Value: Boolean);
  870. begin
  871. asm
  872. jmp @@e_signature
  873. DB '#$signature$#', 0
  874. DB 'TKOLTimer.SetEnabled', 0
  875. @@e_signature:
  876. end;
  877. FEnabled := Value;
  878. Change;
  879. end;
  880. procedure TKOLTimer.SetInterval(const Value: Integer);
  881. begin
  882. asm
  883. jmp @@e_signature
  884. DB '#$signature$#', 0
  885. DB 'TKOLTimer.SetInterval', 0
  886. @@e_signature:
  887. end;
  888. FInterval := Value;
  889. Change;
  890. end;
  891. procedure TKOLTimer.SetMultimedia(const Value: Boolean);
  892. begin
  893. FMultimedia := Value;
  894. Change;
  895. end;
  896. procedure TKOLTimer.SetOnTimer(const Value: TOnEvent);
  897. begin
  898. asm
  899. jmp @@e_signature
  900. DB '#$signature$#', 0
  901. DB 'TKOLTimer.SetOnTimer', 0
  902. @@e_signature:
  903. end;
  904. FOnTimer := Value;
  905. Change;
  906. end;
  907. procedure TKOLTimer.SetPeriodic(const Value: Boolean);
  908. begin
  909. FPeriodic := Value;
  910. Change;
  911. end;
  912. procedure TKOLTimer.SetResolution(const Value: Integer);
  913. begin
  914. FResolution := Value;
  915. Change;
  916. end;
  917. procedure TKOLTimer.SetupFirst(SL: TStringList; const AName,
  918. AParent, Prefix: String);
  919. begin
  920. asm
  921. jmp @@e_signature
  922. DB '#$signature$#', 0
  923. DB 'TKOLTimer.SetupFirst', 0
  924. @@e_signature:
  925. end;
  926. if Multimedia then
  927. begin
  928. SL.Add( Prefix + AName + ' := NewMMTimer( ' + IntToStr( Interval ) + ' );' );
  929. if not Periodic then
  930. SL.Add( Prefix + 'PMMTimer(' + AName + ').Periodic := FALSE;' );
  931. if Resolution > 0 then
  932. SL.Add( Prefix + 'PMMTimer(' + AName + ').Resolution := ' + IntToStr( Resolution ) + ';' );
  933. end
  934. else
  935. SL.Add( Prefix + AName + ' := NewTimer( ' + IntToStr( Interval ) + ' );' );
  936. //AssignEvents( SL, AName );
  937. GenerateTag( SL, AName, Prefix );
  938. end;
  939. procedure TKOLTimer.SetupLast(SL: TStringList; const AName,
  940. AParent, Prefix: String);
  941. begin
  942. asm
  943. jmp @@e_signature
  944. DB '#$signature$#', 0
  945. DB 'TKOLTimer.SetupLast', 0
  946. @@e_signature:
  947. end;
  948. if Enabled then
  949. SL.Add( Prefix + AName + '.Enabled := True;' );
  950. end;
  951. function TKOLTimer.TypeName: String;
  952. begin
  953. if Multimedia then Result := 'TMMTimer'
  954. else Result := inherited TypeName;
  955. end;
  956. { TKOLImageList }
  957. procedure TKOLImageList.Assign(Value: TPersistent);
  958. var IL: TKOLImageList;
  959. begin
  960. asm
  961. jmp @@e_signature
  962. DB '#$signature$#', 0
  963. DB 'TKOLImageList.Assign', 0
  964. @@e_signature:
  965. end;
  966. if (Value <> nil) and (Value is TKOLImageList) then
  967. begin
  968. IL := Value as TKOLImageList;
  969. FImgWidth := IL.ImgWidth;
  970. FImgHeight := IL.ImgHeight;
  971. FCount := IL.Count;
  972. FBitmap.Assign( IL.Bitmap );
  973. FSystemImageList := IL.SystemImageList;
  974. FTransparentColor := IL.TransparentColor;
  975. end
  976. else
  977. inherited;
  978. Change;
  979. end;
  980. procedure TKOLImageList.AssignBitmapToKOLImgList;
  981. var R: Integer;
  982. TmpBmp: TBitmap;
  983. begin
  984. if FKOLImgList = nil then Exit;
  985. if Bitmap <> nil then
  986. begin
  987. //Bitmap.SaveToFile( 'c:\test1.bmp' );
  988. //ShowMessage( 'Bitmap.Handle=' + Int2Str( Bitmap.Handle ) );
  989. FKOLImgList.Clear;
  990. FKOLImgList.Colors := Colors;
  991. //FKOLImgList.BkColor := Color2RGB( BkColor );
  992. FKOLImgList.ImgWidth := ImgWidth;
  993. FKOLImgList.ImgHeight := ImgHeight;
  994. {$IFDEF _D3orHigher}
  995. {Bitmap.HandleType := bmDIB;
  996. Bitmap.PixelFormat := pf24bit;}
  997. {$ENDIF}
  998. //ShowMessage( Int2Hex( Color2RGB( BkColor ), 8 ) );
  999. if not Bitmap.Empty then
  1000. begin
  1001. //Bitmap.SaveToFile( 'c:\test2.bmp' );
  1002. TmpBmp := TBitmap.Create;
  1003. TRY
  1004. TmpBmp.Assign( Bitmap );
  1005. if Masked then
  1006. R := FKOLImgList.AddMasked( TmpBmp.Handle, Color2RGB( TransparentColor ) )
  1007. else
  1008. begin
  1009. FKOLImgList.Masked := FALSE;
  1010. R := FKOLImgList.Add( TmpBmp.Handle, 0 );
  1011. end;
  1012. if R < 0 then
  1013. ShowMessage( 'Error adding bitmap: ' + SysErrorMessage( GetLastError ) )
  1014. else
  1015. begin
  1016. DoNotifyLinkedComponents( noChanged );
  1017. end;
  1018. FINALLY
  1019. TmpBmp.Free;
  1020. END;
  1021. //Bitmap.SaveToFile( 'c:\test3.bmp' );
  1022. //ShowMessage( 'Result := ' + Int2Str( R ) );
  1023. //ShowMessage( 'FKOLImgList.Handle=' + Int2Str( FKOLImgList.Handle ) );
  1024. end;
  1025. end;
  1026. end;
  1027. {procedure TKOLImageList.BitmapChanged(Sender: TObject);
  1028. begin
  1029. AssignBitmapToKOLImgList;
  1030. end;}
  1031. procedure TKOLImageList.Clear;
  1032. begin
  1033. asm
  1034. jmp @@e_signature
  1035. DB '#$signature$#', 0
  1036. DB 'TKOLImageList.Clear', 0
  1037. @@e_signature:
  1038. end;
  1039. if FBitmap <> nil then
  1040. begin
  1041. FBitmap.Width := 0;
  1042. FBitmap.Height := 0;
  1043. end;
  1044. FCount := 0;
  1045. end;
  1046. constructor TKOLImageList.Create( AOwner: TComponent );
  1047. begin
  1048. asm
  1049. jmp @@e_signature
  1050. DB '#$signature$#', 0
  1051. DB 'TKOLImageList.Create', 0
  1052. @@e_signature:
  1053. end;
  1054. inherited Create( AOwner );
  1055. FBkColor := clNone;
  1056. FBitmap := TBitmap.Create;
  1057. //FBitmap.OnChange := BitmapChanged;
  1058. FImgWidth := 32;
  1059. FImgHeight := 32;
  1060. FTransparentColor := clDefault;
  1061. FMasked := TRUE;
  1062. NeedFree := False; // ImageList in KOL destroyes self when its parent
  1063. // control is destroyed - automatically.
  1064. fCreationPriority := 10;
  1065. end;
  1066. destructor TKOLImageList.Destroy;
  1067. begin
  1068. asm
  1069. jmp @@e_signature
  1070. DB '#$signature$#', 0
  1071. DB 'TKOLImageList.Destroy', 0
  1072. @@e_signature:
  1073. end;
  1074. FKOLImgList.Free;
  1075. FBitmap.Free;
  1076. inherited;
  1077. end;
  1078. function TKOLImageList.GetBitmap: TBitmap;
  1079. begin
  1080. asm
  1081. jmp @@e_signature
  1082. DB '#$signature$#', 0
  1083. DB 'TKOLImageList.GetBitmap', 0
  1084. @@e_signature:
  1085. end;
  1086. if SystemImageList then
  1087. Result := nil
  1088. else
  1089. Result := FBitmap;
  1090. end;
  1091. function TKOLImageList.GetImageListHandle: THandle;
  1092. begin
  1093. if FKOLImgList = nil then
  1094. begin
  1095. FKOLImgList := NewImageList( nil );
  1096. AssignBitmapToKOLImgList;
  1097. end;
  1098. Result := FKOLImgList.Handle;
  1099. end;
  1100. function TKOLImageList.GetTransparentColor: TColor;
  1101. begin
  1102. asm
  1103. jmp @@e_signature
  1104. DB '#$signature$#', 0
  1105. DB 'TKOLImageList.GetTransparentColor', 0
  1106. @@e_signature:
  1107. end;
  1108. Result := FTransparentColor;
  1109. if Result = clDefault then
  1110. if FBitmap <> nil then
  1111. if (FBitmap.Width <> 0) and (FBitmap.Height <> 0) then
  1112. Result := FBitmap.Canvas.Pixels[ 0, FBitmap.Height - 1 ];
  1113. end;
  1114. procedure TKOLImageList.SetBitmap(const Value: TBitmap);
  1115. {$IFDEF _D2}
  1116. var KOLBmp: KOL.PBitmap;
  1117. {$ENDIF}
  1118. begin
  1119. asm
  1120. jmp @@e_signature
  1121. DB '#$signature$#', 0
  1122. DB 'TKOLImageList.SetBitmap', 0
  1123. @@e_signature:
  1124. end;
  1125. if FBitmap = Value then Exit;
  1126. FBitmap.Assign( Value );
  1127. if (FBitmap.Height <> 0) and (FBitmap.Width <> 0) then
  1128. begin
  1129. FImgHeight := FBitmap.Height;
  1130. {AK->}if FImgWidth<=0 then{<-AK} FImgWidth := FImgHeight;
  1131. FCount := FBitmap.Width div FImgWidth;
  1132. end;
  1133. {$IFDEF _D2}
  1134. KOLBmp := NewBitmap( Value.Width, Value.Height );
  1135. TRY
  1136. KOLBmp.HandleType := KOL.bmDIB;
  1137. KOLBmp.PixelFormat := KOL.pf32bit;
  1138. BitBlt( KOLBmp.Canvas.Handle, 0, 0, Value.Width, Value.Height,
  1139. Value.Canvas.Handle, 0, 0, SrcCopy );
  1140. case CountSystemColorsUsedInBitmap( KOLBmp ) of
  1141. KOL.pf1bit, KOL.pf4bit: Colors := ilcColor4;
  1142. KOL.pf8bit: Colors := ilcColor8;
  1143. KOL.pf32bit: Colors := ilcColor32;
  1144. else Colors := ilcColor24;
  1145. end;
  1146. FINALLY
  1147. KOLBmp.Free;
  1148. END;
  1149. {$ELSE}
  1150. if FBitmap.HandleType = bmDDB then
  1151. Colors := ilcColorDDB
  1152. else
  1153. begin
  1154. case FBitmap.PixelFormat of
  1155. pf1bit,
  1156. pf4bit: Colors := ilcColor4;
  1157. pf8bit: Colors := ilcColor8;
  1158. pf32bit: Colors := ilcColor32;
  1159. //pf24bit:
  1160. else Colors := ilcColor24;
  1161. end;
  1162. end;
  1163. {$ENDIF}
  1164. if (FBitmap.Height <> 0) and (FBitmap.Width <> 0) then
  1165. begin
  1166. TransparentColor := FBitmap.Canvas.Pixels[ 0, FBitmap.Height - 1 ];
  1167. end;
  1168. if FKOLImgList <> nil then
  1169. AssignBitmapToKOLImgList;
  1170. Change;
  1171. end;
  1172. procedure TKOLImageList.SetBkColor(const Value: TColor);
  1173. begin
  1174. asm
  1175. jmp @@e_signature
  1176. DB '#$signature$#', 0
  1177. DB 'TKOLImageList.SetBkColor', 0
  1178. @@e_signature:
  1179. end;
  1180. FBkColor := Value;
  1181. AssignBitmapToKOLImgList;
  1182. Change;
  1183. end;
  1184. procedure TKOLImageList.SetColors(const Value: TImageListColors);
  1185. //{$IFDEF _D2}
  1186. var KOLBmp: KOL.PBitmap;
  1187. //{$ENDIF}
  1188. begin
  1189. asm
  1190. jmp @@e_signature
  1191. DB '#$signature$#', 0
  1192. DB 'TKOLImageList.SetColors', 0
  1193. @@e_signature:
  1194. end;
  1195. if FColors = Value then Exit;
  1196. FColors := Value;
  1197. if FBitmap = nil then Exit;
  1198. if FBitmap.Width * FBitmap.Height = 0 then Exit;
  1199. //{$IFDEF _D2}
  1200. KOLBmp := NewBitmap( FBitmap.Width, FBitmap.Height );
  1201. TRY
  1202. KOLBmp.HandleType := KOL.bmDIB;
  1203. KOLBmp.PixelFormat := KOL.pf32bit;
  1204. BitBlt( KOLBmp.Canvas.Handle, 0, 0, FBitmap.Width, FBitmap.Height,
  1205. FBitmap.Canvas.Handle, 0, 0, SrcCopy );
  1206. case Value of
  1207. ilcColor4: KOLBmp.PixelFormat := KOL.pf4bit;
  1208. ilcColor8: KOLBmp.PixelFormat := KOL.pf8bit;
  1209. ilcColor24: KOLBmp.PixelFormat := KOL.pf24bit;
  1210. ilcColor32: KOLBmp.PixelFormat := KOL.pf32bit;
  1211. else KOLBmp.HandleType := KOL.bmDDB;
  1212. end;
  1213. FBitmap.Handle := KOLBmp.ReleaseHandle;
  1214. FINALLY
  1215. KOLBmp.Free;
  1216. END;
  1217. (*{$ELSE}
  1218. if Assigned( FBitmap ) then
  1219. begin
  1220. if FColors = ilcColorDDB then
  1221. FBitmap.HandleType := bmDDB
  1222. else
  1223. begin
  1224. FBitmap.HandleType := bmDIB;
  1225. case Value of
  1226. ilcColor4: FBitmap.PixelFormat := pf4bit;
  1227. ilcColor8: FBitmap.PixelFormat := pf8bit;
  1228. ilcColor24: FBitmap.PixelFormat := pf24bit;
  1229. ilcColor32: FBitmap.PixelFormat := pf32bit;
  1230. end;
  1231. end;
  1232. end;
  1233. {$ENDIF}*)
  1234. Change;
  1235. end;
  1236. procedure TKOLImageList.SetCount(const Value: Integer);
  1237. begin
  1238. asm
  1239. jmp @@e_signature
  1240. DB '#$signature$#', 0
  1241. DB 'TKOLImageList.SetCount', 0
  1242. @@e_signature:
  1243. end;
  1244. FCount := Value;
  1245. if Value > 0 then
  1246. begin
  1247. {AK->} if FImgWidth <= 0 then {<-AK} // change by Andrzej Kubaszek 28-Jan-2002
  1248. FImgWidth := FImgHeight;
  1249. if FBitmap <> nil then
  1250. if FBitmap.Width > 0 then
  1251. FImgWidth := FBitmap.Width div FCount;
  1252. end;
  1253. Change;
  1254. end;
  1255. procedure TKOLImageList.SetImgHeight(Value: Integer);
  1256. var I: Integer;
  1257. begin
  1258. asm
  1259. jmp @@e_signature
  1260. DB '#$signature$#', 0
  1261. DB 'TKOLImageList.SetImgHeight', 0
  1262. @@e_signature:
  1263. end;
  1264. if Value < 0 then
  1265. Value := 0;
  1266. if SystemImageList then
  1267. if Value >= 32 then
  1268. Value := 32
  1269. else
  1270. Value := 16
  1271. else
  1272. if FBitmap <> nil then
  1273. begin
  1274. if not FBitmap.Empty then
  1275. if (FBitmap.Height <> 0) and (FBitmap.Width <> 0) then
  1276. if Value <> FBitmap.Height then
  1277. Value := FBitmap.Height;
  1278. end;
  1279. if FImgHeight = Value then Exit;
  1280. if Count > 0 then
  1281. if not( csLoading in ComponentState ) then
  1282. begin
  1283. I := MessageBox( 0, 'Changing image list height will lead to clearing it. Are ' +
  1284. 'You sure You want to change height now?',
  1285. 'TKOLImageList.ImgHeight change', MB_YESNO or
  1286. MB_DEFBUTTON2 or MB_SETFOREGROUND );
  1287. if I = ID_NO then Exit;
  1288. Clear;
  1289. end;
  1290. FImgHeight := Value;
  1291. if SystemImageList then
  1292. FImgWidth := FImgHeight;
  1293. Change;
  1294. end;
  1295. procedure TKOLImageList.SetImgWidth(Value: Integer);
  1296. var I: Integer;
  1297. begin
  1298. asm
  1299. jmp @@e_signature
  1300. DB '#$signature$#', 0
  1301. DB 'TKOLImageList.SetImgWidth', 0
  1302. @@e_signature:
  1303. end;
  1304. if Value < 0 then Value := 0;
  1305. if SystemImageList then
  1306. begin
  1307. if Value >= 32 then
  1308. Value := 32
  1309. else
  1310. Value := 16;
  1311. end
  1312. else
  1313. if FBitmap <> nil then
  1314. begin
  1315. if not FBitmap.Empty then
  1316. if (FBitmap.Width <> 0) and (FBitmap.Height <> 0) then
  1317. if Value > FBitmap.Width then
  1318. Value := FBitmap.Width;
  1319. end;
  1320. if FImgWidth = Value then Exit;
  1321. if Count > 0 then
  1322. if not( csLoading in ComponentState ) then
  1323. begin
  1324. I := MessageBox( 0, 'Changing image list width will lead to clearing it. Are ' +
  1325. 'You sure You want to change width now?',
  1326. 'TKOLImageList.ImgWidth change', MB_YESNO or
  1327. MB_DEFBUTTON2 or MB_SETFOREGROUND );
  1328. if I = ID_NO then Exit;
  1329. Clear;
  1330. end;
  1331. FImgWidth := Value;
  1332. if SystemImageList then
  1333. FImgHeight := FImgWidth;
  1334. Change;
  1335. end;
  1336. procedure TKOLImageList.SetMasked(const Value: Boolean);
  1337. begin
  1338. asm
  1339. jmp @@e_signature
  1340. DB '#$signature$#', 0
  1341. DB 'TKOLImageList.SetMasked', 0
  1342. @@e_signature:
  1343. end;
  1344. FMasked := Value;
  1345. Change;
  1346. end;
  1347. procedure TKOLImageList.SetSystemImageList(const Value: Boolean);
  1348. begin
  1349. asm
  1350. jmp @@e_signature
  1351. DB '#$signature$#', 0
  1352. DB 'TKOLImageList.SetSystemImageList', 0
  1353. @@e_signature:
  1354. end;
  1355. if Value = FSystemImageList then Exit;
  1356. FSystemImageList := Value;
  1357. if Value then
  1358. begin
  1359. Clear;
  1360. SetImgHeight( ImgHeight );
  1361. SetImgWidth( ImgHeight );
  1362. end
  1363. else
  1364. Clear;
  1365. Change;
  1366. end;
  1367. procedure TKOLImageList.SetTransparentColor(const Value: TColor);
  1368. begin
  1369. asm
  1370. jmp @@e_signature
  1371. DB '#$signature$#', 0
  1372. DB 'TKOLImageList.SetTransparentColor', 0
  1373. @@e_signature:
  1374. end;
  1375. FTransparentColor := Value;
  1376. AssignBitmapToKOLImgList;
  1377. Change;
  1378. end;
  1379. procedure TKOLImageList.SetupFirst(SL: TStringList; const AName,
  1380. AParent, Prefix: String);
  1381. const Booleans: array[ Boolean ] of String = ( 'False', 'True' );
  1382. const ColorsValues: array[ TImageListColors ] of String = ( 'ilcColor', 'ilcColor4',
  1383. 'ilcColor8', 'ilcColor16', 'ilcColor24', 'ilcColor32', 'ilcColorDDB',
  1384. 'ilcDefault' );
  1385. var RsrcName, RsrcFile: String;
  1386. begin
  1387. asm
  1388. jmp @@e_signature
  1389. DB '#$signature$#', 0
  1390. DB 'TKOLImageList.SetupFirst', 0
  1391. @@e_signature:
  1392. end;
  1393. SL.Add( Prefix + AName + ' := NewImageList( ' + AParent + ' );' );
  1394. GenerateTag( SL, AName, Prefix );
  1395. if SystemImageList then
  1396. SL.Add( Prefix + AName + '.LoadSystemIcons( ' + Booleans[ ImgHeight = 16 ] + ' );' )
  1397. else
  1398. begin
  1399. if Colors <> ilcDefault then
  1400. SL.Add( Prefix + AName + '.Colors := ' + ColorsValues[ Colors ] + ';' );
  1401. if not Masked then
  1402. begin
  1403. SL.Add( Prefix + AName + '.Masked := FALSE;' );
  1404. if BkColor <> clNone then
  1405. SL.Add( Prefix + AName + '.BkColor := ' + Color2Str( BkColor ) +
  1406. ';' );
  1407. end;
  1408. if FImgWidth <> 32 then
  1409. SL.Add( Prefix + ' ' + AName + '.ImgWidth := ' + IntToStr( FImgWidth ) + ';' );
  1410. if FImgHeight <> 32 then
  1411. SL.Add( Prefix + ' ' + AName + '.ImgHeight := ' + IntToStr( FImgHeight ) + ';' );
  1412. end;
  1413. if (FBitmap.Width <> 0) and (FBitmap.Height <> 0) then
  1414. begin
  1415. if (FImgHeight = 32) and (FImgWidth <> FImgHeight) then
  1416. SL.Add( Prefix + ' ' + AName + '.ImgWidth := ' + IntToStr( FImgWidth ) + ';' );
  1417. RsrcName := UpperCase( ParentKOLForm.FormName + '_' + Name );
  1418. RsrcFile := ParentKOLForm.FormName + '_' + Name;
  1419. SL.Add( Prefix + ' {$R ' + RsrcFile + '.res}' );
  1420. if Masked then
  1421. SL.Add( Prefix + AName + '.AddMasked( LoadBmp( hInstance, ''' +
  1422. RsrcName + ''', ' +
  1423. AName + ' ), ' + Color2Str( TransparentColor ) + ' );' )
  1424. else
  1425. SL.Add( Prefix + AName + '.Add( LoadBmp( hInstance, ''' +
  1426. RsrcName + ''', ' +
  1427. AName + ' ), 0 );' );
  1428. //Rpt( 'Generating resource: ' + ProjectSourcePath + RsrcFile + '.res' );
  1429. GenerateBitmapResource( FBitmap, RsrcName, RsrcFile, fUpdated );
  1430. end;
  1431. end;
  1432. procedure TKOLImageList.SetupLast(SL: TStringList; const AName, AParent,
  1433. Prefix: String);
  1434. begin
  1435. asm
  1436. jmp @@e_signature
  1437. DB '#$signature$#', 0
  1438. DB 'TKOLImageList.SetupLast', 0
  1439. @@e_signature:
  1440. end;
  1441. inherited;
  1442. end;
  1443. { TKOLImageListEditor }
  1444. procedure TKOLImageListEditor.Edit;
  1445. var IL: TImageList; //Invisible;
  1446. {$IFDEF _D6orHigher}
  1447. ILCE: IComponentEditor;
  1448. {$ELSE}
  1449. ILCE: TComponentEditor;
  1450. {$ENDIF}
  1451. ILH: THandle;
  1452. KIL: TKOLImageList;
  1453. KName: String;
  1454. I: Integer;
  1455. //TrColor: TColor;
  1456. begin
  1457. asm
  1458. jmp @@e_signature
  1459. DB '#$signature$#', 0
  1460. DB 'TKOLImageListEditor.Edit', 0
  1461. @@e_signature:
  1462. end;
  1463. if Component = nil then Exit;
  1464. if not ( Component is TKOLImageList ) then Exit;
  1465. KIL := Component as TKOLImageList;
  1466. if KIL.SystemImageList then
  1467. begin
  1468. ShowMessage( 'It is not possible to edit system image list!' );
  1469. Exit;
  1470. end;
  1471. IL := TImageList{Invisible}.Create( {KIL.ParentForm} KIL );
  1472. KName := KIL.Name;
  1473. IL.Name := KName + '_edit';
  1474. {IL.Width := KIL.ImgWidth;
  1475. IL.Height := KIL.ImgHeight;}
  1476. try
  1477. {$IFNDEF _D2}
  1478. //KIL.Bitmap.HandleType := bmDIB;
  1479. CASE KIL.Colors OF
  1480. ilcColor4 : I := ILC_COLOR4;
  1481. ilcColor8 : I := ILC_COLOR8;
  1482. ilcColor16 : I := ILC_COLOR16;
  1483. ilcColor24 : I := ILC_COLOR24;
  1484. ilcColor32 : I := ILC_COLOR32;
  1485. else I := ILC_COLOR;
  1486. END;
  1487. {case KIL.Bitmap.PixelFormat of
  1488. pf1bit, pf4bit: I := ILC_COLOR4;
  1489. pf8bit: I := ILC_COLOR8;
  1490. pf15bit, pf16bit: I := ILC_COLOR16;
  1491. pf24bit: I := ILC_COLOR24;
  1492. pf32bit: I := ILC_COLOR32;
  1493. else I := ILC_COLOR;
  1494. end;}
  1495. {$ELSE}
  1496. I := ILC_COLOR;
  1497. {$ENDIF}
  1498. //I := ILC_COLOR8;
  1499. if KIL.TransparentColor = clNone then
  1500. ILH := ImageList_Create( KIL.ImgWidth, KIL.ImgHeight, I, KIL.Count, 1 )
  1501. else
  1502. ILH := ImageList_Create( KIL.ImgWidth, KIL.ImgHeight, I or ILC_MASK,
  1503. KIL.Count, 1 );
  1504. if ILH <> 0 then
  1505. begin
  1506. if KIL.Masked then
  1507. ImageList_AddMasked( ILH, KIL.Bitmap.Handle, Color2RGB( KIL.TransparentColor ) )
  1508. else
  1509. ImageList_Add( ILH, KIL.Bitmap.Handle, 0 );
  1510. {
  1511. if KIL.TransparentColor = clNone then
  1512. ImageList_Add( ILH, KIL.Bitmap.Handle, 0 )
  1513. else
  1514. begin
  1515. TrColor := KIL.TransparentColor;
  1516. Tmp := TBitmap.Create;
  1517. Tmp.Assign( KIL.Bitmap );
  1518. Tmp.Mask( TrColor );
  1519. try
  1520. //TrColor := KIL.Bitmap.TransparentColor;
  1521. //TrColor := KIL.Bitmap.Canvas.Pixels[ 0, KIL.Bitmap.Height - 1 ];
  1522. //ShowMessage( 'Èñïîëüçóåì ïðîçðà÷íûé öâåò: ' + Int2Hex( Color2RGB( TrColor ), 8 ) );
  1523. //ImageList_AddMasked( ILH, KIL.Bitmap.Handle, Color2RGB( TrColor ) );
  1524. ImageList_Add( ILH, KIL.Bitmap.Handle, Tmp.Handle );
  1525. finally
  1526. Tmp.Free;
  1527. end;
  1528. end;
  1529. }
  1530. IL.Handle := ILH;
  1531. IL.ShareImages := False;
  1532. //Rpt( 'Attempt to get component editor' );
  1533. ILCE := GetComponentEditor( IL, Designer );
  1534. if ILCE <> nil then
  1535. try
  1536. //Rpt( 'ILCE obtained, try to call editor' );
  1537. ILCE.Edit;
  1538. Rpt( 'Image list ' + KIL.Name + ' edited.' );
  1539. if KIL.Bitmap.Empty then
  1540. begin
  1541. KIL.Bitmap := TBitmap.Create;
  1542. //KIL.Bitmap.PixelFormat := pf24bit;
  1543. Rpt( 'Bitmap was empty - created.' );
  1544. end;
  1545. KIL.Bitmap.Height := IL.Height;
  1546. KIL.Bitmap.Width := IL.Width * IL.Count;
  1547. KIL.Bitmap.Canvas.Brush.Color := KIL.TransparentColor;
  1548. KIL.Bitmap.Canvas.FillRect( Rect( 0, 0, KIL.Bitmap.Width, KIL.Bitmap.Height ) );
  1549. for I := 0 to IL.Count - 1 do
  1550. IL.Draw( KIL.Bitmap.Canvas, I * IL.Width, 0, I );
  1551. KIL.FCount := IL.Count;
  1552. KIL.AssignBitmapToKOLImgList;
  1553. KIL.Change;
  1554. finally
  1555. {$IFNDEF _D6orHigher}
  1556. ILCE.Free;
  1557. {$ENDIF}
  1558. end;
  1559. end;
  1560. finally
  1561. IL.Free;
  1562. end;
  1563. end;
  1564. procedure TKOLImageListEditor.ExecuteVerb(Index: Integer);
  1565. begin
  1566. asm
  1567. jmp @@e_signature
  1568. DB '#$signature$#', 0
  1569. DB 'TKOLImageListEditor.ExecuteVerb', 0
  1570. @@e_signature:
  1571. end;
  1572. Edit;
  1573. end;
  1574. function TKOLImageListEditor.GetVerb(Index: Integer): string;
  1575. begin
  1576. asm
  1577. jmp @@e_signature
  1578. DB '#$signature$#', 0
  1579. DB 'TKOLImageListEditor.GetVerb', 0
  1580. @@e_signature:
  1581. end;
  1582. Result := '&Editor';
  1583. end;
  1584. function TKOLImageListEditor.GetVerbCount: Integer;
  1585. begin
  1586. asm
  1587. jmp @@e_signature
  1588. DB '#$signature$#', 0
  1589. DB 'TKOLImageListEditor.GetVerbCount', 0
  1590. @@e_signature:
  1591. end;
  1592. Result := 1;
  1593. end;
  1594. { TKOLOpenSaveDialog }
  1595. constructor TKOLOpenSaveDialog.Create(AOwner: TComponent);
  1596. begin
  1597. asm
  1598. jmp @@e_signature
  1599. DB '#$signature$#', 0
  1600. DB 'TKOLOpenSaveDialog.Create', 0
  1601. @@e_signature:
  1602. end;
  1603. inherited;
  1604. Options := DefOpenSaveDlgOptions;
  1605. OpenDialog := TRUE;
  1606. end;
  1607. procedure TKOLOpenSaveDialog.SetDefExtension(const Value: String);
  1608. begin
  1609. asm
  1610. jmp @@e_signature
  1611. DB '#$signature$#', 0
  1612. DB 'TKOLOpenSaveDialog.SetDefExtension', 0
  1613. @@e_signature:
  1614. end;
  1615. FDefExtension := Value;
  1616. Change;
  1617. end;
  1618. procedure TKOLOpenSaveDialog.SetFilter(const Value: String);
  1619. begin
  1620. asm
  1621. jmp @@e_signature
  1622. DB '#$signature$#', 0
  1623. DB 'TKOLOpenSaveDialog.SetFilter', 0
  1624. @@e_signature:
  1625. end;
  1626. FFilter := Value;
  1627. Change;
  1628. end;
  1629. procedure TKOLOpenSaveDialog.SetFilterIndex(const Value: Integer);
  1630. begin
  1631. asm
  1632. jmp @@e_signature
  1633. DB '#$signature$#', 0
  1634. DB 'TKOLOpenSaveDialog.SetFilterIndex', 0
  1635. @@e_signature:
  1636. end;
  1637. FFilterIndex := Value;
  1638. if FFilterIndex < 0 then
  1639. FFilterIndex := 0;
  1640. Change;
  1641. end;
  1642. procedure TKOLOpenSaveDialog.SetInitialDir(const Value: String);
  1643. begin
  1644. asm
  1645. jmp @@e_signature
  1646. DB '#$signature$#', 0
  1647. DB 'TKOLOpenSaveDialog.SetInitialDir', 0
  1648. @@e_signature:
  1649. end;
  1650. FInitialDir := Value;
  1651. Change;
  1652. end;
  1653. procedure TKOLOpenSaveDialog.SetOpenDialog(const Value: Boolean);
  1654. begin
  1655. asm
  1656. jmp @@e_signature
  1657. DB '#$signature$#', 0
  1658. DB 'TKOLOpenSaveDialog.SetOpenDialog', 0
  1659. @@e_signature:
  1660. end;
  1661. FOpenDialog := Value;
  1662. Change;
  1663. end;
  1664. procedure TKOLOpenSaveDialog.SetOptions(const Value: TOpenSaveOptions);
  1665. begin
  1666. asm
  1667. jmp @@e_signature
  1668. DB '#$signature$#', 0
  1669. DB 'TKOLOpenSaveDialog.SetOptions', 0
  1670. @@e_signature:
  1671. end;
  1672. FOptions := Value;
  1673. Change;
  1674. end;
  1675. procedure TKOLOpenSaveDialog.SetTemplateName(const Value: String);
  1676. begin
  1677. FTemplateName := Value;
  1678. Change;
  1679. end;
  1680. procedure TKOLOpenSaveDialog.SetTitle(const Value: String);
  1681. begin
  1682. asm
  1683. jmp @@e_signature
  1684. DB '#$signature$#', 0
  1685. DB 'TKOLOpenSaveDialog.SetTitle', 0
  1686. @@e_signature:
  1687. end;
  1688. FTitle := Value;
  1689. Change;
  1690. end;
  1691. procedure TKOLOpenSaveDialog.SetupFirst(SL: TStringList; const AName,
  1692. AParent, Prefix: String);
  1693. var S: String;
  1694. begin
  1695. asm
  1696. jmp @@e_signature
  1697. DB '#$signature$#', 0
  1698. DB 'TKOLOpenSaveDialog.SetupFirst', 0
  1699. @@e_signature:
  1700. end;
  1701. S := '';
  1702. if Options <> DefOpenSaveDlgOptions then
  1703. begin
  1704. if OSCreatePrompt in Options then
  1705. S := 'OSCreatePrompt';
  1706. if OSExtensionDiffent in Options then
  1707. S := S + ', OSExtensionDiffent';
  1708. if OSFileMustExist in Options then
  1709. S := S + ', OSFileMustExist';
  1710. if OSHideReadonly in Options then
  1711. S := S + ', OSHideReadonly';
  1712. if OSNoChangedir in Options then
  1713. S := S + ', OSNoChangedir';
  1714. if OSNoReferenceLinks in Options then
  1715. S := S + ', OSNoReferenceLinks';
  1716. if OSAllowMultiSelect in Options then
  1717. S := S + ', OSAllowMultiSelect';
  1718. if OSNoNetworkButton in Options then
  1719. S := S + ', OSNoNetworkButton';
  1720. if OSNoReadonlyReturn in Options then
  1721. S := S + ', OSNoReadonlyReturn';
  1722. if OSOverwritePrompt in Options then
  1723. S := S + ', OSOverwritePrompt';
  1724. if OSPathMustExist in Options then
  1725. S := S + ', OSPathMustExist';
  1726. if OSReadonly in Options then
  1727. S := S + ', OSReadonly';
  1728. if OSNoValidate in Options then
  1729. S := S + ', OSNoValidate';
  1730. if OSTemplate in Options then
  1731. S := S + ', OSTemplate';
  1732. if OSHook in Options then
  1733. S := S + ', OSHook';
  1734. if S <> '' then
  1735. if S[ 1 ] = ',' then
  1736. S := Trim( Copy( S, 2, MaxInt ) );
  1737. end;
  1738. SL.Add( Prefix + AName + ' := NewOpenSaveDialog( ' + StringConstant( 'Title', Title )
  1739. + ', ' + StringConstant( 'InitialDir', InitialDir ) + ', [ ' + S + ' ] );' );
  1740. GenerateTag( SL, AName, Prefix );
  1741. if Filter <> '' then
  1742. SL.Add( Prefix + ' ' + AName + '.Filter := ' + StringConstant( 'Filter', Filter ) + ';' );
  1743. if not OpenDialog then
  1744. SL.Add( Prefix + ' ' + AName + '.OpenDialog := FALSE;' );
  1745. if DefExtension <> '' then
  1746. SL.Add( Prefix + ' ' + AName + '.DefExtension := ' + StringConstant( 'DefExtension', DefExtension ) + ';' );
  1747. if TemplateName <> '' then
  1748. SL.Add( Prefix + ' ' + AName + '.TemplateName := ' + StringConstant( 'TemplateName', TemplateName ) + ';' );
  1749. end;
  1750. { TKOLFileFilter }
  1751. procedure TKOLOpenSaveDialog.SetupLast(SL: TStringList; const AName,
  1752. AParent, Prefix: String);
  1753. begin
  1754. asm
  1755. jmp @@e_signature
  1756. DB '#$signature$#', 0
  1757. DB 'TKOLOpenSaveDialog.SetupLast', 0
  1758. @@e_signature:
  1759. end;
  1760. SL.Add( Prefix + ' ' + AName + '.WndOwner := Result.Form.GetWindowHandle;' );
  1761. end;
  1762. { TKOLFileFilter }
  1763. procedure TKOLFileFilter.Edit;
  1764. var Dlg: TfmFileFilterEditor;
  1765. begin
  1766. asm
  1767. jmp @@e_signature
  1768. DB '#$signature$#', 0
  1769. DB 'TKOLFileFilter.Edit', 0
  1770. @@e_signature:
  1771. end;
  1772. if GetComponent( 0 ) = nil then Exit;
  1773. Dlg := TfmFileFilterEditor.Create( Application );
  1774. Dlg.Caption := (GetComponent( 0 ) as TComponent).Name + '.Filter';
  1775. Dlg.Filter := GetStrValue;
  1776. Dlg.ShowModal;
  1777. if Dlg.ModalResult = mrOK then
  1778. begin
  1779. SetStrValue( Dlg.Filter );
  1780. end;
  1781. Dlg.Free;
  1782. end;
  1783. function TKOLFileFilter.GetAttributes: TPropertyAttributes;
  1784. begin
  1785. asm
  1786. jmp @@e_signature
  1787. DB '#$signature$#', 0
  1788. DB 'TKOLFileFilter.GetAttributes', 0
  1789. @@e_signature:
  1790. end;
  1791. Result := [ paDialog, paReadOnly ];
  1792. end;
  1793. { TKOLOpenDirDialog }
  1794. procedure TKOLOpenDirDialog.AssignEvents(SL: TStringList;
  1795. const AName: String);
  1796. begin
  1797. asm
  1798. jmp @@e_signature
  1799. DB '#$signature$#', 0
  1800. DB 'TKOLOpenDirDialog.AssignEvents', 0
  1801. @@e_signature:
  1802. end;
  1803. inherited;
  1804. DoAssignEvents( SL, AName,
  1805. [ 'OnSelChanged' ],
  1806. [ @ OnSelChanged ] );
  1807. end;
  1808. constructor TKOLOpenDirDialog.Create(AOwner: TComponent);
  1809. begin
  1810. asm
  1811. jmp @@e_signature
  1812. DB '#$signature$#', 0
  1813. DB 'TKOLOpenDirDialog.Create', 0
  1814. @@e_signature:
  1815. end;
  1816. inherited;
  1817. Options := [ odOnlySystemDirs ];
  1818. end;
  1819. procedure TKOLOpenDirDialog.SetCenterOnScreen(const Value: Boolean);
  1820. begin
  1821. asm
  1822. jmp @@e_signature
  1823. DB '#$signature$#', 0
  1824. DB 'TKOLOpenDirDialog.SetCenterOnScreen', 0
  1825. @@e_signature:
  1826. end;
  1827. FCenterOnScreen := Value;
  1828. Change;
  1829. end;
  1830. procedure TKOLOpenDirDialog.SetInitialPath(const Value: String);
  1831. begin
  1832. asm
  1833. jmp @@e_signature
  1834. DB '#$signature$#', 0
  1835. DB 'TKOLOpenDirDialog.SetInitialPath', 0
  1836. @@e_signature:
  1837. end;
  1838. FInitialPath := Value;
  1839. Change;
  1840. end;
  1841. procedure TKOLOpenDirDialog.SetOnSelChanged(const Value: TOnODSelChange);
  1842. begin
  1843. asm
  1844. jmp @@e_signature
  1845. DB '#$signature$#', 0
  1846. DB 'TKOLOpenDirDialog.SetOnSelChanged', 0
  1847. @@e_signature:
  1848. end;
  1849. FOnSelChanged := Value;
  1850. Change;
  1851. end;
  1852. procedure TKOLOpenDirDialog.SetOptions(const Value: TOpenDirOptions);
  1853. begin
  1854. asm
  1855. jmp @@e_signature
  1856. DB '#$signature$#', 0
  1857. DB 'TKOLOpenDirDialog.SetOptions', 0
  1858. @@e_signature:
  1859. end;
  1860. FOptions := Value;
  1861. Change;
  1862. end;
  1863. procedure TKOLOpenDirDialog.SetTitle(const Value: String);
  1864. begin
  1865. asm
  1866. jmp @@e_signature
  1867. DB '#$signature$#', 0
  1868. DB 'TKOLOpenDirDialog.SetTitle', 0
  1869. @@e_signature:
  1870. end;
  1871. FTitle := Value;
  1872. Change;
  1873. end;
  1874. procedure TKOLOpenDirDialog.SetupFirst(SL: TStringList; const AName,
  1875. AParent, Prefix: String);
  1876. var S: String;
  1877. begin
  1878. asm
  1879. jmp @@e_signature
  1880. DB '#$signature$#', 0
  1881. DB 'TKOLOpenDirDialog.SetupFirst', 0
  1882. @@e_signature:
  1883. end;
  1884. if Options <> [ odOnlySystemDirs ] then
  1885. begin
  1886. S := '';
  1887. if odBrowseForComputer in Options then
  1888. S := 'odBrowseForComputer';
  1889. if odBrowseForPrinter in Options then
  1890. S := S + ', odBrowseForPrinter';
  1891. if odDontGoBelowDomain in Options then
  1892. S := S + ', odDontGoBelowDomain';
  1893. if odOnlyFileSystemAncestors in Options then
  1894. S := S + ', odOnlyFileSystemAncestors';
  1895. if odOnlySystemDirs in Options then
  1896. S := S + ', odOnlySystemDirs';
  1897. if odStatusText in Options then
  1898. S := S + ', odStatusText';
  1899. if S <> '' then
  1900. if S[ 1 ] = ',' then
  1901. S := Trim( Copy( S, 2, MaxInt ) );
  1902. end;
  1903. SL.Add( Prefix + AName + ' := NewOpenDirDialog( ' + StringConstant( 'Title', Title ) +
  1904. ', [ ' + S + ' ] );' );
  1905. GenerateTag( SL, AName, Prefix );
  1906. if InitialPath <> '' then
  1907. SL.Add( Prefix + ' ' + AName + '.InitialPath := ' + StringConstant( 'InitialDir', InitialPath )
  1908. + ';' );
  1909. if CenterOnScreen then
  1910. SL.Add( Prefix + ' ' + AName + '.CenterOnScreen := TRUE;' );
  1911. //AssignEvents( SL, AName );
  1912. end;
  1913. procedure TKOLOpenDirDialog.SetupLast(SL: TStringList; const AName,
  1914. AParent, Prefix: String);
  1915. begin
  1916. asm
  1917. jmp @@e_signature
  1918. DB '#$signature$#', 0
  1919. DB 'TKOLOpenDirDialog.SetupLast', 0
  1920. @@e_signature:
  1921. end;
  1922. SL.Add( Prefix + ' ' + AName + '.WndOwner := Result.Form.GetWindowHandle;' );
  1923. end;
  1924. { TKOLColorDialog }
  1925. constructor TKOLColorDialog.Create(AOwner: TComponent);
  1926. var I: Integer;
  1927. begin
  1928. asm
  1929. jmp @@e_signature
  1930. DB '#$signature$#', 0
  1931. DB 'TKOLColorDialog.Create', 0
  1932. @@e_signature:
  1933. end;
  1934. inherited;
  1935. for I := 1 to 16 do
  1936. FCustomColors[ I ] := clWhite;
  1937. end;
  1938. function TKOLColorDialog.GetCustomColor( const Index: Integer ): TColor;
  1939. begin
  1940. asm
  1941. jmp @@e_signature
  1942. DB '#$signature$#', 0
  1943. DB 'TKOLColorDialog.GetCustomColor', 0
  1944. @@e_signature:
  1945. end;
  1946. Result := FCustomColors[ Index ];
  1947. end;
  1948. procedure TKOLColorDialog.SetColorCustomOption(
  1949. const Value: TColorCustomOption);
  1950. begin
  1951. asm
  1952. jmp @@e_signature
  1953. DB '#$signature$#', 0
  1954. DB 'TKOLColorDialog.SetColorCustomOption', 0
  1955. @@e_signature:
  1956. end;
  1957. FColorCustomOption := Value;
  1958. Change;
  1959. end;
  1960. procedure TKOLColorDialog.SetCustomColor(const Index: Integer;
  1961. const Value: TColor);
  1962. begin
  1963. asm
  1964. jmp @@e_signature
  1965. DB '#$signature$#', 0
  1966. DB 'TKOLColorDialog.SetCustomColor', 0
  1967. @@e_signature:
  1968. end;
  1969. FCustomColors[ Index ] := Value;
  1970. Change;
  1971. end;
  1972. procedure TKOLColorDialog.SetupFirst(SL: TStringList; const AName, AParent,
  1973. Prefix: String);
  1974. const
  1975. ColorDialogOptions: array[ TColorCustomOption ] of String = ( 'ccoFullOpen',
  1976. 'ccoShortOpen', 'ccoPreventFullOpen' );
  1977. var I: Integer;
  1978. begin
  1979. asm
  1980. jmp @@e_signature
  1981. DB '#$signature$#', 0
  1982. DB 'TKOLColorDialog.SetupFirst', 0
  1983. @@e_signature:
  1984. end;
  1985. SL.Add( Prefix + AName + ' := NewColorDialog( ' + ColorDialogOptions[ ColorCustomOption ] +
  1986. ' );' );
  1987. GenerateTag( SL, AName, Prefix );
  1988. for I := 1 to 16 do
  1989. begin
  1990. if FCustomColors[ I ] <> clWhite then
  1991. SL.Add( Prefix + ' ' + AName + '.CustomColors[ ' + IntToStr( I ) + ' ] := ' +
  1992. Color2Str( FCustomColors[ I ] ) + ';' );
  1993. end;
  1994. end;
  1995. { TKOLTrayIcon }
  1996. procedure TKOLTrayIcon.AssignEvents(SL: TStringList; const AName: String);
  1997. begin
  1998. asm
  1999. jmp @@e_signature
  2000. DB '#$signature$#', 0
  2001. DB 'TKOLTrayIcon.AssignEvents', 0
  2002. @@e_signature:
  2003. end;
  2004. inherited;
  2005. DoAssignEvents( SL, AName,
  2006. [ 'OnMouse' ],
  2007. [ @ OnMouse ] );
  2008. end;
  2009. constructor TKOLTrayIcon.Create(AOwner: TComponent);
  2010. begin
  2011. asm
  2012. jmp @@e_signature
  2013. DB '#$signature$#', 0
  2014. DB 'TKOLTrayIcon.Create', 0
  2015. @@e_signature:
  2016. end;
  2017. inherited;
  2018. FIcon := TIcon.Create;
  2019. FActive := TRUE;
  2020. fCreationPriority := -10;
  2021. end;
  2022. destructor TKOLTrayIcon.Destroy;
  2023. begin
  2024. asm
  2025. jmp @@e_signature
  2026. DB '#$signature$#', 0
  2027. DB 'TKOLTrayIcon.Destroy', 0
  2028. @@e_signature:
  2029. end;
  2030. FIcon.Free;
  2031. inherited;
  2032. end;
  2033. procedure TKOLTrayIcon.SetActive(const Value: Boolean);
  2034. begin
  2035. asm
  2036. jmp @@e_signature
  2037. DB '#$signature$#', 0
  2038. DB 'TKOLTrayIcon.SetActive', 0
  2039. @@e_signature:
  2040. end;
  2041. FActive := Value;
  2042. Change;
  2043. end;
  2044. procedure TKOLTrayIcon.SetAutoRecreate(const Value: Boolean);
  2045. begin
  2046. asm
  2047. jmp @@e_signature
  2048. DB '#$signature$#', 0
  2049. DB 'TKOLTrayIcon.SetAutoRecreate', 0
  2050. @@e_signature:
  2051. end;
  2052. FAutoRecreate := Value;
  2053. Change;
  2054. end;
  2055. procedure TKOLTrayIcon.SetIcon(const Value: TIcon);
  2056. begin
  2057. asm
  2058. jmp @@e_signature
  2059. DB '#$signature$#', 0
  2060. DB 'TKOLTrayIcon.SetIcon', 0
  2061. @@e_signature:
  2062. end;
  2063. if Value <> nil then
  2064. FIcon.Assign( Value )
  2065. else
  2066. begin
  2067. FIcon.Free;
  2068. FIcon := TIcon.Create;
  2069. end;
  2070. Change;
  2071. end;
  2072. procedure TKOLTrayIcon.SetNoAutoDeactivate(const Value: Boolean);
  2073. begin
  2074. FNoAutoDeactivate := Value;
  2075. Change;
  2076. end;
  2077. procedure TKOLTrayIcon.SetOnMouse(const Value: TOnTrayIconMouse);
  2078. begin
  2079. asm
  2080. jmp @@e_signature
  2081. DB '#$signature$#', 0
  2082. DB 'TKOLTrayIcon.SetOnMouse', 0
  2083. @@e_signature:
  2084. end;
  2085. FOnMouse := Value;
  2086. Change;
  2087. end;
  2088. procedure TKOLTrayIcon.SetTooltip(const Value: String);
  2089. begin
  2090. asm
  2091. jmp @@e_signature
  2092. DB '#$signature$#', 0
  2093. DB 'TKOLTrayIcon.SetTooltip', 0
  2094. @@e_signature:
  2095. end;
  2096. FTooltip := Value;
  2097. if Length( FTooltip ) > 64 then
  2098. FTooltip := Copy( FTooltip, 1, 64 ); // 64 characters maximum allowed
  2099. Change;
  2100. end;
  2101. procedure TKOLTrayIcon.SetupFirst(SL: TStringList; const AName, AParent,
  2102. Prefix: String);
  2103. var RsrcName, RsrcFile: String;
  2104. begin
  2105. asm
  2106. jmp @@e_signature
  2107. DB '#$signature$#', 0
  2108. DB 'TKOLTrayIcon.SetupFirst', 0
  2109. @@e_signature:
  2110. end;
  2111. if not Icon.Empty then
  2112. begin
  2113. RsrcName := UpperCase( 'z' + ParentKOLForm.FormName + '_' + Name );
  2114. RsrcFile := ParentKOLForm.FormName + '_' + Name;
  2115. GenerateIconResource( Icon, RsrcName, RsrcFile, fUpdated );
  2116. SL.Add( Prefix + ' {$R ' + RsrcFile + '.RES}' );
  2117. end;
  2118. if Icon.Empty or not Active then
  2119. SL.Add( Prefix + AName + ' := NewTrayIcon( Applet, 0 );' )
  2120. else
  2121. SL.Add( Prefix + AName + ' := NewTrayIcon( Applet, LoadIcon( hInstance, ' +
  2122. String2Pascal( RsrcName ) + ' ) );' );
  2123. if not Active then
  2124. begin
  2125. SL.Add( Prefix + AName + '.Active := FALSE;' );
  2126. if not Icon.Empty then
  2127. SL.Add( Prefix + AName + '.Icon := LoadIcon( hInstance, ' +
  2128. String2Pascal( RsrcName ) + ' );' )
  2129. end;
  2130. if NoAutoDeactivate then
  2131. SL.Add( Prefix + AName + '.NoAutoDeactivate := TRUE;' );
  2132. if Tooltip <> '' then
  2133. SL.Add( Prefix + AName + '.Tooltip := ' + StringConstant( 'Tooltip', Tooltip ) + ';' );
  2134. if AutoRecreate then
  2135. SL.Add( Prefix + AName + '.AutoRecreate := TRUE;' );
  2136. GenerateTag( SL, AName, Prefix );
  2137. end;
  2138. procedure TKOLTrayIcon.SetupLast(SL: TStringList; const AName, AParent,
  2139. Prefix: String);
  2140. begin
  2141. asm
  2142. jmp @@e_signature
  2143. DB '#$signature$#', 0
  2144. DB 'TKOLTrayIcon.SetupLast', 0
  2145. @@e_signature:
  2146. end;
  2147. if Active then
  2148. SL.Add( Prefix + AName + '.Active := TRUE;' );
  2149. end;
  2150. { TKOLThread }
  2151. procedure TKOLThread.AssignEvents(SL: TStringList; const AName: String);
  2152. begin
  2153. asm
  2154. jmp @@e_signature
  2155. DB '#$signature$#', 0
  2156. DB 'TKOLThread.AssignEvents', 0
  2157. @@e_signature:
  2158. end;
  2159. //
  2160. end;
  2161. function TKOLThread.BestEventName: String;
  2162. begin
  2163. Result := 'OnExecute';
  2164. end;
  2165. function TKOLThread.NotAutoFree: Boolean;
  2166. begin
  2167. asm
  2168. jmp @@e_signature
  2169. DB '#$signature$#', 0
  2170. DB 'TKOLThread.NotAutoFree', 0
  2171. @@e_signature:
  2172. end;
  2173. Result := F_AutoFree;
  2174. end;
  2175. procedure TKOLThread.SetAutoFree(const Value: Boolean);
  2176. begin
  2177. asm
  2178. jmp @@e_signature
  2179. DB '#$signature$#', 0
  2180. DB 'TKOLThread.SetAutoFree', 0
  2181. @@e_signature:
  2182. end;
  2183. F_AutoFree := Value;
  2184. Change;
  2185. end;
  2186. procedure TKOLThread.SetOnExecute(const Value: TOnThreadExecute);
  2187. begin
  2188. asm
  2189. jmp @@e_signature
  2190. DB '#$signature$#', 0
  2191. DB 'TKOLThread.SetOnExecute', 0
  2192. @@e_signature:
  2193. end;
  2194. FOnExecute := Value;
  2195. Change;
  2196. end;
  2197. procedure TKOLThread.SetOnResume(const Value: TOnEvent);
  2198. begin
  2199. asm
  2200. jmp @@e_signature
  2201. DB '#$signature$#', 0
  2202. DB 'TKOLThread.SetOnResume', 0
  2203. @@e_signature:
  2204. end;
  2205. FOnResume := Value;
  2206. Change;
  2207. end;
  2208. procedure TKOLThread.SetOnSuspend(const Value: TObjectMethod);
  2209. begin
  2210. asm
  2211. jmp @@e_signature
  2212. DB '#$signature$#', 0
  2213. DB 'TKOLThread.SetOnSuspend', 0
  2214. @@e_signature:
  2215. end;
  2216. FOnSuspend := Value;
  2217. Change;
  2218. end;
  2219. procedure TKOLThread.SetPriorityClass(const Value: TPriorityClass);
  2220. begin
  2221. asm
  2222. jmp @@e_signature
  2223. DB '#$signature$#', 0
  2224. DB 'TKOLThread.SetPriorityClass', 0
  2225. @@e_signature:
  2226. end;
  2227. FPriorityClass := Value;
  2228. Change;
  2229. end;
  2230. procedure TKOLThread.SetstartSuspended(const Value: Boolean);
  2231. begin
  2232. asm
  2233. jmp @@e_signature
  2234. DB '#$signature$#', 0
  2235. DB 'TKOLThread.SetstartSuspended', 0
  2236. @@e_signature:
  2237. end;
  2238. FstartSuspended := Value;
  2239. Change;
  2240. end;
  2241. procedure TKOLThread.SetThreadPriority(const Value: TThreadPriority);
  2242. begin
  2243. asm
  2244. jmp @@e_signature
  2245. DB '#$signature$#', 0
  2246. DB 'TKOLThread.SetThreadPriority', 0
  2247. @@e_signature:
  2248. end;
  2249. FThreadPriority := Value;
  2250. Change;
  2251. end;
  2252. procedure TKOLThread.SetupFirst(SL: TStringList; const AName, AParent,
  2253. Prefix: String);
  2254. const PriorityClasses: array[ TPriorityClass ] of String =
  2255. ( 'NORMAL_PRIORITY_CLASS', 'IDLE_PRIORITY_CLASS', 'HIGH_PRIORITY_CLASS',
  2256. 'REALTIME_PRIORITY_CLASS' );
  2257. ThreadPriorities: array[ TThreadPriority ] of String =
  2258. ( 'THREAD_PRIORITY_NORMAL', 'THREAD_PRIORITY_BELOW_NORMAL',
  2259. 'THREAD_PRIORITY_LOWEST', 'THREAD_PRIORITY_IDLE',
  2260. 'THREAD_PRIORITY_ABOVE_NORMAL', 'THREAD_PRIORITY_HIGHEST',
  2261. 'THREAD_PRIORITY_CRITICAL' );
  2262. var S: String;
  2263. begin
  2264. asm
  2265. jmp @@e_signature
  2266. DB '#$signature$#', 0
  2267. DB 'TKOLThread.SetupFirst', 0
  2268. @@e_signature:
  2269. end;
  2270. if startSuspended or (@OnSuspend <> nil) or
  2271. (@OnResume <> nil) or (@OnDestroy <> nil) or
  2272. AutoFree or (PriorityClass <> pcNormal) or (ThreadPriority <> tpNormal)
  2273. or (Tag <> 0) then
  2274. begin
  2275. if AutoFree then
  2276. SL.Add( Prefix + AName + ' := NewThreadAutoFree( nil );' )
  2277. else
  2278. SL.Add( Prefix + AName + ' := NewThread;' );
  2279. if @OnExecute <> nil then
  2280. SL.Add( Prefix + AName + '.OnExecute := Result.' +
  2281. ParentForm.MethodName( @OnExecute ) + ';' );
  2282. if @OnSuspend <> nil then
  2283. SL.Add( Prefix + AName + '.OnSuspend := Result.' +
  2284. ParentForm.MethodName( @OnSuspend ) + ';' );
  2285. if @OnResume <> nil then
  2286. SL.Add( Prefix + AName + '.OnResume := Result.' +
  2287. ParentForm.MethodName( @OnResume ) + ';' );
  2288. if @OnDestroy <> nil then
  2289. SL.Add( Prefix + AName + '.OnDestroy := Result.' +
  2290. ParentForm.MethodName( @OnDestroy ) + ';' );
  2291. if PriorityClass <> pcNormal then
  2292. SL.Add( Prefix + AName + '.PriorityClass := ' +
  2293. PriorityClasses[ PriorityClass ] + ';' );
  2294. if ThreadPriority <> tpNormal then
  2295. SL.Add( Prefix + AName + '.ThreadPriority := ' +
  2296. ThreadPriorities[ ThreadPriority ] + ';' );
  2297. GenerateTag( SL, AName, Prefix );
  2298. if not startSuspended then
  2299. SL.Add( Prefix + AName + '.Resume;' );
  2300. end
  2301. else
  2302. begin
  2303. S := 'nil';
  2304. if @OnExecute <> nil then
  2305. S := 'Result.' + ParentForm.MethodName( @OnExecute );
  2306. SL.Add( Prefix + AName + ' := NewThreadEx( ' + S + ' );' );
  2307. end;
  2308. end;
  2309. end.