PageRenderTime 68ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 2ms

/KO208L.pas

http://github.com/rofl0r/KOL
Pascal | 10844 lines | 3819 code | 1050 blank | 5975 comment | 0 complexity | a81b16c76440c8b48a9fd8dcd1486d3f MD5 | raw file
  1. //[START OF KOL.pas]
  2. {****************************************************************
  3. KKKKK KKKKK OOOOOOOOO LLLLL
  4. KKKKK KKKKK OOOOOOOOOOOOO LLLLL
  5. KKKKK KKKKK OOOOO OOOOO LLLLL
  6. KKKKK KKKKK OOOOO OOOOO LLLLL
  7. KKKKKKKKKK OOOOO OOOOO LLLLL
  8. KKKKK KKKKK OOOOO OOOOO LLLLL
  9. KKKKK KKKKK OOOOO OOOOO LLLLL
  10. KKKKK KKKKK OOOOOOOOOOOOO LLLLLLLLLLLLL
  11. KKKKK KKKKK OOOOOOOOO LLLLLLLLLLLLL
  12. Key Objects Library (C) 2000 by Kladov Vladimir.
  13. //[VERSION]
  14. ****************************************************************
  15. * VERSION 2.08
  16. ****************************************************************
  17. //[END OF VERSION]
  18. K.O.L. - is a set of objects to create small programs
  19. with the Delphi, but without the VCL. KOL allows to
  20. create executables of size about 10 times smaller then
  21. those created with the VCL. But this does not mean that
  22. KOL is less power then the VCL - perhaps just the opposite...
  23. KOL is provided free with the source code.
  24. Copyright (C) Vladimir Kladov, 2000-2003.
  25. For code provided by other developers (even if later
  26. changed by me) authors are noted in the source.
  27. mailto: bonanzas@online.sinor.ru
  28. Web-Page: http://bonanzas.rinet.ru
  29. See also Mirror Classes Kit (M.C.K.) which allows
  30. to create KOL programs visually.
  31. ****************************************************************}
  32. //[UNIT DEFINES]
  33. {$INCLUDE delphidef.inc}
  34. //[START OF UNIT]
  35. unit KOL;
  36. {-}
  37. {*
  38. Please note, that KOL does not use keyword 'class'. Instead,
  39. poor Pascal 'object' is the base of our objects. So, remember,
  40. how we worked earlier with such Object Pascal's objects:
  41. |<br>
  42. - to create objects dynamically, use P<objname> instead of
  43. T<objname> to allocate a pointer for dynamically created
  44. object instance;
  45. |<br>
  46. - remember, that constructors of objects can not be virtual.
  47. Override procedure Init instead in your own derived objects;
  48. |<br>
  49. - rather then call constructors of objects, call global procedures
  50. New<objname> (e.g. NewLabel). If not, first (for virtualally
  51. created objects) call New( ); then call constructor Create
  52. (which calls Init) - but this is possible only if the constructor
  53. is overriden by a new one.
  54. |<br>
  55. - the operator 'is' is not applicable to objects. And operator 'as'
  56. is not necessary (and is not applicable too), use typecast to desired
  57. object type, e.g.: "PSomeObjectType( C )" inplace of "C as TSomeClassType".
  58. |<br>
  59. |<hr>
  60. Also remember, that IF [ MyObj: PMyObj ] THEN
  61. NOT[ with MyObj do ] BUT[ with MyObj^ do ]
  62. Though it is possible to skip '^' symbol when accessing member
  63. fields, methods, properties, e.g. [ MyObj.Execute; ]
  64. |<hr>
  65. |&U=&nbsp;&nbsp;&nbsp;<a href="#%0">%0</a><br>
  66. |&B=<a href="%1.htm">%0</a><br>
  67. |&C=<a href="%1.htm">%0</a>
  68. | <table border=1 cellpadding=6 width=100%>
  69. | <colgroup valign=top span=2>
  70. | <tr>
  71. | <td> objects </td> <td> functions by category </td>
  72. | </tr>
  73. | <td>
  74. <C _TObj> <B TObj>
  75. <C TList> <C TListEx> <C TStrList> <B TStrListEx>
  76. <C TTree> <C TDirList> <C TIniFile> <C TCabFile>
  77. <B TStream>
  78. <B TControl>
  79. <C TGraphicTool> <C TCanvas> <C TImageList> <C TIcon> <C TBitmap>
  80. <C TGif> <C TGifDecoder> <B TJpeg>
  81. <C TTimer> <C TThread> <C TTrayIcon> <C TDirChange> <B TMediaPlayer>
  82. <C TMenu> <C TOpenSaveDialog> <C TOpenDirDialog> <B TColorDialog>
  83. <C TAction> <B TActionList>
  84. <B Exception>
  85. | </td>
  86. | <td>
  87. |<a href="kol_pas.htm#visual_objects_constructors">
  88. Visual objects constructing functions
  89. |</a><br><br>
  90. <U Working with null-terminated and ansi strings>
  91. <U Small bit arrays (max 32 bits in array)>
  92. <U Arithmetics, geometry and other utility functions>
  93. <U Data sorting (quicksort implementation)>
  94. <U String to number and number to string conversions>
  95. <U 64-bit integer numbers>
  96. <U Floating point numbers>
  97. <U Date and time handling>
  98. <U File and directory routines>
  99. <U System functions and working with windows>
  100. <U Text in clipboard operations>
  101. <U Wrappers to registry API functions>
  102. | </td>
  103. | </table>
  104. Several conditional symbols can be used in a project
  105. (Project | Options | Directories/Conditional Defines)
  106. to change code generated a bit. There are following:
  107. |<pre>
  108. PAS_VERSION - to use Pascal version of the code.
  109. PARANOIA - to force short versions of asm instructions (for D5
  110. and below, D6 and higher use those instructions always).
  111. USE_NAMES - to use property Name with any TObj. This makes also
  112. available global function FindObj( name ): PObj.
  113. (USE_CONSTRUCTORS - to use constructors like in VCL. Note: this option is
  114. not carefully tested!)
  115. USE_CUSTOMEXTENSIONS - to extend TControl with custom additions.
  116. UNICODE_CTRLS - to use Unicode versions of controls (WM_XXXXW messages,
  117. etc.)
  118. USE_MHTOOLTIP - to use MHTOOLTIP.
  119. NOT_USE_OnIdle - to stop using OnIdle event (to make code smaller
  120. if it is not used actually).
  121. USE_ASM_DODRAG - to use assembler version of code for DoDrag.
  122. ENUM_DYN_HANDLERS_AFTER_RUN - to allow all the events handling even when
  123. AppletTerminated become TRUE.
  124. ALL_BUTTONS_RESPOND_TO_ENTER - obvious (by default, buttons respond to key
  125. SPACE, since those are working this way in Windows).
  126. ESC_CLOSE_DIALOGS - to allow closing all dialogs with ESCAPE.
  127. KEY_PREVIEW - form also receive WM_KEYDOWN (OnKeyDown event fired)
  128. OpenSaveDialog_Extended - to allow using custom extensions for OpenSaveDialog.
  129. AUTO_CONTEXT_HELP - to use automatic respond to WM_CONTEXTMENU to call
  130. context help.
  131. NOT_FIX_CURINDEX - to use old version of TControl.SetItems, which could
  132. lead to loose CurIndex value (e.g. for Combobox)
  133. NOT_FIX_MODAL - not to fix modal (if fixed, click on any window
  134. activates the application. If not fixed, code is
  135. smaller very a little, but only click on modal form
  136. activates the application).
  137. NEW_MODAL - to use extended modalness.
  138. USE_SETMODALRESULT - to guarantee ModalResult property assigninig handling.
  139. USE_MENU_CURCTL - to use CurCtl property in popup menu to detect which
  140. control initiated a pop-up.
  141. NEW_MENU_ACCELL - to use another menu accelerators handling, without
  142. AcceleratorTable
  143. USE_DROPDOWNCOUNT - to force setting combobox dropdown count.
  144. NOT_UNLOAD_RICHEDITLIB - to stop unload Rich Edit library in finalization
  145. section (to economy several byte of code).
  146. DEBUG_GDIOBJECTS - to allow counting all the GDI objects used.
  147. CHK_BITBLT - to check BitBlt operations.
  148. DEBUG_ENDSESSION - to allow debugging WM_ENDSESSION handling.
  149. DEBUG_CREATEWINDOW - to debug CreateWindow.
  150. TEST_CLOSE - to debug Close.
  151. DEBUG_MENU - to debug menu.
  152. DEBUG_DBLBUFF - to debug DoubleBuffered.
  153. DEBUG - other debugging.
  154. PROVIDE_EXITCODE - PostQuitMessage( value ) assigns value to ExitCode
  155. INITIALFORMSIZE_FIXMENU - form size initially is really the same as defined at
  156. design time even for forms having main menu bar
  157. GRAPHCTL_XPSTYLES - to use XP themed Visual styles for drawing graphic
  158. controls. This does not affect windowed controls
  159. which visual style is controlled by the manifest.
  160. GRAPHCTL_HOTTRACK - to use hot-tracking also together with XP themed
  161. graphic controls (otherwise only static XP themed
  162. view is provided). Also, turn this option on if you
  163. want to handle OnMouseEnter and OnMouseLeabe events
  164. for graphic controls.
  165. |</pre>
  166. }
  167. {= K.O.L - . (C) , 2000-2003.
  168. }
  169. //[OPTIONS]
  170. {$A-} // align off, otherwise code is not good
  171. {+}
  172. {$Q-} // no overflow check: this option makes code wrong
  173. {$R-} // no range checking: this option makes code wrong
  174. {$T-} // not typed @-operator
  175. //{$D+}
  176. {$IFDEF INPACKAGE} // use this symbol in packages requiring kol.pas
  177. {$WARNINGS OFF}
  178. {$ENDIF}
  179. {$IFDEF _D7orHigher}
  180. {$WARN UNSAFE_TYPE OFF} // Too many such warnings in Delphi7
  181. {$WARN UNSAFE_CODE OFF}
  182. {$WARN UNSAFE_CAST OFF}
  183. {$ENDIF}
  184. //[START OF INTERFACE]
  185. interface
  186. //{$DEFINE DEBUG_GDIOBJECTS}
  187. //{$DEFINE CHK_GDI}
  188. //[USES]
  189. uses
  190. messages, windows, RichEdit {$IFDEF CHK_GDI}, ChkGdi {$ENDIF};
  191. //[END OF USES]
  192. {$IFDEF DEBUG_GDIOBJECTS}
  193. var
  194. BrushCount: Integer;
  195. FontCount: Integer;
  196. PenCount: Integer;
  197. {$ENDIF}
  198. //{_#IF [DELPHI]}
  199. {$INCLUDE delphicommctrl.inc}
  200. //{_#ENDIF}
  201. type
  202. //[_TObj DEFINITION]
  203. {-}
  204. _TObj = object
  205. {* auxiliary object type. See TObj. }
  206. protected
  207. procedure Init; virtual;
  208. {* Is called from a constructor to initialize created object instance
  209. filling its fields with 0. Can be overriden in descendant objects
  210. to add another initialization code there. (Main reason of intending
  211. is what constructors can not be virtual in poor objects). }
  212. {= . }
  213. public
  214. function VmtAddr: Pointer;
  215. {* Returns addres of virtual methods table of object. ? }
  216. {= (VMT). ? }
  217. end;
  218. {+}
  219. {++}(* TObj = class;*){--}
  220. PObj = {-}^{+}TObj;
  221. {* }
  222. {++}(* TList = class;*){--}
  223. PList = {-}^{+}TList;
  224. {* }
  225. //[TObjectMethod DECLARATION]
  226. TObjectMethod = procedure of object;
  227. {* }
  228. TOnEvent = procedure( Sender: PObj ) of object;
  229. {* This type of event is the most common - event handler when called can
  230. know only what object was a sender of this call. Replaces good known
  231. VCL TNotifyEvent event type. }
  232. //[TPointerList DECLARATION]
  233. PPointerList = ^TPointerList;
  234. TPointerList = array[0..MaxInt div 4 - 1] of Pointer;
  235. { ---------------------------------------------------------------------
  236. TObj - base object to derive all others
  237. ---------------------------------------------------------------------- }
  238. //[TObj DEFINITION]
  239. TObj = {-} object( _TObj ) {+}{++}(*class*){--}
  240. {* Prototype for all objects of KOL. All its methods are important to
  241. implement objects in a manner similar to Delphi TObject class. }
  242. {= KOL. }
  243. protected
  244. fRefCount: Integer;
  245. fOnDestroy: TOnEvent;
  246. procedure DoDestroy;
  247. protected
  248. fAutoFree: PList;
  249. {* Is called from a constructor to initialize created object instance
  250. filling its fields with 0. Can be overriden in descendant objects
  251. to add another initialization code there. (Main reason of intending
  252. is what constructors can not be virtual in poor objects). }
  253. {= . }
  254. fTag: DWORD;
  255. {* Custom data. }
  256. {++}(*public*){--}
  257. destructor Destroy; {-} virtual; {+}{++}(* override; *){--}
  258. {* Disposes memory, allocated to an object. Does not release huge strings,
  259. dynamic arrays and so on. Such memory should be freeing in overriden
  260. destructor. }
  261. {= , . ,
  262. , ..
  263. . }
  264. {++}(*protected*){--}
  265. {++}(*
  266. procedure Init; virtual;
  267. {* Can be overriden in descendant objects
  268. to add initialization code there. (Main reason of intending
  269. is what constructors can not be virtual in poor objects). }
  270. *){--}
  271. procedure Final;
  272. {* It is called in destructor to perform OnDestroy event call and to
  273. released objects, added to fAutoFree list. }
  274. public
  275. procedure Free;
  276. {* Before calling destructor of object, checks if passed pointer is not
  277. nil - similar what is done in VCL for TObject. It is ALWAYS recommended
  278. to use Free instead of Destroy - see also comments to RefInc, RefDec. }
  279. {= , , nil .
  280. Free Destroy - . RefInc,
  281. RefDec. }
  282. {-}
  283. // By Vyacheslav Gavrik:
  284. function InstanceSize: Integer;
  285. {* Returns a size of object instance. }
  286. {+}
  287. constructor Create;
  288. {* Constructor. Do not call it. Instead, use New<objectname> function
  289. call for certain object, e.g., NewLabel( AParent, 'caption' ); }
  290. {= . . ,
  291. New<->. ,
  292. NewLabel( MyForm, '������1' ); }
  293. {-}
  294. class function AncestorOfObject( Obj: Pointer ): Boolean;
  295. {* Is intended to replace 'is' operator, which is not applicable to objects. }
  296. {= }
  297. function VmtAddr: Pointer;
  298. {* Returns addres of virtual methods table of object. }
  299. {= (VMT). }
  300. {+}
  301. procedure RefInc;
  302. {* See comments below. }
  303. {= . RefDec . }
  304. procedure RefDec;
  305. {* Decrements reference count. If it is becoming <0, and Free
  306. method was already called, object is (self-) destroyed. Otherwise,
  307. Free method does not destroy object, but only sets flag
  308. "Free was called".
  309. |<br>
  310. Use RefInc..RefDec to provide a block of code, where
  311. object can not be destroyed by call of Free method.
  312. This makes code more safe from intersecting flows of processing,
  313. where some code want to destroy object, but others suppose that it
  314. is yet existing.
  315. |<br>
  316. If You want to release object at the end of block RefInc..RefDec,
  317. do it immediately BEFORE call of last RefDec (to avoid situation,
  318. when object is released in result of RefDec, and attempt to
  319. destroy it follow leads to AV exception).
  320. }
  321. {= .
  322. < 0, Free , (-) . ,
  323. Free , "Free ���
  324. ".
  325. |<br>
  326. RefInc..RefDec
  327. ( ).
  328. |<br>
  329. () RefDec,
  330. Free RefDec. }
  331. property RefCount: Integer read fRefCount;
  332. {* }
  333. property OnDestroy: TOnEvent read fOnDestroy write fOnDestroy;
  334. {* This event is provided for any KOL object, so You can provide your own
  335. OnDestroy event for it. }
  336. {= KOL.
  337. - . }
  338. procedure Add2AutoFree( Obj: PObj );
  339. {* Adds an object to the list of objects, destroyed automatically
  340. when the object is destroyed. Do not add here child controls of
  341. the TControl (these are destroyed by another way). Only non-control
  342. objects, which are not destroyed automatically, should be added here. }
  343. procedure Add2AutoFreeEx( Proc: TObjectMethod );
  344. {* Adds an event handler to the list of events, called in destructor.
  345. This method is mainly for internal use, and allows to auto-destroy
  346. VCL components, located on KOL form at design time (in MCK project). }
  347. property Tag: DWORD read fTag write fTag;
  348. {* Custom data field. }
  349. protected
  350. {$IFDEF USE_NAMES}
  351. FName: String;
  352. procedure SetName( const NewName: String );
  353. {$ENDIF}
  354. public
  355. {$IFDEF USE_NAMES}
  356. property Name: String read FName write SetName;
  357. {$ENDIF}
  358. end;
  359. //[END OF TObj DEFINITION]
  360. { ---------------------------------------------------------------------
  361. TList - object to implement list of pointers (or dwords)
  362. ---------------------------------------------------------------------- }
  363. //[TList DEFINITION]
  364. TList = object( TObj )
  365. {* Simple list of pointers. It is used in KOL instead of standard VCL
  366. TList to store any kind data (or pointers to these ones). Can be created
  367. calling function NewList. }
  368. {= . }
  369. protected
  370. fItems: PPointerList;
  371. fCount: Integer;
  372. fCapacity: Integer;
  373. fAddBy: Integer;
  374. procedure SetCount(const Value: Integer);
  375. procedure SetAddBy(Value: Integer);
  376. {++}(*public*){--}
  377. destructor Destroy; {-}virtual;{+}{++}(*override;*){--}
  378. {* Destroys list, freeing memory, allocated for pointers. Programmer
  379. is resposible for destroying of data, referenced by the pointers. }
  380. {= }
  381. {++}(*protected*){--}
  382. procedure SetCapacity( Value: Integer );
  383. function Get( Idx: Integer ): Pointer;
  384. procedure Put( Idx: Integer; Value: Pointer );
  385. {$IFDEF USE_CONSTRUCTORS}
  386. procedure Init; virtual;
  387. {$ENDIF USE_CONSTRUCTORS}
  388. public
  389. procedure Clear;
  390. {* Makes Count equal to 0. Not responsible for freeing (or destroying)
  391. data, referenced by released pointers. }
  392. procedure Add( Value: Pointer );
  393. {* Adds pointer to the end of list, increasing Count by one. }
  394. procedure Insert( Idx: Integer; Value: Pointer );
  395. {* Inserts pointer before given item. Returns Idx, i.e. index of
  396. inserted item in the list. Indeces of items, located after insertion
  397. point, are increasing. To add item to the end of list, pass Count
  398. as index parameter. To insert item before first item, pass 0 there. }
  399. function IndexOf( Value: Pointer ): Integer;
  400. {* Searches first (from start) item pointer with given value and returns
  401. its index (zero-based) if found. If not found, returns -1. }
  402. procedure Delete( Idx: Integer );
  403. {* Deletes given (by index) pointer item from the list, shifting all
  404. follow item indeces up by one. }
  405. procedure DeleteRange( Idx, Len: Integer );
  406. {* Deletes Len items starting from Idx. }
  407. procedure Remove( Value: Pointer );
  408. {* Removes first entry of a Value in the list. }
  409. property Count: Integer read fCount write SetCount;
  410. {* Returns count of items in the list. It is possible to delete a number
  411. of items at the end of the list, keeping only first Count items alive,
  412. assigning new value to Count property (less then Count it is). }
  413. property Capacity: Integer read fCapacity write SetCapacity;
  414. {* Returns number of pointers which could be stored in the list
  415. without reallocating of memory. It is possible change this value
  416. for optimize usage of the list (for minimize number of reallocating
  417. memory operations). }
  418. property Items[ Idx: Integer ]: Pointer read Get write Put; default;
  419. {* Provides access (read and write) to items of the list. Please note,
  420. that TList is not responsible for freeing memory, referenced by stored
  421. pointers. }
  422. function Last: Pointer;
  423. {* Returns the last item (or nil, if the list is empty). }
  424. procedure Swap( Idx1, Idx2: Integer );
  425. {* Swaps two items in list directly (fast, but without testing of
  426. index bounds). }
  427. procedure MoveItem( OldIdx, NewIdx: Integer );
  428. {* Moves item to new position. Pass NewIdx >= Count to move item
  429. after the last one. }
  430. procedure Release;
  431. {* Especially for lists of pointers to dynamically allocated memory.
  432. Releases all pointed memory blocks and destroys object itself. }
  433. procedure ReleaseObjects;
  434. {* Especially for a list of objects derived from TObj.
  435. Calls Free for every of the object in the list, and then calls
  436. Free for the object itself. }
  437. property AddBy: Integer read fAddBy write SetAddBy;
  438. {* Value to increment capacity when new items are added or inserted
  439. and capacity need to be increased. }
  440. property DataMemory: PPointerList read fItems;
  441. {* Raw data memory. Can be used for direct access to items of a list. }
  442. procedure Assign( SrcList: PList );
  443. {* Copies all source list items. }
  444. {$IFDEF _D4orHigher}
  445. procedure AddItems( const AItems: array of Pointer );
  446. {* Adds a list of items given by a dynamic array. }
  447. {$ENDIF}
  448. end;
  449. //[END OF TList DEFINITION]
  450. //[NewList DECLARATION]
  451. function NewList: PList;
  452. {* Returns pointer to newly created TList object. Use it instead usual
  453. TList.Create as it is done in VCL or XCL. }
  454. {$IFDEF _D4orHigher}
  455. function NewListInit( const AItems: array of Pointer ): PList;
  456. {* Creates a list filling it initially with certain Items. }
  457. {$ENDIF}
  458. procedure FastIncNum2Elements( List: TList; FromIdx, Count, Value: Integer );
  459. {* Very fast adds Value to List elements from List[FromIdx] to List[FromIdx+Count-1].
  460. Given elements must exist. Count must be > 0. }
  461. procedure Free_And_Nil( var Obj );
  462. {* Obj.Free and Obj := nil, where Obj *MUST* be TObj or its descendant
  463. (TControl, TMenu, etc.) This procedure is not compatible with VCL's
  464. FreeAndNil, which works with TObject, since this it has another name. }
  465. {$IFDEF USE_NAMES}
  466. var
  467. NamedObjectsList: PList;
  468. function FindObj( const Name: String ): PObj;
  469. {$ENDIF}
  470. { -- tree (non-visual) -- }
  471. type
  472. //[TTree DEFINITION]
  473. {++}(*TTree = class;*){--}
  474. PTree = {-}^{+}TTree;
  475. TTree = object( TObj )
  476. {* Object to store tree-like data in memory (non-visual). }
  477. protected
  478. fParent: PTree;
  479. fChildren: PList;
  480. fPrev: PTree;
  481. fNext: PTree;
  482. fNodeName: String;
  483. fData: Pointer;
  484. function GetCount: Integer;
  485. function GetItems(Idx: Integer): PTree;
  486. procedure Unlink;
  487. function GetRoot: PTree;
  488. function GetLevel: Integer;
  489. function GetTotal: Integer;
  490. function GetIndexAmongSiblings: Integer;
  491. protected
  492. {$IFDEF USE_CONSTRUCTORS}
  493. constructor CreateTree( AParent: PTree; const AName: String );
  494. {* }
  495. {$ENDIF}
  496. {++}(*public*){--}
  497. destructor Destroy; {-}virtual;{+}{++}(*override;*){--}
  498. {* }
  499. {++}(*protected*){--}
  500. procedure Init; {-}virtual;{+}{++}(*override;*){--}
  501. public
  502. procedure Clear;
  503. {* Destoyes all child nodes. }
  504. property Name: String read fNodeName write fNodeName;
  505. {* Optional node name. }
  506. property Data: Pointer read fData write fData;
  507. {* Optional user-defined pointer. }
  508. property Count: Integer read GetCount;
  509. {* Number of child nodes of given node. }
  510. property Items[ Idx: Integer ]: PTree read GetItems;
  511. {* Child nodes list items. }
  512. procedure Add( Node: PTree );
  513. {* Adds another node as a child of given tree node. This operation
  514. as well as Insert can be used to move node together with its children
  515. to another location of the same tree or even from another tree.
  516. Anyway, added Node first correctly removed from old place (if it is
  517. defined for it). But for simplest task, such as filling of tree with
  518. nodes, code should looking as follows:
  519. ! Node := NewTree( nil, 'test of creating node without parent' );
  520. ! RootOfMyTree.Add( Node );
  521. Though, this code gives the same result as:
  522. ! Node := NewTree( RootOfMyTree, 'test of creatign node as a child' ); }
  523. procedure Insert( Before, Node: PTree );
  524. {* Inserts earlier created 'Node' just before given child node 'Before'
  525. as a child of given tree node. See also Add method. }
  526. property Parent: PTree read fParent;
  527. {* Returns parent node (or nil, if there is no parent). }
  528. property Index: Integer read GetIndexAmongSiblings;
  529. {* Returns an index of the node in a list of nodes of the same parent
  530. (or -1, if Parent is not defined). }
  531. property PrevSibling: PTree read fPrev;
  532. {* Returns previous node in a list of children of the Parent. Nil is
  533. returned, if given node is the first child of the Parent or has
  534. no Parent. }
  535. property NextSibling: PTree read fNext;
  536. {* Returns next node in a list of children of the Parent. Nil is returned,
  537. if given node is the last child of the Parent or has no Parent at all. }
  538. property Root: PTree read GetRoot;
  539. {* Returns root node (i.e. the last Parent, enumerating parents recursively). }
  540. property Level: Integer read GetLevel;
  541. {* Returns level of the node, i.e. integer value, equal to 0 for root
  542. of a tree, 1 for its children, etc. }
  543. property Total: Integer read GetTotal;
  544. {* Returns total number of children of the node and all its children
  545. counting its recursively (but node itself is not considered, i.e.
  546. Total for node without children is equal to 0). }
  547. procedure SortByName;
  548. {* Sorts children of the node in ascending order. Sorting is not
  549. recursive, i.e. only immediate children are sorted. }
  550. procedure SwapNodes( i1, i2: Integer );
  551. {* Swaps two child nodes. }
  552. function IsParentOfNode( Node: PTree ): Boolean;
  553. {* Returns true, if Node is the tree itself or is a parent of the given node
  554. on any level. }
  555. function IndexOf( Node: PTree ): Integer;
  556. {* Total index of the child node (on any level under this node). }
  557. end;
  558. //[END OF TTree DEFINITION]
  559. //[NewTree DECLARATION]
  560. function NewTree( AParent: PTree; const AName: String ): PTree;
  561. {* Constructs tree node, adding it to the end of children list of
  562. the AParent. If AParent is nil, new root tree node is created. }
  563. //[DummyObjProc, DummyObjProcParam DECLARATION]
  564. procedure DummyObjProc( Sender: PObj );
  565. procedure DummyObjProcParam( Sender: PObj; Param: Pointer );
  566. { --- threads --- }
  567. //[THREADS]
  568. const
  569. ABOVE_NORMAL_PRIORITY_CLASS = $8000; // only for Windows 2K
  570. BELOW_NORMAL_PRIORITY_CLASS = $4000; // and higher !
  571. type
  572. {++}(*TThread = class;*){--}
  573. PThread = {-}^{+}TThread;
  574. TThreadMethod = procedure of object;
  575. TThreadMethodEx = procedure( Sender: PThread; Param: Pointer ) of object;
  576. TOnThreadExecute = function(Sender:PThread): Integer of object;
  577. {* Event to be called when Execute method is called for TThread }
  578. { ---------------------------------------------------------------------
  579. TThread object
  580. ---------------------------------------------------------------------- }
  581. //[TThread DEFINITION]
  582. TThread = object(TObj)
  583. {* Thread object. It is possible not to derive Your own thread-based
  584. object, but instead create thread Suspended and assign event
  585. OnExecute. To create, use one of NewThread of NewThreadEx functions,
  586. or derive Your own descendant object and write creation function
  587. (or constructor) for it.
  588. |<br><br>
  589. Aknowledgements. Originally class ZThread was developed for XCL:
  590. |<br> * By: Tim Slusher : junior@nlcomm.com
  591. |<br> * Home: http://www.nlcomm.com/~junior
  592. }
  593. protected
  594. FSuspended,
  595. FTerminated: boolean;
  596. FHandle: THandle;
  597. FThreadId: DWORD;
  598. FOnSuspend: TObjectMethod;
  599. FOnResume: TOnEvent;
  600. FData : Pointer;
  601. FOnExecute : TOnThreadExecute;
  602. FMethod: TThreadMethod;
  603. FMethodEx: TThreadMethodEx;
  604. F_AutoFree: Boolean;
  605. function GetPriorityCls: Integer;
  606. function GetThrdPriority: Integer;
  607. procedure SetPriorityCls(Value: Integer);
  608. procedure SetThrdPriority(Value: Integer);
  609. {++}(*public*){--}
  610. destructor Destroy; {-}virtual;{+}{++}(*override;*){--}
  611. {* }
  612. public
  613. function Execute: integer; virtual;
  614. {* Executes thread. Do not call this method from another thread! (Even do
  615. not call this method at all!) Instead, use Resume.
  616. |<br>
  617. Note also that in contrast to VCL, it is not necessary to create your
  618. own descendant object from TThread and override Execute method. In KOL,
  619. it is sufficient to create an instance of TThread object (see NewThread,
  620. NewThreadEx, NewThreadAutoFree functions) and assign OnExecute event
  621. handler for it. }
  622. procedure Resume;
  623. {* Continues executing. It is necessary to make call for every
  624. nested Suspend. }
  625. procedure Suspend;
  626. {* Suspends thread until it will be resumed. Can be called from another
  627. thread or from the thread itself. }
  628. procedure Terminate;
  629. {* Terminates thread. }
  630. function WaitFor: Integer;
  631. {* Waits (infinitively) until thead will be finished. }
  632. property Handle: THandle read FHandle;
  633. {* Thread handle. It is created immediately when object is created
  634. (using NewThread). }
  635. property Suspended: boolean read FSuspended;
  636. {* True, if suspended. }
  637. property Terminated: boolean read FTerminated;
  638. {* True, if terminated. }
  639. property ThreadId: DWORD read FThreadId;
  640. {* Thread id. }
  641. property PriorityClass: Integer read GetPriorityCls write SetPriorityCls;
  642. {* Thread priority class. One of following values: HIGH_PRIORITY_CLASS,
  643. IDLE_PRIORITY_CLASS, NORMAL_PRIORITY_CLASS, REALTIME_PRIORITY_CLASS. }
  644. property ThreadPriority: Integer read GetThrdPriority write SetThrdPriority;
  645. {* Thread priority value. One of following values: THREAD_PRIORITY_ABOVE_NORMAL,
  646. THREAD_PRIORITY_BELOW_NORMAL, THREAD_PRIORITY_HIGHEST, THREAD_PRIORITY_IDLE,
  647. THREAD_PRIORITY_LOWEST, THREAD_PRIORITY_NORMAL, THREAD_PRIORITY_TIME_CRITICAL. }
  648. property Data : Pointer read FData write FData;
  649. {* Custom data pointer. Use it for Youe own purpose. }
  650. property OnExecute: TOnThreadExecute read FOnExecute write FOnExecute;
  651. {* Is called, when Execute is starting. }
  652. property OnSuspend: TObjectMethod read FOnSuspend write FOnSuspend;
  653. {* Is called, when Suspend is performed. }
  654. property OnResume: TOnEvent read FOnResume write FOnResume;
  655. {* Is called, when resumed. }
  656. procedure Synchronize( Method: TThreadMethod );
  657. {* Call it to execute given method in main thread context. Applet variable
  658. must exist for that time. }
  659. procedure SynchronizeEx( Method: TThreadMethodEx; Param: Pointer );
  660. {* Call it to execute given method in main thread context, with a given
  661. parameter. Applet variable must exist for that time. Param must not be nil. }
  662. {$IFDEF USE_CONSTRUCTORS}
  663. constructor ThreadCreate;
  664. constructor ThreadCreateEx( const Proc: TOnThreadExecute );
  665. {$ENDIF USE_CONSTRUCTORS}
  666. property AutoFree: Boolean read F_AutoFree write F_AutoFree;
  667. {* Set this property to true to provide automatic destroying of thread
  668. object when its executing is finished. }
  669. end;
  670. //[END OF TThread DEFINITION]
  671. //[NewThread, NewThreadEx, NewThreadAutoFree, Global_Synchronized DECLARATIONS]
  672. function NewThread: PThread;
  673. {* Creates thread object (always suspended). After creating, set event
  674. OnExecute and perform Resume operation. }
  675. function NewThreadEx( const Proc: TOnThreadExecute ): PThread;
  676. {* Creates thread object, assigns Proc to its OnExecute event and runs
  677. it. }
  678. function NewThreadAutoFree( const Proc: TOnThreadExecute ): PThread;
  679. {* Creates thread object similar to NewThreadEx, but freeing automatically
  680. when executing of such thread finished. Be sure that a thread is resumed
  681. at least to provide its object keeper freeing. }
  682. var Global_Synchronized: procedure( Sender: PObj; Param: Pointer ) = DummyObjProcParam;
  683. // It is not necessary to declare it as threadvar.
  684. { -- streams -- }
  685. //[STREAMS]
  686. type
  687. TMoveMethod = ( spBegin, spCurrent, spEnd );
  688. {++}(*TStream = class;*){--}
  689. PStream = {-}^{+}TStream;
  690. PStreamMethods = ^TStreamMethods;
  691. TStreamMethods = Packed Record
  692. fSeek: function( Strm: PStream; MoveTo: Integer; MoveMethod: TMoveMethod ): DWORD;
  693. fGetSiz: function( Strm: PStream ): DWORD;
  694. fSetSiz: procedure( Strm: PStream; Value: DWORD );
  695. fRead: function( Strm: PStream; var Buffer; Count: DWORD ): DWORD;
  696. fWrite: function( Strm: PStream; var Buffer; Count: DWORD ): DWORD;
  697. fClose: procedure( Strm: PStream );
  698. fCustom: Pointer;
  699. fWait: procedure( Strm: PStream );
  700. end;
  701. TStreamData = Packed Record
  702. fHandle: THandle;
  703. fCapacity, fSize, fPosition: DWORD;
  704. fThread: PThread;
  705. end;
  706. { ---------------------------------------------------------------------
  707. TStream - streaming objects incapsulation
  708. ---------------------------------------------------------------------- }
  709. //[TStream DEFINITION]
  710. TStream = object(TObj)
  711. {* Simple stream object. Can be opened for file, or as memory stream (see
  712. NewReadFileStream, NewWriteFileStream, NewMemoryStream, etc.). And, another
  713. type of streaming object can be derived (without inheriting new object
  714. type, just by writing another New...Stream method, which calls
  715. _NewStream and pass methods record to it). }
  716. protected
  717. fPMethods: PStreamMethods;
  718. fMethods: TStreamMethods;
  719. fMemory: Pointer;
  720. fData: TStreamData;
  721. fParam1, fParam2: DWORD; // parameters to use in thread
  722. function GetCapacity: DWORD;
  723. procedure SetCapacity(const Value: DWORD);
  724. function DoAsyncRead( Sender: PThread ): Integer;
  725. function DoAsyncWrite( Sender: PThread ): Integer;
  726. function DoAsyncSeek( Sender: PThread ): Integer;
  727. protected
  728. function GetFileStreamHandle: THandle;
  729. procedure SetPosition(Value: DWord);
  730. function GetPosition: DWord;
  731. function GetSize: DWord;
  732. procedure SetSize(NewSize: DWord);
  733. {++}(*public*){--}
  734. destructor Destroy; {-}virtual;{+}{++}(*override;*){--}
  735. public
  736. function Read(var Buffer; Count: DWord): DWord;
  737. {* Reads Count bytes from a stream. Returns number of bytes read. }
  738. function Seek(MoveTo: Integer; MoveMethod: TMoveMethod): DWord;
  739. {* Allows to change current position or to obtain it. Property
  740. Position uses this method both for get and set position. }
  741. function Write(var Buffer; Count: DWord): DWord;
  742. {* Writes Count bytes from Buffer, starting from current position
  743. in a stream. Returns how much bytes are written. }
  744. function WriteStr( S: String ): DWORD;
  745. {* Writes string to the stream, not including ending #0. Exactly
  746. Length( S ) characters are written. }
  747. function WriteStrZ( S: String ): DWORD;
  748. {* Writes string, adding #0. Number of bytes written is returned. }
  749. function ReadStrZ: String;
  750. {* Reads string, finished by #0. After reading, current position in
  751. the stream is set to the byte, follows #0. }
  752. function ReadStr: String;
  753. {* Reads string, finished by #13, #10 or #13#10 symbols. Terminating symbols
  754. #13 and/or #10 are not added to the end of returned string though
  755. stream positioned follow it. }
  756. function WriteStrEx(S: String): DWord;
  757. {* Writes string S to stream, also saving its size for future use by
  758. ReadStrEx* functions. Returns number of actually written characters. }
  759. function ReadStrExVar(var S: String): DWord;
  760. {* Reads string from stream and assigns it to S.
  761. Returns number of actually read characters.
  762. Note:
  763. String must be written by using WriteStrEx function.
  764. Return value is count of characters READ, not the length of string. }
  765. function ReadStrEx: String;
  766. {* Reads string from stream and returns it. }
  767. function WriteStrPas( S: String ): DWORD;
  768. {* Writes a string in Pascal short string format - 1 byte length, then string
  769. itself without trailing #0 char. S parameter length should not exceed 255
  770. chars, rest chars are truncated while writing. Total amount of bytes
  771. written is returned. }
  772. function ReadStrPas: String;
  773. {* Reads 1 byte from a stream, then treat it as a length of following string
  774. which is read and returned. A purpose of this function is reading strings
  775. written using WriteStrPas. }
  776. property Size: DWord read GetSize write SetSize;
  777. {* Returns stream size. For some custom streams, can be slow
  778. operation, or even always return undefined value (-1 recommended). }
  779. property Position: DWord read GetPosition write SetPosition;
  780. {* Current position. }
  781. property Memory: Pointer read fMemory;
  782. {* Only for memory stream. }
  783. property Handle: THandle read GetFileStreamHandle;
  784. {* Only for file stream. It is possible to check that Handle <>
  785. INVALID_HANDLE_VALUE to ensure that file stream is created OK. }
  786. //---------- for asynchronous operations (using thread - not tested):
  787. procedure SeekAsync(MoveTo: Integer; MoveMethod: TMoveMethod);
  788. {* Changes current position asynchronously. To wait for finishing the
  789. operation, use method Wait. }
  790. procedure ReadAsync(var Buffer; Count: DWord);
  791. {* Reads Count bytes from a stream asynchronously. To wait finishing the
  792. operation, use method Wait. }
  793. procedure WriteAsync(var Buffer; Count: DWord);
  794. {* Writes Count bytes from Buffer, starting from current position
  795. in a stream - asynchronously. To wait finishing the operation,
  796. use method Wait. }
  797. function Busy: Boolean;
  798. {* Returns TRUE until finishing the last asynchronous operation
  799. started by calling SeekAsync, ReadAsync, WriteAsync methods. }
  800. procedure Wait;
  801. {* Waits for finishing the last asynchronous operation. }
  802. property Methods: PStreamMethods read fPMethods;
  803. {* Pointer to TStreamMethods record. Useful to implement custom-defined
  804. streams, which can access its fCustom field, or even to change
  805. methods when necessary. }
  806. property Data: TStreamData read fData;
  807. {* Pointer to TStreamData record. Useful to implement custom-defined
  808. streams, which can access Data fields directly when implemented. }
  809. property Capacity: DWORD read GetCapacity write SetCapacity;
  810. {* Amound of memory allocated for data (MemoryStream). }
  811. end;
  812. //[END OF TStream DEFINITION]
  813. //[_NewStream DECLARATION]
  814. function _NewStream( const StreamMethods: TStreamMethods ): PStream;
  815. {* Use this method only to define your own stream type. See also declared
  816. below (in KOL.pas) methods used to implement standard KOL streams. You can use it in
  817. your code to create streams, which are partially based on standard
  818. methods. }
  819. // Methods below are declared here to simplify creating your
  820. // own streams with some methods standard and some non-standard
  821. // together:
  822. function SeekFileStream( Strm: PStream; MoveTo: Integer; MoveFrom: TMoveMethod ): DWORD;
  823. function GetSizeFileStream( Strm: PStream ): DWORD;
  824. function ReadFileStream( Strm: PStream; var Buffer; Count: DWORD ): DWORD;
  825. function WriteFileStream( Strm: PStream; var Buffer; Count: DWORD ): DWORD;
  826. function WriteFileStreamEOF( Strm: PStream; var Buffer; Count: DWORD ): DWORD;
  827. procedure CloseFileStream( Strm: PStream );
  828. function SeekMemStream( Strm: PStream; MoveTo: Integer; MoveFrom: TMoveMethod ): DWORD;
  829. function GetSizeMemStream( Strm: PStream ): DWORD;
  830. procedure SetSizeMemStream( Strm: PStream; NewSize: DWORD );
  831. function ReadMemStream( Strm: PStream; var Buffer; Count: DWORD ): DWORD;
  832. function WriteMemStream( Strm: PStream; var Buffer; Count: DWORD ): DWORD;
  833. procedure CloseMemStream( Strm: PStream );
  834. procedure SetSizeFileStream( Strm: PStream; NewSize: DWORD );
  835. function DummyReadWrite( Strm: PStream; var Buffer; Count: DWORD ): DWORD;
  836. procedure DummySetSize( Strm: PStream; Value: DWORD );
  837. procedure DummyStreamProc(Strm: PStream);
  838. //[NewFileStream DECLARATION]
  839. function NewFileStream( const FileName: String; Options: DWORD ): PStream;
  840. {* Creates file stream for read and write. Exact set of open attributes
  841. should be passed through Options parameter (see FileCreate where those
  842. flags are listed). }
  843. function NewReadFileStream( const FileName: String ): PStream;
  844. {* Creates file stream for read only. }
  845. function NewWriteFileStream( const FileName: String ): PStream;
  846. {* Creates file stream for write only. Truncating of file (if needed)
  847. is provided automatically. }
  848. function NewReadWriteFileStream( const FileName: String ): PStream;
  849. {* Creates stream for read and write file. To truncate file, if it is
  850. necessary, change Size property. }
  851. //[NewMemoryStream DECLARATION]
  852. function NewMemoryStream: PStream;
  853. {* Creates memory stream (read and write). }
  854. function NewExMemoryStream( ExistingMem: Pointer; Size: DWORD ): PStream;
  855. {* Creates memory stream on base of existing memory. It is not possible
  856. to write out of top bound given by Size (i.e. memory can not be resized,
  857. or reallocated. When stream object is destroyed this memory is not freed. }
  858. //[Stream2Stream DECLARATION]
  859. function Stream2Stream( Dst, Src: PStream; Count: DWORD ): DWORD;
  860. {* Copies Count (or less, if the rest of Src is not sufficiently long)
  861. bytes from Src to Dst, but with optimizing in cases, when Src or/and
  862. Dst are memory streams (intermediate buffer is not allocated). }
  863. function Stream2StreamEx( Dst, Src: PStream; Count: DWORD ): DWORD;
  864. {* Copies Count bytes from Src to Dst, but without any optimization.
  865. Unlike Stream2Stream function, it can be applied to very large streams.
  866. See also Stream2StreamExBufSz. }
  867. function Stream2StreamExBufSz( Dst, Src: PStream; Count, BufSz: DWORD ): DWORD;
  868. {* Copies Count bytes from Src to Dst using buffer of given size, but without
  869. other optimizations.
  870. Unlike Stream2Stream function, it can be applied to very large streams }
  871. //[Resource2Stream DECLARATION]
  872. function Resource2Stream( DestStrm : PStream; Inst : HInst;
  873. ResName : PChar; ResType : PChar ): Integer;
  874. {* Loads given resource to DestStrm. Useful for non-standard
  875. resources to load it into memory (use memory stream for such
  876. purpose). Use one of following resource types to pass as ResType:
  877. |<pre>
  878. RT_ACCELERATOR Accelerator table
  879. RT_ANICURSOR Animated cursor
  880. RT_ANIICON Animated icon
  881. RT_BITMAP Bitmap resource
  882. RT_CURSOR Hardware-dependent cursor resource
  883. RT_DIALOG Dialog box
  884. RT_FONT Font resource
  885. RT_FONTDIR Font directory resource
  886. RT_GROUP_CURSOR Hardware-independent cursor resource
  887. RT_GROUP_ICON Hardware-independent icon resource
  888. RT_ICON Hardware-dependent icon resource
  889. RT_MENU Menu resource
  890. RT_MESSAGETABLE Message-table entry
  891. RT_RCDATA Application-defined resource (raw data)
  892. RT_STRING String-table entry
  893. RT_VERSION Version resource
  894. |</pre>
  895. |<br>For example:
  896. !var MemStrm: PStream;
  897. ! JpgObj: PJpeg;
  898. !......
  899. ! MemStrm := NewMemoryStream;
  900. ! JpgObj := NewJpeg;
  901. !......
  902. ! Resource2Stream( MemStrm, hInstance, 'MYJPEG', RT_RCDATA );
  903. ! MemStrm.Position := 0;
  904. ! JpgObj.LoadFromStream( MemStrm );
  905. ! MemStrm.Free;
  906. !......
  907. }
  908. { -- string list objects -- }
  909. //[TStrList]
  910. type
  911. {++}(*TStrList = class;*){--}
  912. PStrList = {-}^{+}TStrList;
  913. { ---------------------------------------------------------------------
  914. TStrList - string list
  915. ---------------------------------------------------------------------- }
  916. //[TStrList DEFINITION]
  917. TStrList = object(TObj)
  918. {* Easy string list implementation (non-visual, just to store
  919. string data). It is well improved and has very high performance
  920. allowing to work fast with huge text files (more then megabyte
  921. of text data).
  922. |
  923. Please note that #0 charaster if stored in string lines, will cut it
  924. preventing reading the rest of a line. Be careful, if your data
  925. contain such characters. }
  926. protected
  927. procedure Init; virtual;
  928. protected
  929. fList: PList;
  930. fCount: Integer;
  931. fCaseSensitiveSort: Boolean;
  932. fTextBuf: PChar;
  933. fTextSiz: DWORD;
  934. function GetPChars(Idx: Integer): PChar;
  935. //procedure AddTextBuf( Src: PChar; Len: DWORD );
  936. protected
  937. function Get(Idx: integer): string;
  938. function GetTextStr: string;
  939. procedure Put(Idx: integer; const Value: string);
  940. procedure SetTextStr(const Value: string);
  941. {++}(*public*){--}
  942. destructor Destroy; {-}virtual;{+}{++}(*override;*){--}
  943. protected
  944. // by Dod:
  945. procedure SetValue(const AName, Value: string);
  946. function GetValue(const AName: string): string;
  947. public
  948. // by Dod:
  949. function IndexOfName(AName: string): Integer;
  950. {* by Dod. Returns index of line starting like Name=... }
  951. property Values[const AName: string]: string read GetValue write SetValue;
  952. {* by Dod. Returns right side of a line starting like Name=... }
  953. public
  954. function Add(const S: string): integer;
  955. {* Adds a string to list. }
  956. procedure AddStrings(Strings: PStrList);
  957. {* Merges string list with given one. Very fast - more preferrable to
  958. use than any loop with calling Add method. }
  959. procedure Assign(Strings: PStrList);
  960. {* Fills string list with strings from other one. The same as AddStrings,
  961. but Clear is called first. }
  962. procedure Clear;
  963. {* Makes string list empty. }
  964. procedure Delete(Idx: integer);
  965. {* Deletes string with given index (it *must* exist). }
  966. function IndexOf(const S: string): integer;
  967. {* Returns index of first string, equal to given one. }
  968. function IndexOf_NoCase(const S: string): integer;
  969. {* Returns index of first string, equal to given one (while comparing it
  970. without case sensitivity). }
  971. function IndexOfStrL_NoCase( Str: PChar; L: Integer ): integer;
  972. {* Returns index of first string, equal to given one (while comparing it
  973. without case sensitivity). }
  974. function Find(const S: String; var Index: Integer): Boolean;
  975. {* Returns Index of the first string, equal or greater to given pattern, but
  976. works only for sorted TStrList object. Returns TRUE if exact string found,
  977. otherwise nearest (greater then a pattern) string index is returned,
  978. and the result is FALSE. }
  979. procedure Insert(Idx: integer; const S: string);
  980. {* Inserts string before one with given index. }
  981. function LoadFromFile(const FileName: string): Boolean;
  982. {* Loads string list from a file. (If file does not exist, nothing
  983. happens). Very fast even for huge text files. }
  984. procedure LoadFromStream(Stream: PStream; Append2List: boolean);
  985. {* Loads string list from a stream (from current position to the end of
  986. a stream). Very fast even for huge text. }
  987. procedure MergeFromFile(const FileName: string);
  988. {* Merges string list with strings in a file. Fast. }
  989. procedure Move(CurIndex, NewIndex: integer);
  990. {* Moves string to another location. }
  991. procedure SetText(const S: string; Append2List: boolean);
  992. {* Allows to set strings of string list from given string (in which
  993. strings are separated by $0D,$0A or $0D characters). Text must not
  994. contain #0 characters. Works very fast. This method is used in
  995. all others, working with text arrays (LoadFromFile, MergeFromFile,
  996. Assign, AddStrings). }
  997. procedure SetUnixText( const S: String; Append2List: Boolean );
  998. {* Allows to assign UNIX-style text (with #10 as string separator). }
  999. function SaveToFile(const FileName: string): Boolean;
  1000. {* Stores string list to a file. }
  1001. procedure SaveToStream(Stream: PStream);
  1002. {* Saves string list to a stream (from current position). }
  1003. function AppendToFile(const FileName: string): Boolean;
  1004. {* Appends strings of string list to the end of a file. }
  1005. property Count: integer read fCount;
  1006. {* Number of strings in a string list. }
  1007. property Items[Idx: integer]: string read Get write Put; default;
  1008. {* Strings array items. If item does not exist, empty string is returned.
  1009. But for assign to property, string with given index *must* exist. }
  1010. property ItemPtrs[ Idx: Integer ]: PChar read GetPChars;
  1011. {* Fast access to item strings as PChars. }
  1012. function Last: String;
  1013. {* Last item (or '', if string list is empty). }
  1014. property Text: string read GetTextStr write SetTextStr;
  1015. {* Content of string list as a single string (where strings are separated
  1016. by characters $0D,$0A). }
  1017. procedure Swap( Idx1, Idx2 : Integer );
  1018. {* Swaps to strings with given indeces. }
  1019. procedure Sort( CaseSensitive: Boolean );
  1020. {* Call it to sort string list. }
  1021. procedure AnsiSort( CaseSensitive: Boolean );
  1022. {* Call it to sort ANSI string list. }
  1023. // by Alexander Pravdin:
  1024. protected
  1025. fNameDelim: Char;
  1026. function GetLineName( Idx: Integer ): string;
  1027. procedure SetLineName( Idx: Integer; const NV: string );
  1028. function GetLineValue(Idx: Integer): string;
  1029. procedure SetLineValue(Idx: Integer; const Value: string);
  1030. public
  1031. property LineName[ Idx: Integer ]: string read GetLineName write SetLineName;
  1032. property LineValue[ Idx: Integer ]: string read GetLineValue write SetLineValue;
  1033. property NameDelimiter: Char read fNameDelim write fNameDelim;
  1034. function Join( const sep: String ): String;
  1035. {* by Sergey Shishmintzev. }
  1036. end;
  1037. //[END OF TStrList DEFINITION]
  1038. //[DefaultNameDelimiter]
  1039. var DefaultNameDelimiter: Char = '=';
  1040. ThsSeparator: Char = ',';
  1041. //[NewStrList DECLARATION]
  1042. function NewStrList: PStrList;
  1043. {* Creates string list object. }
  1044. function GetFileList(const dir: string): PStrList;
  1045. {* By Alexander Shakhaylo. Returns list of file names of the given directory. }
  1046. {$IFNDEF _FPC}
  1047. function WStrLen( W: PWideChar ): Integer;
  1048. {* Returns Length of null-terminated Unicode string. }
  1049. {$ENDIF _FPC}
  1050. //[TStrListEx]
  1051. type
  1052. {++}(*TStrListEx = class;*){--}
  1053. PStrListEx = {-}^{+}TStrListEx;
  1054. //[TStrListEx DEFINITION]
  1055. TStrListEx = object( TStrList )
  1056. {* Extended string list object. Has additional capability to associate
  1057. numbers or objects with string list items. }
  1058. protected
  1059. FObjects: PList;
  1060. function GetObjects(Idx: Integer): DWORD;
  1061. procedure SetObjects(Idx: Integer; const Value: DWORD);
  1062. procedure Init; {-}virtual;{+}{++}(*override;*){--}
  1063. procedure ProvideObjCapacity( NewCap: Integer );
  1064. public
  1065. destructor Destroy; {-}virtual;{+}{++}(*override;*){--}
  1066. {* }
  1067. property Objects[ Idx: Integer ]: DWORD read GetObjects write SetObjects;
  1068. {* Objects are just 32-bit values. You can treat and use it as pointers to
  1069. any other data in the memory. But it is your task to free allocated
  1070. memory in such case therefore. }
  1071. procedure AddStrings(Strings: PStrListEx);
  1072. {* Merges string list with given one. Very fast - more preferrable to
  1073. use than any loop with calling Add method. }
  1074. procedure Assign(Strings: PStrListEx);
  1075. {* Fills string list with strings from other one. The same as AddStrings,
  1076. but Clear is called first. }
  1077. procedure Clear;
  1078. {* Makes string list empty. }
  1079. procedure Delete(Idx: integer);
  1080. {* Deletes string with given index (it *must* exist). }
  1081. procedure Move(CurIndex, NewIndex: integer);
  1082. {* Moves string to another location. }
  1083. procedure Swap( Idx1, Idx2 : Integer );
  1084. {* Swaps to strings with given indeces. }
  1085. procedure Sort( CaseSensitive: Boolean );
  1086. {* Call it to sort string list. }
  1087. procedure AnsiSort( CaseSensitive: Boolean );
  1088. {* Call it to sort ANSI string list. }
  1089. function LastObj: DWORD;
  1090. {* Object assotiated with the last string. }
  1091. function AddObject( const S: String; Obj: DWORD ): Integer;
  1092. {* Adds a string and associates given number with it. Index of the item added
  1093. is returned. }
  1094. procedure InsertObject( Before: Integer; const S: String; Obj: DWORD );
  1095. {* Inserts a string together with object associated. }
  1096. function IndexOfObj( Obj: Pointer ): Integer;
  1097. {* Returns an index of a string associated with the object passed as a
  1098. parameter. If there are no such strings, -1 is returned. }
  1099. end;
  1100. //[END OF TStrListEx DEFINITION]
  1101. //[NewStrListEx DECLARATION]
  1102. function NewStrListEx: PStrListEx;
  1103. {* Creates extended string list object. }
  1104. {+}
  1105. ////////////////////////////////////////////////////////////////////////////////
  1106. // GRAPHIC OBJECTS //
  1107. ////////////////////////////////////////////////////////////////////////////////
  1108. //[GRAPHIC OBJECTS]
  1109. {
  1110. It is very important, that the most of code, implementing graphic objets
  1111. from this section, is included into executable ONLY if really accessed in your
  1112. project directly (e.g., if Font or Brush properies of a control are accessed
  1113. or changed).
  1114. }
  1115. type
  1116. TColor = Integer;
  1117. const
  1118. //[COLOR CONSTANTS]
  1119. clScrollBar = TColor(COLOR_SCROLLBAR or $80000000);
  1120. clBackground = TColor(COLOR_BACKGROUND or $80000000);
  1121. clActiveCaption = TColor(COLOR_ACTIVECAPTION or $80000000);
  1122. clInactiveCaption = TColor(COLOR_INACTIVECAPTION or $80000000);
  1123. clMenu = TColor(COLOR_MENU or $80000000);
  1124. clWindow = TColor(COLOR_WINDOW or $80000000);
  1125. clWindowFrame = TColor(COLOR_WINDOWFRAME or $80000000);
  1126. clMenuText = TColor(COLOR_MENUTEXT or $80000000);
  1127. clWindowText = TColor(COLOR_WINDOWTEXT or $80000000);
  1128. clCaptionText = TColor(COLOR_CAPTIONTEXT or $80000000);
  1129. clActiveBorder = TColor(COLOR_ACTIVEBORDER or $80000000);
  1130. clInactiveBorder = TColor(COLOR_INACTIVEBORDER or $80000000);
  1131. clAppWorkSpace = TColor(COLOR_APPWORKSPACE or $80000000);
  1132. clHighlight = TColor(COLOR_HIGHLIGHT or $80000000);
  1133. clHighlightText = TColor(COLOR_HIGHLIGHTTEXT or $80000000);
  1134. clBtnFace = TColor(COLOR_BTNFACE or $80000000);
  1135. clBtnShadow = TColor(COLOR_BTNSHADOW or $80000000);
  1136. clGrayText = TColor(COLOR_GRAYTEXT or $80000000);
  1137. clBtnText = TColor(COLOR_BTNTEXT or $80000000);
  1138. clInactiveCaptionText = TColor(COLOR_INACTIVECAPTIONTEXT or $80000000);
  1139. clBtnHighlight = TColor(COLOR_BTNHIGHLIGHT or $80000000);
  1140. cl3DDkShadow = TColor(COLOR_3DDKSHADOW or $80000000);
  1141. cl3DLight = TColor(COLOR_3DLIGHT or $80000000);
  1142. clInfoText = TColor(COLOR_INFOTEXT or $80000000);
  1143. clInfoBk = TColor(COLOR_INFOBK or $80000000);
  1144. clBlack = TColor($000000);
  1145. clMaroon = TColor($000080);
  1146. clGreen = TColor($008000);
  1147. clOlive = TColor($008080);
  1148. clNavy = TColor($800000);
  1149. clPurple = TColor($800080);
  1150. clTeal = TColor($808000);
  1151. clGray = TColor($808080);
  1152. clSilver = TColor($C0C0C0);
  1153. clRed = TColor($0000FF);
  1154. clLime = TColor($00FF00);
  1155. clYellow = TColor($00FFFF);
  1156. clBlue = TColor($FF0000);
  1157. clFuchsia = TColor($FF00FF);
  1158. clAqua = TColor($FFFF00);
  1159. clLtGray = TColor($C0C0C0);
  1160. clDkGray = TColor($808080);
  1161. clWhite = TColor($FFFFFF);
  1162. clNone = TColor($1FFFFFFF);
  1163. clDefault = TColor($20000000);
  1164. clMoneyGreen = TColor($C0DCC0);
  1165. clSkyBlue = TColor($F0CAA6);
  1166. clCream = TColor($F0FBFF);
  1167. clMedGray = TColor($A4A0A0);
  1168. //[END OF COLOR CONSTANTS]
  1169. const
  1170. //[TGraphicTool FIELD OFFSET CONSTANTS]
  1171. go_Color = 0;
  1172. go_FontHeight = 4;
  1173. go_FontWidth = 8;
  1174. go_FontEscapement = 12;
  1175. go_FontOrientation = 16;
  1176. go_FontWeight = 20;
  1177. go_FontItalic = 24;
  1178. go_FontUnderline = 25;
  1179. go_FontStrikeOut = 26;
  1180. go_FontCharSet = 27;
  1181. go_FontOutPrecision = 28;
  1182. go_FontClipPrecision = 29;
  1183. go_FontQuality = 30;
  1184. go_FontPitch = 31;
  1185. go_FontName = 32;
  1186. go_BrushBitmap = 4;
  1187. go_BrushStyle = 8;
  1188. go_BrushLineColor = 9;
  1189. go_PenBrushBitmap = 4;
  1190. go_PenBrushStyle = 8;
  1191. go_PenStyle = 9;
  1192. go_PenWidth = 10;
  1193. go_PenMode = 14;
  1194. go_PenGeometric = 15;
  1195. go_PenEndCap = 16;
  1196. go_PenJoin = 17;
  1197. //[END OF TGraphicTool FIELD OFFSET CONSTANTS]
  1198. //[TGraphicTool]
  1199. type
  1200. TGraphicToolType = ( gttBrush, gttFont, gttPen );
  1201. {* Graphic object types, mainly for internal use. }
  1202. {++}(*TGraphicTool = class;*){--}
  1203. PGraphicTool = {-}^{+}TGraphicTool;
  1204. {* }
  1205. TOnGraphicChange = procedure ( Sender: PGraphicTool ) of object;
  1206. {* An event mainly for internal use. }
  1207. TBrushStyle = (bsSolid, bsClear, bsHorizontal, bsVertical,
  1208. bsFDiagonal, bsBDiagonal, bsCross, bsDiagCross);
  1209. {* Available brush styles. }
  1210. TFontStyles = (fsBold, fsItalic, fsUnderline, fsStrikeOut);
  1211. {* Available font styles. }
  1212. TFontStyle = set of TFontStyles;
  1213. {* Font style is representing as a set of XFontStyles. }
  1214. TFontPitch = (fpDefault, fpFixed, fpVariable);
  1215. {* Availabe font pitch values. }
  1216. TFontName = type string;
  1217. {* Font name is represented as a string. }
  1218. TFontCharset = 0..255;
  1219. {* Font charset is represented by number from 0 to 255. }
  1220. TFontQuality = (fqDefault, fqDraft, fqProof, fqNonAntialiased, fqAntialiased);
  1221. {* Font quality. }
  1222. TPenStyle = (psSolid, psDash, psDot, psDashDot, psDashDotDot, psClear,
  1223. psInsideFrame);
  1224. {* Available pen styles. For more info see Delphi or Win32 help files. }
  1225. TPenMode = (pmBlack, pmNotMerge, pmMaskNotPen, pmNotCopy, pmMaskPenNot,
  1226. pmNot, pmXor, pmNotMask, pmMask, pmNotXor, pmNop, pmMergePenNot,
  1227. pmCopy, pmMergeNotPen, pmMerge, pmWhite);
  1228. {* Available pen modes. For more info see Delphi or Win32 help files. }
  1229. TPenEndCap = (pecRound, pecSquare, pecFlat);
  1230. {* Avalable (for geometric pen) end cap styles. }
  1231. TPenJoin = (pjRound, pjBevel, pjMiter);
  1232. {* Available (for geometric pen) join styles. }
  1233. //[TGdiFont]
  1234. TGDIFont = packed record
  1235. Height: Integer;
  1236. Width: Integer;
  1237. Escapement: Integer;
  1238. Orientation: Integer;
  1239. Weight: Integer;
  1240. Italic: Boolean;
  1241. Underline: Boolean;
  1242. StrikeOut: Boolean;
  1243. CharSet: TFontCharset;
  1244. OutPrecision: Byte;
  1245. ClipPrecision: Byte;
  1246. Quality: TFontQuality;
  1247. Pitch: TFontPitch;
  1248. Name: array[0..LF_FACESIZE - 1] of Char;
  1249. end;
  1250. //[TGDIBrush]
  1251. TGDIBrush = packed record
  1252. Bitmap: HBitmap;
  1253. Style: TBrushStyle;
  1254. LineColor: TColor;
  1255. end;
  1256. //[TGDIPen]
  1257. TGDIPen = packed record
  1258. BrushBitmap: HBitmap;
  1259. BrushStyle: TBrushStyle;
  1260. Style: TPenStyle;
  1261. Width: Integer;
  1262. Mode: TPenMode;
  1263. Geometric: Boolean;
  1264. EndCap: TPenEndCap;
  1265. Join: TPenJoin;
  1266. end;
  1267. //[TGDIToolData]
  1268. TGDIToolData = packed record
  1269. Color: TColor;
  1270. case Integer of
  1271. 1: (Font: TGDIFont);
  1272. 2: (Pen: TGDIPen);
  1273. 3: (Brush: TGDIBrush);
  1274. end;
  1275. //[TNewGraphicTool]
  1276. TNewGraphicTool = function: PGraphicTool;
  1277. { ---------------------------------------------------------------------
  1278. TGraphicTool - object to implement GDI-tools (brush, pen, font)
  1279. ---------------------------------------------------------------------- }
  1280. //[TGraphicTool DEFINITION]
  1281. TGraphicTool = object( TObj )
  1282. {* Incapsulates all GDI objects: Pen, Brush and Font. }
  1283. protected
  1284. fType: TGraphicToolType;
  1285. fHandle: THandle;
  1286. fParentGDITool: PGraphicTool;
  1287. fOnChange: TOnGraphicChange;
  1288. fColorRGB: TColor;
  1289. fData: TGDIToolData;
  1290. fNewProc: TNewGraphicTool;
  1291. fMakeHandleProc: function( Self_: PGraphicTool ): THandle;
  1292. procedure SetInt( const Index: Integer; Value: Integer );
  1293. {$IFDEF F_P}
  1294. function GetInt( const Index: Integer ): Integer;
  1295. {$ENDIF}
  1296. procedure SetColor( Value: TColor );
  1297. procedure SetBrushBitmap(const Value: HBitmap);
  1298. procedure SetBrushStyle(const Value: TBrushStyle);
  1299. procedure SetFontCharset(const Value: TFontCharset);
  1300. procedure SetFontQuality(const Value: TFontQuality);
  1301. function GetFontName: String;
  1302. procedure SetFontName(const Value: String);
  1303. procedure SetFontOrientation(Value: Integer);
  1304. procedure SetFontPitch(const Value: TFontPitch);
  1305. function GetFontStyle: TFontStyle;
  1306. procedure SetFontStyle(const Value: TFontStyle);
  1307. procedure SetPenMode(const Value: TPenMode);
  1308. procedure SetPenStyle(const Value: TPenStyle);
  1309. procedure SetGeometricPen(const Value: Boolean);
  1310. procedure SetPenEndCap(const Value: TPenEndCap);
  1311. procedure SetPenJoin(const Value: TPenJoin);
  1312. procedure SetFontWeight(const Value: Integer);
  1313. procedure SetLogFontStruct(const Value: TLogFont);
  1314. function GetLogFontStruct: TLogFont;
  1315. protected
  1316. procedure Changed;
  1317. {* }
  1318. function GetHandle: THandle;
  1319. {* }
  1320. public
  1321. destructor Destroy; {-}virtual;{+}{++}(*override;*){--}
  1322. {* }
  1323. property Handle: THandle read GetHandle;
  1324. {* Every time, when accessed, real GDI object is created (if it is
  1325. not yet created). So, to prevent creating of the handle, use
  1326. HandleAllocated instead of comparing Handle with value 0. }
  1327. function HandleAllocated: Boolean;
  1328. {* Returns True, if handle is allocated (i.e., if real GDI
  1329. objet is created. }
  1330. property OnChange: TOnGraphicChange read fOnChange write fOnChange;
  1331. {* Called, when object is changed. }
  1332. function ReleaseHandle: Integer;
  1333. {* Returns Handle value (if allocated), releasing it from the
  1334. object (so, it is no more knows about this handle and its
  1335. HandleAllocated function returns False. }
  1336. property Color: TColor {index go_Color} read fData.Color write SetColor;
  1337. {* Color is the most common property for all Pen, Brush and
  1338. Font objects, so it is placed in its common for all of them. }
  1339. function Assign( Value: PGraphicTool ): PGraphicTool;
  1340. {* Assigns properties of the same (only) type graphic object,
  1341. excluding Handle. If assigning is really leading to change
  1342. object, procedure Changed is called. }
  1343. procedure AssignHandle( NewHandle: Integer );
  1344. {* Assigns value to Handle property. }
  1345. property BrushBitmap: HBitmap read fData.Brush.Bitmap write SetBrushBitmap;
  1346. {* Brush bitmap. For more info about using brush bitmap,
  1347. see Delphi or Win32 help files. }
  1348. property BrushStyle: TBrushStyle read fData.Brush.Style write SetBrushStyle;
  1349. {* Brush style. }
  1350. property BrushLineColor: TColor index go_BrushLineColor
  1351. {$IFDEF F_P}
  1352. read GetInt
  1353. {$ELSE DELPHI}
  1354. read fData.Brush.LineColor
  1355. {$ENDIF F_P/DELPHI}
  1356. write SetInt;
  1357. {* Brush line color, used to represent lines in hatched brush. Default value is clBlack. }
  1358. property FontHeight: Integer index go_FontHeight
  1359. {$IFDEF F_P}
  1360. read GetInt
  1361. {$ELSE DELPHI}
  1362. read fData.Font.Height
  1363. {$ENDIF F_P/DELPHI}
  1364. write SetInt;
  1365. {* Font height. Value 0 (default) seys to use system default value,
  1366. negative values are to represent font height in "points", positive
  1367. - in pixels. In XCL usually positive values (if not 0) are used to
  1368. make appearance independent from different local settings. }
  1369. property FontWidth: Integer index go_FontWidth
  1370. {$IFDEF F_P}
  1371. read GetInt
  1372. {$ELSE DELPHI}
  1373. read fData.Font.Width
  1374. {$ENDIF F_P/DELPHI}
  1375. write SetInt;
  1376. {* Font width in logical units. If FontWidth = 0, then as it is said
  1377. in Win32.hlp, "the aspect ratio of the device is matched against the
  1378. digitization aspect ratio of the available fonts to find the closest match,
  1379. determined by the absolute value of the difference." }
  1380. property FontPitch: TFontPitch read fData.Font.Pitch write SetFontPitch;
  1381. {* Font pitch. Change it very rare. }
  1382. property FontStyle: TFontStyle read GetFontStyle write SetFontStyle;
  1383. {* Very useful property to control text appearance. }
  1384. property FontCharset: TFontCharset read fData.Font.Charset write SetFontCharset;
  1385. {* Do not change it if You do not know what You do. }
  1386. property FontQuality: TFontQuality read fData.Font.Quality write SetFontQuality;
  1387. {* Font quality. }
  1388. property FontOrientation: Integer read fData.Font.Orientation write SetFontOrientation;
  1389. {* It is possible to rotate text in XCL just by changing this
  1390. property of a font (tenths of degree, i.e. value 900 represents
  1391. 90 degree - text written from bottom to top). }
  1392. property FontWeight: Integer read fData.Font.Weight write SetFontWeight;
  1393. {* Additional font weight for bold fonts (must be 0..1000). When set to
  1394. value <> 0, fsBold is added to FontStyle. And otherwise, when set to 0,
  1395. fsBold is removed from FontStyle. Value 700 corresponds to Bold,
  1396. 400 to Normal. }
  1397. property FontName: String read GetFontName write SetFontName;
  1398. {* Font face name. }
  1399. function IsFontTrueType: Boolean;
  1400. {* Returns True, if font is True Type. Requires of creating of a Handle,
  1401. if it is not yet created. }
  1402. property PenWidth: Integer index go_PenWidth
  1403. {$IFDEF F_P}
  1404. read GetInt
  1405. {$ELSE DELPHI}
  1406. read fData.Pen.Width
  1407. {$ENDIF F_P/DELPHI}
  1408. write SetInt;
  1409. {* Value 0 means default pen width. }
  1410. property PenStyle: TPenStyle read fData.Pen.Style write SetPenStyle;
  1411. {* Pen style. }
  1412. property PenMode: TPenMode read fData.Pen.Mode write SetPenMode;
  1413. {* Pen mode. }
  1414. property GeometricPen: Boolean read fData.Pen.Geometric write SetGeometricPen;
  1415. {* True if Pen is geometric. Note, that under Win95/98 only pen styles
  1416. psSolid, psNull, psInsideFrame are supported by OS. }
  1417. property PenBrushStyle: TBrushStyle read fData.Pen.BrushStyle write SetBrushStyle;
  1418. {* Brush style for hatched geometric pen. }
  1419. property PenBrushBitmap: HBitmap read fData.Pen.BrushBitmap write SetBrushBitmap;
  1420. {* Brush bitmap for geometric pen (if assigned Pen is functioning as
  1421. its style = BS_PATTERN, regadless of PenBrushStyle value). }
  1422. property PenEndCap: TPenEndCap read fData.Pen.EndCap write SetPenEndCap;
  1423. {* Pen end cap mode - for GeometricPen only. }
  1424. property PenJoin: TPenJoin read fData.Pen.Join write SetPenJoin;
  1425. {* Pen join mode - for GeometricPen only. }
  1426. property LogFontStruct: TLogFont read GetLogFontStruct write SetLogFontStruct;
  1427. {* by Alex Pravdin: a property to change all font structure items at once. }
  1428. end;
  1429. //[END OF TGraphicTool DEFINITION]
  1430. //[Color2XXX FUNCTIONS]
  1431. function Color2RGB( Color: TColor ): TColor;
  1432. {* Function to get RGB color from system color. Parameter can be also RGB
  1433. color, in that case result is just equal to a parameter. }
  1434. function ColorsMix( Color1, Color2: TColor ): TColor;
  1435. {* Returns color, which RGB components are build as an (approximate)
  1436. arithmetic mean of correspondent RGB components of both source
  1437. colors (these both are first converted from system to RGB, and
  1438. result is always RGB color). Please note: this function is fast,
  1439. but can be not too exact. }
  1440. function Color2RGBQuad( Color: TColor ): TRGBQuad;
  1441. {* Converts color to RGB, used to represent RGB values in palette entries
  1442. (actually swaps R and B bytes). }
  1443. function Color2Color16( Color: TColor ): WORD;
  1444. {* Converts Color to RGB, packed to word (as it is used in format pf16bit). }
  1445. //[DefFont VARIABLE]
  1446. var // New TFont instances are intialized with the values in this structure:
  1447. DefFont: TGDIFont = (
  1448. Height: 0;
  1449. Width: 0;
  1450. Escapement: 0;
  1451. Orientation: 0;
  1452. Weight: 0;
  1453. Italic: FALSE;
  1454. Underline: FALSE;
  1455. StrikeOut: FALSE;
  1456. CharSet: 1;
  1457. OutPrecision: 0;
  1458. ClipPrecision: 0;
  1459. Quality: fqDefault;
  1460. Pitch: fpDefault;
  1461. Name: 'MS Sans Serif';
  1462. );
  1463. DefFontColor: TColor = clWindowText;
  1464. {* Default font color. }
  1465. //[GlobalGraphics_UseFontOrient]
  1466. GlobalGraphics_UseFontOrient: Boolean;
  1467. {* Global flag. If stays False (default), Orientation property of Font
  1468. objects is ignored. This flag is set to True automatically in
  1469. RotateFonts add-on. }
  1470. { -- Constructors for different GDI tools -- }
  1471. //[New FUNCTIONS FOR TGraphicTool]
  1472. function NewFont: PGraphicTool;
  1473. {* Creates and returns font graphic tool object. }
  1474. function NewBrush: PGraphicTool;
  1475. {* Creates and returns new brush object. }
  1476. function NewPen: PGraphicTool;
  1477. {* Creates and returns new pen object. }
  1478. { -- TCanvas object -- }
  1479. //[TCanvas]
  1480. const
  1481. HandleValid = 1;
  1482. PenValid = 2;
  1483. BrushValid = 4;
  1484. FontValid = 8;
  1485. ChangingCanvas = 16;
  1486. type
  1487. TFillStyle = (fsSurface, fsBorder);
  1488. {* Available filling styles. For more info see Win32 or Delphi help files. }
  1489. TFillMode = (fmAlternate, fmWinding);
  1490. {* Available filling modes. For more info see Win32 or Delphi help files. }
  1491. TCopyMode = Integer;
  1492. {* Available copying modes are following:
  1493. | cmBlackness<br>
  1494. | cmDstInvert<br>
  1495. | cmMergeCopy<br>
  1496. | cmMergePaint<br>
  1497. | cmNotSrcCopy<br>
  1498. | cmNotSrcErase<br>
  1499. | cmPatCopy<br>
  1500. | cmPatInvert<br>
  1501. | cmPatPaint<br>
  1502. | cmSrcAnd<br>
  1503. | cmSrcCopy<br>
  1504. | cmSrcErase<br>
  1505. | cmSrcInvert<br>
  1506. | cmSrcPaint<br>
  1507. | cmWhiteness<br>&nbsp;&nbsp;&nbsp;
  1508. Also it is possible to use any other available ROP2 modes. For more info,
  1509. see Win32 help files. }
  1510. const
  1511. cmBlackness = BLACKNESS;
  1512. cmDstInvert = DSTINVERT;
  1513. cmMergeCopy = MERGECOPY;
  1514. cmMergePaint = MERGEPAINT;
  1515. cmNotSrcCopy = NOTSRCCOPY;
  1516. cmNotSrcErase = NOTSRCERASE;
  1517. cmPatCopy = PATCOPY;
  1518. cmPatInvert = PATINVERT;
  1519. cmPatPaint = PATPAINT;
  1520. cmSrcAnd = SRCAND;
  1521. cmSrcCopy = SRCCOPY;
  1522. cmSrcErase = SRCERASE;
  1523. cmSrcInvert = SRCINVERT;
  1524. cmSrcPaint = SRCPAINT;
  1525. cmWhiteness = WHITENESS;
  1526. type
  1527. {++}(*TCanvas = class;*){--}
  1528. PCanvas = {-}^{+}TCanvas;
  1529. {* }
  1530. TOnGetHandle = function( Canvas: PCanvas ): HDC of object;
  1531. {* For internal use mainly. }
  1532. TOnTextArea = procedure( Sender: PCanvas; var Size : TSize; var P0 : TPoint );
  1533. {* Event to calculate actual area, occupying by a text. It is used
  1534. to optionally extend calculating of TextArea taking into considaration
  1535. font Orientation property. }
  1536. { ---------------------------------------------------------------------
  1537. TCanvas - high-level drawing helper object
  1538. ----------------------------------------------------------------------- }
  1539. //[TCanvas DEFINITION]
  1540. TCanvas = object( TObj )
  1541. {* Very similar to VCL's TCanvas object. But with some changes, specific
  1542. for KOL: there is no necessary to use canvases in all applications.
  1543. And graphic tools objects are not created with canvas, but only
  1544. if really accessed in program. (Actually, even if paint box used,
  1545. only programmer decides, if to implement painting using Canvas or
  1546. to call low level API drawing functions working directly with DC).
  1547. Therefore TCanvas has some powerful extensions: rotated text support,
  1548. geometric pen support - just by changing correspondent properties
  1549. of certain graphic tool objects (Font.FontOrientation, Pen.GeometricPen).
  1550. See also additional Font properties (Font.FontWeight, Font.FontQuality,
  1551. etc. }
  1552. protected
  1553. fOwnerControl: Pointer; //PControl;
  1554. fHandle : HDC;
  1555. fPenPos : TPoint;
  1556. fBrush, fFont, fPen : PGraphicTool; // order is important for ASM version
  1557. fState : Byte;
  1558. fCopyMode : TCopyMode;
  1559. fOnChange: TOnEvent;
  1560. fOnGetHandle: TOnGetHandle;
  1561. procedure SetHandle( Value : HDC );
  1562. procedure SetPenPos( const Value : TPoint );
  1563. procedure CreatePen;
  1564. procedure CreateBrush;
  1565. procedure CreateFont;
  1566. procedure ObjectChanged( Sender : PGraphicTool );
  1567. procedure Changing;
  1568. function GetBrush: PGraphicTool;
  1569. function GetFont: PGraphicTool;
  1570. function GetPen: PGraphicTool;
  1571. function GetHandle: HDC;
  1572. procedure AssignChangeEvents;
  1573. function GetPixels(X, Y: Integer): TColor;
  1574. procedure SetPixels(X, Y: Integer; const Value: TColor);
  1575. protected
  1576. fIsPaintDC : Boolean;
  1577. {* TRUE, if DC obtained during current WM_PAINT (or WM_ERASEBKGND?)
  1578. processing for a control. This affects a way how Handle is released. }
  1579. {++}(*public*){--}
  1580. destructor Destroy;{-}virtual;{+}{++}(*override;*){--}
  1581. {* }
  1582. {++}(*protected*){--}
  1583. property OnGetHandle: TOnGetHandle read fOnGetHandle write fOnGetHandle;
  1584. {* For internal use only. }
  1585. public
  1586. property Handle : HDC read GetHandle write SetHandle;
  1587. {* GDI device context object handle. Never created by
  1588. Canvas itself (to use Canvas with memory bitmaps,
  1589. always create DC by yourself and assign it to the
  1590. Handle property of Canvas object, or use property
  1591. Canvas of a bitmap). }
  1592. property PenPos : TPoint read FPenPos write SetPenPos;
  1593. {* Position of a pen. }
  1594. property Pen : PGraphicTool read GetPen;
  1595. {* Pen of Canvas object. Do not change its Pen.OnChange event value. }
  1596. property Brush : PGraphicTool read GetBrush;
  1597. {* Brush of Canvas object. Do not change its Brush.OnChange event value. }
  1598. property Font : PGraphicTool read GetFont;
  1599. {* Font of Canvas object. Do not change its Font.OnChange event value. }
  1600. procedure Arc(X1, Y1, X2, Y2, X3, Y3, X4, Y4: Integer); stdcall;
  1601. {* Draws arc. For more info, see Delphi TCanvas help. }
  1602. procedure Chord(X1, Y1, X2, Y2, X3, Y3, X4, Y4: Integer); stdcall;
  1603. {* Draws chord. For more info, see Delphi TCanvas help. }
  1604. procedure DrawFocusRect({$IFNDEF FPC}const{$ENDIF} Rect: TRect);
  1605. {* Draws rectangle to represent focused visual object.
  1606. For more info, see Delphi TCanvas help. }
  1607. procedure Ellipse(X1, Y1, X2, Y2: Integer);
  1608. {* Draws an ellipse. For more info, see Delphi TCanvas help. }
  1609. procedure FillRect({$IFNDEF FPC}const{$ENDIF} Rect: TRect);
  1610. {* Fills rectangle. For more info, see Delphi TCanvas help. }
  1611. procedure FillRgn( const Rgn : HRgn );
  1612. {* Fills region. For more info, see Delphi TCanvas help. }
  1613. procedure FloodFill(X, Y: Integer; Color: TColor; FillStyle: TFillStyle);
  1614. {* Fills a figure with givien color, floodfilling its surface.
  1615. For more info, see Delphi TCanvas help. }
  1616. procedure FrameRect({$IFNDEF FPC}const{$ENDIF} Rect: TRect);
  1617. {* Draws a rectangle using Brush settings (color, etc.).
  1618. For more info, see Delphi TCanvas help. }
  1619. procedure MoveTo( X, Y : Integer );
  1620. {* Moves current PenPos to a new position.
  1621. For more info, see Delphi TCanvas help. }
  1622. procedure LineTo( X, Y : Integer );
  1623. {* Draws a line from current PenPos up to new position.
  1624. For more info, see Delphi TCanvas help. }
  1625. procedure Pie(X1, Y1, X2, Y2, X3, Y3, X4, Y4: Integer); stdcall;
  1626. {* Draws a pie. For more info, see Delphi TCanvas help. }
  1627. procedure Polygon(const Points: array of TPoint);
  1628. {* Draws a polygon. For more info, see Delphi TCanvas help. }
  1629. procedure Polyline(const Points: array of TPoint);
  1630. {* Draws a bound for polygon. For more info, see Delphi TCanvas help. }
  1631. procedure Rectangle(X1, Y1, X2, Y2: Integer);
  1632. {* Draws a rectangle using current Pen and/or Brush.
  1633. For more info, see Delphi TCanvas help. }
  1634. procedure RoundRect(X1, Y1, X2, Y2, X3, Y3: Integer);
  1635. {* Draws a rounded rectangle. For more info, see Delphi TCanvas help. }
  1636. procedure TextOut(X, Y: Integer; const Text: String); stdcall;
  1637. {* Draws a text. For more info, see Delphi TCanvas help. }
  1638. procedure ExtTextOut( X, Y: Integer; Options: DWORD; const Rect: TRect; const Text: String;
  1639. const Spacing: array of Integer );
  1640. {* }
  1641. procedure DrawText(Text:String; var Rect:TRect; Flags:DWord);
  1642. {* }
  1643. procedure TextRect(const Rect: TRect; X, Y: Integer; const Text: string);
  1644. {* Draws a text, clipping output into given rectangle.
  1645. For more info, see Delphi TCanvas help. }
  1646. function TextExtent(const Text: string): TSize;
  1647. {* Calculates size of a Text, using current Font settings.
  1648. Does not need in Handle for Canvas object (if it is not
  1649. yet allocated, temporary device context is created and used. }
  1650. procedure TextArea( const Text : String; var Sz : TSize; var P0 : TPoint );
  1651. {* Calculates size and starting point to output Text,
  1652. taking into considaration all Font attributes, including
  1653. Orientation (only if GlobalGraphics_UseFontOrient flag
  1654. is set to True, i.e. if rotated fonts are used).
  1655. Like for TextExtent, does not need in Handle (and if this
  1656. last is not yet allocated/assigned, temporary device context
  1657. is created and used). }
  1658. function TextWidth(const Text: string): Integer;
  1659. {* Calculates text width (using TextArea). }
  1660. function TextHeight(const Text: string): Integer;
  1661. {* Calculates text height (using TextArea). }
  1662. function ClipRect: TRect;
  1663. {* returns ClipBox. by Dmitry Zharov. }
  1664. {$IFNDEF _FPC}
  1665. {$IFNDEF _D2} //------- WideString not supported in D2
  1666. procedure WTextOut(X, Y: Integer; const WText: WideString); stdcall;
  1667. {* Draws a Unicode text. }
  1668. procedure WExtTextOut( X, Y: Integer; Options: DWORD; const Rect: TRect;
  1669. const WText: WideString; const Spacing: array of Integer );
  1670. {* }
  1671. procedure WDrawText(WText: WideString; var Rect:TRect; Flags:DWord);
  1672. {* }
  1673. procedure WTextRect(const Rect: TRect; X, Y: Integer;
  1674. const WText: WideString);
  1675. {* Draws a Unicode text, clipping output into given rectangle. }
  1676. function WTextExtent( const WText: WideString ): TSize;
  1677. {* Calculates Unicode text width and height. }
  1678. function WTextWidth( const WText: WideString ): Integer;
  1679. {* Calculates Unicode text width. }
  1680. function WTextHeight( const WText: WideString ): Integer;
  1681. {* Calculates Unicode text height. }
  1682. {$ENDIF _D2}
  1683. {$ENDIF _FPC}
  1684. property ModeCopy : TCopyMode read fCopyMode write fCopyMode;
  1685. {* Current copy mode. Is used in CopyRect method. }
  1686. procedure CopyRect( const DstRect : TRect; SrcCanvas : PCanvas; const SrcRect : TRect );
  1687. {* Copyes a rectangle from source to destination, using StretchBlt. }
  1688. property OnChange: TOnEvent read fOnChange write fOnChange;
  1689. {* }
  1690. function Assign( SrcCanvas : PCanvas ) : Boolean;
  1691. {* }
  1692. function RequiredState( ReqState : DWORD ): Integer; stdcall;// public now
  1693. {* It is possible to call this method before using Handle property
  1694. to pass it into API calls - to provide valid combinations of
  1695. pen, brush and font, selected into device context. This method
  1696. can not provide valid Handle - You always must create it by
  1697. yourself and assign to TCanvas.Handle property manually.
  1698. To optimize assembler version, returns Handle value. }
  1699. procedure DeselectHandles;
  1700. {* Call this method to deselect all graphic tool objects from the canvas. }
  1701. property Pixels[ X, Y: Integer ]: TColor read GetPixels write SetPixels;
  1702. {* Obvious. }
  1703. end;
  1704. //[END OF TCanvas DEFINITION]
  1705. //[GlobalCanvas_OnTextArea]
  1706. var
  1707. GlobalCanvas_OnTextArea : TOnTextArea;
  1708. {* Global event to extend Canvas with possible add-ons, applied
  1709. when rotated fonts are used only (to take into consideration
  1710. Font.Orientation property in TextArea method). }
  1711. //[NewCanvas DECLARATION]
  1712. function NewCanvas( DC: HDC ): PCanvas;
  1713. {* Use to construct Canvas on base of memory DC. }
  1714. //[Extended FUNCTIONS TO WORK WITH CANVAS]
  1715. {++}(*
  1716. {$IFDEF F_P}
  1717. function Windows_Polygon(DC: HDC; var Points; Count: Integer): BOOL; stdcall;
  1718. function Windows_Polyline(DC: HDC; var Points; Count: Integer): BOOL; stdcall;
  1719. function FillRect(hDC: HDC; const lprc: TRect; hbr: HBRUSH): Integer; stdcall;
  1720. function OffsetRect(var lprc: TRect; dx, dy: Integer): BOOL; stdcall;
  1721. function CreateAcceleratorTable(var Accel; Count: Integer): HACCEL; stdcall;
  1722. function TrackPopupMenu(hMenu: HMENU; uFlags: UINT; x, y, nReserved: Integer;
  1723. hWnd: HWND; prcRect: PRect): BOOL; stdcall;
  1724. function AdjustTokenPrivileges(TokenHandle: THandle; DisableAllPrivileges: BOOL;
  1725. const NewState: TTokenPrivileges; BufferLength: DWORD;
  1726. var PreviousState: TTokenPrivileges; var ReturnLength: DWORD): BOOL; stdcall;
  1727. function InflateRect(var lprc: TRect; dx, dy: Integer): BOOL; stdcall;
  1728. {$IFDEF F_P105ORBELOW}
  1729. function InvalidateRect(hWnd: HWND; lpRect: PRect; bErase: BOOL): BOOL; stdcall;
  1730. function ValidateRect(hWnd: HWND; lpRect: PRect): BOOL; stdcall;
  1731. {$ENDIF F_P105ORBELOW}
  1732. {$ENDIF}
  1733. *){--}
  1734. { -- Image list object -- }
  1735. //[IMAGE LIST]
  1736. type
  1737. TImageListColors = (ilcColor,ilcColor4,ilcColor8,ilcColor16,
  1738. ilcColor24,ilcColor32,ilcColorDDB,ilcDefault);
  1739. {* ImageList color schemes available. }
  1740. TDrawingStyles = ( dsBlend25, dsBlend50, dsMask, dsTransparent );
  1741. {* ImageList drawing styles available. }
  1742. TDrawingStyle = Set of TDrawingStyles;
  1743. {* Style of drawing is a combination of all available drawing styles. }
  1744. TImageType = (itBitmap,itIcon,itCursor);
  1745. {* ImageList types available. }
  1746. {++}(*TImageList = class;*){--}
  1747. PImageList = {-}^{+}TImageList;
  1748. {* }
  1749. TImgLOVrlayIdx = 1..15;
  1750. { ---------------------------------------------------------------------
  1751. TImageList - images container
  1752. ----------------------------------------------------------------------- }
  1753. //[TImageList DEFINITION]
  1754. TImageList = object( TObj )
  1755. {* ImageList incapsulation. }
  1756. protected
  1757. FHandle: THandle;
  1758. FControl: Pointer; // PControl;
  1759. fPrev, fNext: PImageList;
  1760. FColors: TImageListColors;
  1761. FMasked: Boolean;
  1762. FImgWidth: Integer;
  1763. FImgHeight: Integer;
  1764. FDrawingStyle: TDrawingStyle;
  1765. FBlendColor: TColor;
  1766. fBkColor: TColor;
  1767. FAllocBy: Integer;
  1768. FShareImages: Boolean;
  1769. FOverlay: array[ TImgLOVrlayIdx ] of Integer;
  1770. function HandleNeeded : Boolean;
  1771. procedure SetColors(const Value: TImageListColors);
  1772. procedure SetMasked(const Value: Boolean);
  1773. procedure SetImgWidth(const Value: Integer);
  1774. procedure SetImgHeight(const Value: Integer);
  1775. function GetCount: Integer;
  1776. function GetBkColor: TColor;
  1777. procedure SetBkColor(const Value: TColor);
  1778. function GetBitmap: HBitmap;
  1779. function GetMask: HBitmap;
  1780. function GetDrawStyle : DWord;
  1781. procedure SetAllocBy(const Value: Integer);
  1782. function GetHandle: THandle;
  1783. function GetOverlay(Idx: TImgLOVrlayIdx): Integer;
  1784. procedure SetOverlay(Idx: TImgLOVrlayIdx; const Value: Integer);
  1785. protected
  1786. procedure SetHandle(const Value: THandle);
  1787. {*}
  1788. public
  1789. destructor Destroy; {-}virtual;{+}{++}(*override;*){--}
  1790. {*}
  1791. property Handle : THandle read GetHandle write SetHandle;
  1792. {* Handle of ImageList object. }
  1793. property ShareImages : Boolean read FShareImages write FShareImages;
  1794. {* True if images are shared between processes (it is set to True,
  1795. if its Handle is assigned to given value, which is a handle of
  1796. already existing ImageList object). }
  1797. property Colors : TImageListColors read FColors write SetColors;
  1798. {* Colors used to represent images. }
  1799. property Masked : Boolean read FMasked write SetMasked;
  1800. {* True, if mask is used. It is set to True, if first added image
  1801. is icon, e.g. }
  1802. property ImgWidth : Integer read FImgWidth write SetImgWidth;
  1803. {* Width of every image in list. If change, ImageList is cleared. }
  1804. property ImgHeight : Integer read FImgHeight write SetImgHeight;
  1805. {* Height of every image in list. If change, ImageList is cleared. }
  1806. property Count : Integer read GetCount;
  1807. {* Number of images in list. }
  1808. property AllocBy : Integer read FAllocBy write SetAllocBy;
  1809. {* Allocation factor. Default is 1. Set it to size of ImageList if this
  1810. value is known - to optimize speed of allocation. }
  1811. property BkColor : TColor read GetBkColor write SetBkColor;
  1812. {* Background color. }
  1813. property BlendColor : TColor read FBlendColor write FBlendColor;
  1814. {* Blend color. }
  1815. property Bitmap : HBitmap read GetBitmap;
  1816. {* Bitmap, containing all ImageList images (tiled horizontally). }
  1817. property Mask : HBitmap read GetMask;
  1818. {* Monochrome bitmap, containing masks for all images in list (if not
  1819. Masked, always returns nil). }
  1820. function ImgRect( Idx : Integer ) : TRect;
  1821. {* Rectangle occupied of given image in ImageList. }
  1822. function Add( Bmp, Msk : HBitmap ) : Integer;
  1823. {* Adds bitmap and given mask to ImageList. }
  1824. function AddMasked( Bmp : HBitmap; Color : TColor ) : Integer;
  1825. {* Adds bitmap to ImageList, using given color to create mask. }
  1826. function AddIcon( Ico : HIcon ) : Integer;
  1827. {* Adds icon to ImageList (always masked). }
  1828. procedure Delete( Idx : Integer );
  1829. {* Deletes given image from ImageList. }
  1830. procedure Clear;
  1831. {* Makes ImageList empty. }
  1832. function Replace( Idx : Integer; Bmp, Msk : HBitmap ) : Boolean;
  1833. {* Replaces given (by index) image with bitmap and its mask with mask bitmap. }
  1834. function ReplaceIcon( Idx : Integer; Ico : HIcon ) : Boolean;
  1835. {* Replaces given (by index) image with an icon. }
  1836. function Merge( Idx : Integer; ImgList2 : PImageList; Idx2 : Integer; X, Y : Integer )
  1837. : PImageList;
  1838. {* Merges two ImageList objects, returns resulting ImageList. }
  1839. function ExtractIcon( Idx : Integer ) : HIcon;
  1840. {* Extracts icon by index. }
  1841. function ExtractIconEx( Idx : Integer ) : HIcon;
  1842. {* Extracts icon (is created using current drawing style). }
  1843. property DrawingStyle : TDrawingStyle read FDrawingStyle write FDrawingStyle;
  1844. {* Drawing style. }
  1845. procedure Draw( Idx : Integer; DC : HDC; X, Y : Integer );
  1846. {* Draws given (by index) image from ImageList onto passed Device Context. }
  1847. procedure StretchDraw( Idx : Integer; DC : HDC; const Rect : TRect );
  1848. {* Draws given image with stratching. }
  1849. function LoadBitmap( ResourceName : PChar; TranspColor : TColor ) : Boolean;
  1850. {* Loads ImageList from resource. }
  1851. //function LoadIcon( ResourceName : PChar ) : Boolean;
  1852. //function LoadCursor( ResourceName : PChar ) : Boolean;
  1853. function LoadFromFile( FileName : PChar; TranspColor : TColor; ImgType : TImageType ) : Boolean;
  1854. {* Loads ImageList from file. }
  1855. function LoadSystemIcons( SmallIcons : Boolean ) : Boolean;
  1856. {* Assigns ImageList to system icons list (big or small). }
  1857. property Overlay[ Idx: TImgLOVrlayIdx ]: Integer read GetOverlay write SetOverlay;
  1858. {* Overlay images for image list (images, used as overlay images to draw over
  1859. other images from the image list). These overalay images can be used in
  1860. listview and treeview as overlaying images (up to four masks at the same
  1861. time). }
  1862. {$IFDEF USE_CONSTRUCTORS}
  1863. constructor CreateImageList( POwner: Pointer );
  1864. {$ENDIF USE_CONSTRUCTORS}
  1865. end;
  1866. //[END OF TImageList DEFINITION]
  1867. //[IMAGE LIST API]
  1868. const
  1869. CLR_NONE = $FFFFFFFF;
  1870. CLR_DEFAULT = $FF000000;
  1871. type
  1872. HImageList = THandle;
  1873. const
  1874. ILC_MASK = $0001;
  1875. ILC_COLOR = $00FE;
  1876. ILC_COLORDDB = $00FE;
  1877. ILC_COLOR4 = $0004;
  1878. ILC_COLOR8 = $0008;
  1879. ILC_COLOR16 = $0010;
  1880. ILC_COLOR24 = $0018;
  1881. ILC_COLOR32 = $0020;
  1882. ILC_PALETTE = $0800;
  1883. const
  1884. ILD_NORMAL = $0000;
  1885. ILD_TRANSPARENT = $0001;
  1886. ILD_MASK = $0010;
  1887. ILD_IMAGE = $0020;
  1888. ILD_BLEND25 = $0002;
  1889. ILD_BLEND50 = $0004;
  1890. ILD_OVERLAYMASK = $0F00;
  1891. const
  1892. ILD_SELECTED = ILD_BLEND50;
  1893. ILD_FOCUS = ILD_BLEND25;
  1894. ILD_BLEND = ILD_BLEND50;
  1895. CLR_HILIGHT = CLR_DEFAULT;
  1896. function ImageList_Create(CX, CY: Integer; Flags: UINT;
  1897. Initial, Grow: Integer): HImageList; stdcall;
  1898. function ImageList_Destroy(ImageList: HImageList): Bool; stdcall;
  1899. function ImageList_GetImageCount(ImageList: HImageList): Integer; stdcall;
  1900. function ImageList_SetImageCount(ImageList: HImageList; Count: Integer): Integer; stdcall;
  1901. function ImageList_Add(ImageList: HImageList; Image, Mask: HBitmap): Integer; stdcall;
  1902. function ImageList_ReplaceIcon(ImageList: HImageList; Index: Integer;
  1903. Icon: HIcon): Integer; stdcall;
  1904. function ImageList_SetBkColor(ImageList: HImageList; ClrBk: TColorRef): TColorRef; stdcall;
  1905. function ImageList_GetBkColor(ImageList: HImageList): TColorRef; stdcall;
  1906. function ImageList_SetOverlayImage(ImageList: HImageList; Image: Integer;
  1907. Overlay: Integer): Bool; stdcall;
  1908. function ImageList_AddIcon(ImageList: HImageList; Icon: HIcon): Integer;
  1909. function Index2OverlayMask(Index: Integer): Integer;
  1910. function ImageList_Draw(ImageList: HImageList; Index: Integer;
  1911. Dest: HDC; X, Y: Integer; Style: UINT): Bool; stdcall;
  1912. function ImageList_Replace(ImageList: HImageList; Index: Integer;
  1913. Image, Mask: HBitmap): Bool; stdcall;
  1914. function ImageList_AddMasked(ImageList: HImageList; Image: HBitmap;
  1915. Mask: TColorRef): Integer; stdcall;
  1916. function ImageList_DrawEx(ImageList: HImageList; Index: Integer;
  1917. Dest: HDC; X, Y, DX, DY: Integer; Bk, Fg: TColorRef; Style: Cardinal): Bool; stdcall;
  1918. function ImageList_Remove(ImageList: HImageList; Index: Integer): Bool; stdcall;
  1919. function ImageList_GetIcon(ImageList: HImageList; Index: Integer;
  1920. Flags: Cardinal): HIcon; stdcall;
  1921. function ImageList_LoadImageA(Instance: THandle; Bmp: PAnsiChar; CX, Grow: Integer;
  1922. Mask: TColorRef; pType, Flags: Cardinal): HImageList; stdcall;
  1923. function ImageList_LoadImageW(Instance: THandle; Bmp: PWideChar; CX, Grow: Integer;
  1924. Mask: TColorRef; pType, Flags: Cardinal): HImageList; stdcall;
  1925. function ImageList_LoadImage(Instance: THandle; Bmp: PChar; CX, Grow: Integer;
  1926. Mask: TColorRef; pType, Flags: Cardinal): HImageList; stdcall;
  1927. function ImageList_BeginDrag(ImageList: HImageList; Track: Integer;
  1928. XHotSpot, YHotSpot: Integer): Bool; stdcall;
  1929. function ImageList_EndDrag: Bool; stdcall;
  1930. function ImageList_DragEnter(LockWnd: HWnd; X, Y: Integer): Bool; stdcall;
  1931. function ImageList_DragLeave(LockWnd: HWnd): Bool; stdcall;
  1932. function ImageList_DragMove(X, Y: Integer): Bool; stdcall;
  1933. function ImageList_SetDragCursorImage(ImageList: HImageList; Drag: Integer;
  1934. XHotSpot, YHotSpot: Integer): Bool; stdcall;
  1935. function ImageList_DragShowNolock(Show: Bool): Bool; stdcall;
  1936. function ImageList_GetDragImage(Point, HotSpot: PPoint): HImageList; stdcall;
  1937. { macros }
  1938. procedure ImageList_RemoveAll(ImageList: HImageList); stdcall;
  1939. function ImageList_ExtractIcon(Instance: THandle; ImageList: HImageList;
  1940. Image: Integer): HIcon; stdcall;
  1941. function ImageList_LoadBitmap(Instance: THandle; Bmp: PChar;
  1942. CX, Grow: Integer; MasK: TColorRef): HImageList; stdcall;
  1943. //function ImageList_Read(Stream: IStream): HImageList; stdcall;
  1944. //function ImageList_Write(ImageList: HImageList; Stream: IStream): BOOL; stdcall;
  1945. //[TImageInfo]
  1946. type
  1947. PImageInfo = ^TImageInfo;
  1948. TImageInfo = packed record
  1949. hbmImage: HBitmap;
  1950. hbmMask: HBitmap;
  1951. Unused1: Integer;
  1952. Unused2: Integer;
  1953. rcImage: TRect;
  1954. end;
  1955. function ImageList_GetIconSize(ImageList: HImageList; var CX, CY: Integer): Bool; stdcall;
  1956. function ImageList_SetIconSize(ImageList: HImageList; CX, CY: Integer): Bool; stdcall;
  1957. function ImageList_GetImageInfo(ImageList: HImageList; Index: Integer;
  1958. var ImageInfo: TImageInfo): Bool; stdcall;
  1959. function ImageList_Merge(ImageList1: HImageList; Index1: Integer;
  1960. ImageList2: HImageList; Index2: Integer; DX, DY: Integer)://Bool - ERROR IN VCL
  1961. HImageList; stdcall;
  1962. //[LoadBmp]
  1963. function LoadBmp( Instance: Integer; Rsrc: PChar; MasterObj: PObj ): HBitmap;
  1964. //[BITMAPS]
  1965. type
  1966. tagBitmap = Windows.TBitmap;
  1967. TPixelFormat = ( pfDevice, pf1bit, pf4bit, pf8bit, pf15bit, pf16bit, pf24bit,
  1968. pf32bit, pfCustom );
  1969. {* Available pixel formats. }
  1970. TBitmapHandleType = ( bmDIB, bmDDB );
  1971. {* Available bitmap handle types. }
  1972. {++}(*TBitmap = class;*){--}
  1973. PBitmap = {-}^{+}TBitmap;
  1974. { ----------------------------------------------------------------------
  1975. TBitmap - bitmap image
  1976. ----------------------------------------------------------------------- }
  1977. //[TBitmap DEFINITION]
  1978. TBitmap = object( TObj )
  1979. {* Bitmap incapsulation object. }
  1980. protected
  1981. fHeight: Integer;
  1982. fWidth: Integer;
  1983. fHandle: HBitmap;
  1984. fCanvas: PCanvas;
  1985. fScanLineSize: Integer;
  1986. fBkColor: TColor;
  1987. fApplyBkColor2Canvas: procedure( Sender: PBitmap );
  1988. fDetachCanvas: procedure( Sender: PBitmap );
  1989. fCanvasAttached : Integer;
  1990. fHandleType: TBitmapHandleType;
  1991. fDIBHeader: PBitmapInfo;
  1992. fDIBBits: Pointer;
  1993. fDIBSize: Integer;
  1994. fNewPixelFormat: TPixelFormat;
  1995. fFillWithBkColor: procedure( BmpObj: PBitmap; DC: HDC; oldW, oldH: Integer );
  1996. //stdcall;
  1997. fTransMaskBmp: PBitmap;
  1998. fTransColor: TColor;
  1999. fGetDIBPixels: function( Bmp: PBitmap; X, Y: Integer ): TColor;
  2000. fSetDIBPixels: procedure( Bmp: PBitmap; X, Y: Integer; Value: TColor );
  2001. fScanLine0: PByte;
  2002. fScanLineDelta: Integer;
  2003. fPixelMask: DWORD;
  2004. fPixelsPerByteMask: Integer;
  2005. fBytesPerPixel: Integer;
  2006. fDIBAutoFree: Boolean;
  2007. procedure SetHeight(const Value: Integer);
  2008. procedure SetWidth(const Value: Integer);
  2009. function GetEmpty: Boolean;
  2010. function GetHandle: HBitmap;
  2011. function GetHandleAllocated: Boolean;
  2012. procedure SetHandle(const Value: HBitmap);
  2013. procedure SetPixelFormat(Value: TPixelFormat);
  2014. procedure FormatChanged;
  2015. function GetCanvas: PCanvas;
  2016. procedure CanvasChanged( Sender: PObj );
  2017. function GetScanLine(Y: Integer): Pointer;
  2018. function GetScanLineSize: Integer;
  2019. procedure ClearData;
  2020. procedure ClearTransImage;
  2021. procedure SetBkColor(const Value: TColor);
  2022. function GetDIBPalEntries(Idx: Integer): TColor;
  2023. function GetDIBPalEntryCount: Integer;
  2024. procedure SetDIBPalEntries(Idx: Integer; const Value: TColor);
  2025. procedure SetHandleType(const Value: TBitmapHandleType);
  2026. function GetPixelFormat: TPixelFormat;
  2027. function GetPixels(X, Y: Integer): TColor;
  2028. procedure SetPixels(X, Y: Integer; const Value: TColor);
  2029. function GetDIBPixels(X, Y: Integer): TColor;
  2030. procedure SetDIBPixels(X, Y: Integer; const Value: TColor);
  2031. function GetBoundsRect: TRect;
  2032. protected
  2033. {++}(*public*){--}
  2034. destructor Destroy; {-}virtual;{+}{++}(*override;*){--}
  2035. public
  2036. property Width: Integer read fWidth write SetWidth;
  2037. {* Width of bitmap. To make code smaller, avoid changing Width or Height
  2038. after bitmap is created (using NewBitmap) or after it is loaded from
  2039. file, stream of resource. }
  2040. property Height: Integer read fHeight write SetHeight;
  2041. {* Height of bitmap. To make code smaller, avoid changing Width or Height
  2042. after bitmap is created (using NewBitmap) or after it is loaded from
  2043. file, stream of resource. }
  2044. property BoundsRect: TRect read GetBoundsRect;
  2045. {* Returns rectangle (0,0,Width,Height). }
  2046. property Empty: Boolean read GetEmpty;
  2047. {* Returns True if Width or Height is 0. }
  2048. procedure Clear;
  2049. {* Makes bitmap empty, setting its Width and Height to 0. }
  2050. procedure LoadFromFile( const Filename: String );
  2051. {* Loads bitmap from file (LoadFromStream used). }
  2052. function LoadFromFileEx( const Filename: String ): Boolean;
  2053. {* Loads bitmap from a file. If necessary, bitmap is RLE-decoded. Code given
  2054. by Vyacheslav A. Gavrik. }
  2055. procedure SaveToFile( const Filename: String );
  2056. {* Stores bitmap to file (SaveToStream used). }
  2057. procedure LoadFromStream( Strm: PStream );
  2058. {* Loads bitmap from stream. Follow loading, bitmap has DIB format (without
  2059. handle allocated). It is possible to draw DIB bitmap without creating
  2060. handle for it, which can economy GDI resources. }
  2061. function LoadFromStreamEx( Strm: PStream ): Boolean;
  2062. {* Loads bitmap from a stream. Difference is that RLE decoding supported.
  2063. Code given by Vyacheslav A. Gavrik. }
  2064. procedure SaveToStream( Strm: PStream );
  2065. {* Saves bitmap to stream. If bitmap is not DIB, it is converted to DIB
  2066. before saving. }
  2067. procedure LoadFromResourceID( Inst: DWORD; ResID: Integer );
  2068. {* Loads bitmap from resource using integer ID of resource. To load by name,
  2069. use LoadFromResurceName. To load resource of application itself, pass
  2070. hInstance as first parameter. This method also can be used to load system
  2071. predefined bitmaps, if 0 is passed as Inst parameter:
  2072. |<pre>
  2073. OBM_BTNCORNERS OBM_REDUCE
  2074. OBM_BTSIZE OBM_REDUCED
  2075. OBM_CHECK OBM_RESTORE
  2076. OBM_CHECKBOXES OBM_RESTORED
  2077. OBM_CLOSE OBM_RGARROW
  2078. OBM_COMBO OBM_RGARROWD
  2079. OBM_DNARROW OBM_RGARROWI
  2080. OBM_DNARROWD OBM_SIZE
  2081. OBM_DNARROWI OBM_UPARROW
  2082. OBM_LFARROW OBM_UPARROWD
  2083. OBM_LFARROWD OBM_UPARROWI
  2084. OBM_LFARROWI OBM_ZOOM
  2085. OBM_MNARROW OBM_ZOOMD
  2086. |</pre> }
  2087. procedure LoadFromResourceName( Inst: DWORD; ResName: PChar );
  2088. {* Loads bitmap from resurce (using passed name of bitmap resource. }
  2089. function Assign( SrcBmp: PBitmap ): Boolean;
  2090. {* Assigns bitmap from another. Returns False if not success.
  2091. Note: remember, that Canvas is not assigned - only bitmap image
  2092. is copied. And for DIB, handle is not allocating due this process. }
  2093. property Handle: HBitmap read GetHandle write SetHandle;
  2094. {* Handle of bitmap. Created whenever property accessed. To check if handle
  2095. is allocated (without allocating it), use HandleAllocated property. }
  2096. property HandleAllocated: Boolean read GetHandleAllocated;
  2097. {* Returns True, if Handle already allocated. }
  2098. function ReleaseHandle: HBitmap;
  2099. {* Returns Handle and releases it, so bitmap no more know about handle.
  2100. This method does not destroy bitmap image, but converts it into DIB.
  2101. Returned Handle actually is a handle of copy of original bitmap. If
  2102. You need not in keping it up, use Dormant method instead. }
  2103. procedure Dormant;
  2104. {* Releases handle from bitmap and destroys it. But image is not destroyed
  2105. and its data are preserved in DIB format. Please note, that in KOL, DIB
  2106. bitmaps can be drawn onto given device context without allocating of
  2107. handle. So, it is very useful to call Dormant preparing it using
  2108. Canvas drawing operations - to economy GDI resources. }
  2109. property HandleType: TBitmapHandleType read fHandleType write SetHandleType;
  2110. {* bmDIB, if DIB part of image data is filled and stored internally in
  2111. TBitmap object. DIB image therefore can have Handle allocated, which
  2112. require resources. Use HandleAllocated funtion to determine if handle
  2113. is allocated and Dormant method to remove it, if You want to economy
  2114. GDI resources. (Actually Handle needed for DIB bitmap only in case
  2115. when Canvas is used to draw on bitmap surface). Please note also, that
  2116. before saving bitmap to file or stream, it is converted to DIB. }
  2117. property PixelFormat: TPixelFormat read GetPixelFormat write SetPixelFormat;
  2118. {* Current pixel format. If format of bitmap is unknown, or bitmap is DDB,
  2119. value is pfDevice. Setting PixelFormat to any other format converts
  2120. bitmap to DIB, back to pfDevice converts bitmap to DDB again. Avoid
  2121. such conversations for large bitmaps or for numerous bitmaps in your
  2122. application to keep good performance. }
  2123. function BitsPerPixel: Integer;
  2124. {* Returns bits per pixel if possible. }
  2125. procedure Draw( DC: HDC; X, Y: Integer );
  2126. {* Draws bitmap to given device context. If bitmap is DIB, it is always
  2127. drawing using SetDIBitsToDevice API call, which does not require bitmap
  2128. handle (so, it is very sensible to call Dormant method to free correspondent
  2129. GDI resources). }
  2130. procedure StretchDraw( DC: HDC; const Rect: TRect );
  2131. {* Draws bitmap onto DC, stretching it to fit given rectangle Rect. }
  2132. procedure DrawTransparent( DC: HDC; X, Y: Integer; TranspColor: TColor );
  2133. {* Draws bitmap onto DC transparently, using TranspColor as transparent. }
  2134. procedure StretchDrawTransparent( DC: HDC; const Rect: TRect; TranspColor: TColor );
  2135. {* Draws bitmap onto given rectangle of destination DC (with stretching it
  2136. to fit Rect) - transparently, using TranspColor as transparent. }
  2137. procedure DrawMasked( DC: HDC; X, Y: Integer; Mask: HBitmap );
  2138. {* Draws bitmap to destination DC transparently by mask. It is possible
  2139. to pass as a mask handle of another TBitmap, previously converted to
  2140. monochrome mask using Convert2Mask method. }
  2141. procedure StretchDrawMasked( DC: HDC; const Rect: TRect; Mask: HBitmap );
  2142. {* Like DrawMasked, but with stretching image onto given rectangle. }
  2143. procedure Convert2Mask( TranspColor: TColor );
  2144. {* Converts bitmap to monochrome (mask) bitmap with TranspColor replaced
  2145. to clBlack and all other ones to clWhite. Such mask bitmap can be used
  2146. to draw original bitmap transparently, with given TranspColor as
  2147. transparent. (To preserve original bitmap, create new instance of
  2148. TBitmap and assign original bitmap to it). See also DrawTransparent and
  2149. StretchDrawTransparent methods. }
  2150. procedure Invert;
  2151. {* Obvious. }
  2152. property Canvas: PCanvas read GetCanvas;
  2153. {* Canvas can be used to draw onto bitmap. Whenever it is accessed, handle
  2154. is allocated for bitmap, if it is not yet (to make it possible
  2155. to select bitmap to display compatible device context). }
  2156. procedure RemoveCanvas;
  2157. {* Call this method to destroy Canvas and free GDI resources. }
  2158. property BkColor: TColor read fBkColor write SetBkColor;
  2159. {* Used to fill background for Bitmap, when its width or height is increased.
  2160. Although this value always synchronized with Canvas.Brush.Color, use it
  2161. instead if You do not use Canvas for drawing on bitmap surface. }
  2162. property Pixels[ X, Y: Integer ]: TColor read GetPixels write SetPixels;
  2163. {* Allows to obtain or change certain pixels of a bitmap. This method is
  2164. both for DIB and DDB bitmaps, and leads to allocate handle anyway. For
  2165. DIB bitmaps, it is possible to use property DIBPixels[ ] instead,
  2166. which is much faster and does not require in Handle. }
  2167. property ScanLineSize: Integer read GetScanLineSize;
  2168. {* Returns size of scan line in bytes. Use it to measure size of a single
  2169. ScanLine. To calculate increment value from first byte of ScanLine to
  2170. first byte of next ScanLine, use difference
  2171. ! Integer(ScanLine[1]-ScanLine[0])
  2172. (this is because bitmap can be oriented from bottom to top, so
  2173. step can be negative). }
  2174. property ScanLine[ Y: Integer ]: Pointer read GetScanLine;
  2175. {* Use ScanLine to access DIB bitmap pixels in memory to direct access it
  2176. fast. Take in attention, that for different pixel formats, different
  2177. bit counts are used to represent bitmap pixels. Also do not forget, that
  2178. for formats pf4bit and pf8bit, pixels actually are indices to palette
  2179. entries, and for formats pf16bit, pf24bit and pf32bit are actually
  2180. RGB values (for pf16bit B:5-G:6-R:5, for pf15bit B:5-G:5-R:5 (high order
  2181. bit not used), for pf24bit B:8-G:8-R:8, and for pf32bit high order byte
  2182. of TRGBQuad structure is not used). }
  2183. property DIBPixels[ X, Y: Integer ]: TColor read GetDIBPixels write SetDIBPixels;
  2184. {* Allows direct access to pixels of DIB bitmap, faster then Pixels[ ]
  2185. property. Access to read is slower for pf15bit, pf16bit formats (because
  2186. some conversation needed to translate packed RGB color to TColor). And
  2187. for write, operation performed most slower for pf4bit, pf8bit (searching
  2188. nearest color required) and fastest for pf24bit, pf32bit and pf1bit. }
  2189. property DIBPalEntryCount: Integer read GetDIBPalEntryCount;
  2190. {* Returns palette entries count for DIB image. Always returns 2 for pf1bit,
  2191. 16 for pf4bit, 256 for pf8bit and 0 for other pixel formats. }
  2192. property DIBPalEntries[ Idx: Integer ]: TColor read GetDIBPalEntries write
  2193. SetDIBPalEntries;
  2194. {* Provides direct access to DIB palette. }
  2195. function DIBPalNearestEntry( Color: TColor ): Integer;
  2196. {* Returns index of entry in DIB palette with color nearest (or matching)
  2197. to given one. }
  2198. property DIBBits: Pointer read fDIBBits;
  2199. {* This property is mainly for internal use. }
  2200. property DIBSize: Integer read fDIBSize;
  2201. {* Size of DIBBits array. }
  2202. property DIBHeader: PBitmapInfo read fDIBHeader;
  2203. {* This property is mainly for internal use. }
  2204. procedure DIBDrawRect( DC: HDC; X, Y: Integer; const R: TRect );
  2205. {* This procedure copies given rectangle to the target device context,
  2206. but only for DIB bitmap (using SetDIBBitsToDevice API call). }
  2207. procedure RotateRight;
  2208. {* Rotates bitmap right (90 degree). Bitmap must be DIB. If You definitevely
  2209. know format of a bitmap, use instead one of methods RotateRightMono,
  2210. RotateRight4bit, RotateRight8bit, RotateRight16bit or RotateRightTrueColor
  2211. - this will economy code. But if for most of formats such methods are
  2212. called, this can be more economy just to call always universal method
  2213. RotateRight. }
  2214. procedure RotateLeft;
  2215. {* Rotates bitmap left (90 degree). Bitmap must be DIB. If You definitevely
  2216. know format of a bitmap, use instead one of methods RotateLeftMono,
  2217. RotateLeft4bit, RotateLeft8bit, RotateLeft16bit or RotateLeftTrueColor
  2218. - this will economy code. But if for most of formats such methods are
  2219. called, this can be more economy just to call always universal method
  2220. RotateLeft. }
  2221. procedure RotateRightMono;
  2222. {* Rotates bitmat right, but only if bitmap is monochrome (pf1bit). }
  2223. procedure RotateLeftMono;
  2224. {* Rotates bitmap left, but only if bitmap is monochrome (pf1bit). }
  2225. procedure RotateRight4bit;
  2226. {* Rotates bitmap right, but only if PixelFormat is pf4bit. }
  2227. procedure RotateLeft4bit;
  2228. {* Rotates bitmap left, but only if PixelFormat is pf4bit. }
  2229. procedure RotateRight8bit;
  2230. {* Rotates bitmap right, but only if PixelFormat is pf8bit. }
  2231. procedure RotateLeft8bit;
  2232. {* Rotates bitmap left, but only if PixelFormat is pf8bit. }
  2233. procedure RotateRight16bit;
  2234. {* Rotates bitmap right, but only if PixelFormat is pf16bit. }
  2235. procedure RotateLeft16bit;
  2236. {* Rotates bitmap left, but only if PixelFormat is pf16bit. }
  2237. procedure RotateRightTrueColor;
  2238. {* Rotates bitmap right, but only if PixelFormat is pf24bit or pf32bit. }
  2239. procedure RotateLeftTrueColor;
  2240. {* Rotates bitmap left, but only if PixelFormat is pf24bit or pf32bit. }
  2241. procedure FlipVertical;
  2242. {* Flips bitmap vertically }
  2243. procedure FlipHorizontal;
  2244. {* Flips bitmap horizontally }
  2245. procedure CopyRect( const DstRect : TRect; SrcBmp : PBitmap; const SrcRect : TRect );
  2246. {* It is possible to use Canvas.CopyRect for such purpose, but if You
  2247. do not want use TCanvas, it is possible to copy rectangle from one
  2248. bitmap to another using this function. }
  2249. function CopyToClipboard: Boolean;
  2250. {* Copies bitmap to clipboard. }
  2251. function PasteFromClipboard: Boolean;
  2252. {* Takes CF_DIB format bitmap from clipboard and assigns it to the
  2253. TBitmap object. }
  2254. end;
  2255. //[END OF TBitmap DEFINITION]
  2256. //[NewBitmap DECLARATION]
  2257. function NewBitmap( W, H: Integer ): PBitmap;
  2258. {* Creates bitmap object of given size. If it is possible, do not change its
  2259. size (Width and Heigth) later - this can economy code a bit. See TBitmap. }
  2260. function NewDIBBitmap( W, H: Integer; PixelFormat: TPixelFormat ): PBitmap;
  2261. {* Creates DIB bitmap object of given size and pixel format. If it is possible,
  2262. do not change its size (Width and Heigth) later - this can economy code a bit.
  2263. See TBitmap. }
  2264. //[CalcScanLineSize DECLARATION]
  2265. function CalcScanLineSize( Header: PBitmapInfoHeader ): Integer;
  2266. {* May be will be useful. }
  2267. //[DefaultPixelFormat VARIABLE]
  2268. var
  2269. //DefaultBitsPerPixel: Integer = 16;
  2270. DefaultPixelFormat: TPixelFormat = pf16bit;
  2271. //[Mapped bitmaps]
  2272. { -- Function to load bitmap mapping some its colors. -- }
  2273. function LoadMappedBitmap( hInst: THandle; BmpResID: Integer; const Map: array of TColor )
  2274. : HBitmap;
  2275. {* This function can be used to load bitmap and replace some it colors to
  2276. desired ones. This function especially useful when loaded by the such way
  2277. bitmap is used as toolbar bitmap - to replace some original colors to
  2278. system default colors. To use this function properly, the bitmap shoud
  2279. be prepared as 16-color bitmap, which uses only system colors. To do so,
  2280. create a new 16-color bitmap with needed dimensions in Borland Image Editor
  2281. and paste a bitmap image, copyed in another graphic tool, and then save it.
  2282. If this is not done, bitmap will not be loaded correctly! }
  2283. function LoadMappedBitmapEx( MasterObj: PObj; hInst: THandle; BmpResName: PChar; const Map: array of TColor )
  2284. : HBitmap;
  2285. {* Like LoadMappedBitmap, but much powerful. It uses CreateMappedBitmapEx
  2286. by Alex Pravdin, so it understands any bitmap color format, including
  2287. pf24bit. Also, LoadMappedBitmapEx provides auto-destroying loaded resource
  2288. when MasterObj is destroyed. }
  2289. function CreateMappedBitmap(Instance: THandle; Bitmap: Integer;
  2290. Flags: UINT; ColorMap: PColorMap; NumMaps: Integer): HBitmap; stdcall;
  2291. {* Creates mapped bitmap replacing colors correspondently to the
  2292. ColorMap (each pare of colors defines color replaced and a color
  2293. used for replace it in the bitmap). See also CreateMappedBitmapEx. }
  2294. function CreateMappedBitmapEx(Instance: THandle; BmpRsrcName: PChar; Flags:
  2295. Cardinal; ColorMap: PColorMap; NumMaps: Integer): HBitmap;
  2296. {* By Alex Pravdin.
  2297. Creates mapped bitmap independently from bitmap color format (works
  2298. correctly with bitmaps having format deeper than 8bit per pixel). }
  2299. //[ICONS]
  2300. type
  2301. {++}(*TIcon = class;*){--}
  2302. PIcon = {-}^{+}TIcon;
  2303. { ----------------------------------------------------------------------
  2304. TIcon - icon image
  2305. ----------------------------------------------------------------------- }
  2306. //[TIcon DEFINITION]
  2307. TIcon = object( TObj )
  2308. {* Object type to incapsulate icon or cursor image. }
  2309. protected
  2310. FSize : Integer;
  2311. FHandle: HIcon;
  2312. FShareIcon: Boolean;
  2313. procedure SetSize(const Value: Integer);
  2314. procedure SetHandle(const Value: HIcon);
  2315. function GetHotSpot: TPoint;
  2316. function GetEmpty: Boolean;
  2317. protected
  2318. {++}(*public*){--}
  2319. destructor Destroy; {-}virtual;{+}{++}(*override;*){--}
  2320. public
  2321. property Size : Integer read FSize write SetSize;
  2322. {* Icon dimension (width and/or height, which are equal to each other always). }
  2323. property Handle : HIcon read FHandle write SetHandle;
  2324. {* Windows icon object handle. }
  2325. procedure Clear;
  2326. {* Clears icon, freeing image and allocated GDI resource (Handle). }
  2327. property Empty: Boolean read GetEmpty;
  2328. {* Returns True if icon is Empty. }
  2329. property ShareIcon : Boolean read FShareIcon write FShareIcon;
  2330. {* True, if icon object is shared and can not be deleted when TIcon object
  2331. is destroyed (set this flag is to True, if an icon is obtained from another
  2332. TIcon object, for example). }
  2333. property HotSpot : TPoint read GetHotSpot;
  2334. {* Hot spot point - for cursors. }
  2335. procedure Draw( DC : HDC; X, Y : Integer );
  2336. {* Draws icon onto given device context. Icon always is drawn transparently
  2337. using its transparency mask (stored internally in icon object). }
  2338. procedure StretchDraw( DC : HDC; Dest : TRect );
  2339. {* Draws icon onto given device context with stretching it to fit destination
  2340. rectangle. See also Draw. }
  2341. procedure LoadFromStream( Strm : PStream );
  2342. {* Loads icon from stream. If stream contains several icons (of
  2343. different dimentions), icon with the most appropriate size is loading. }
  2344. procedure LoadFromFile( const FileName : String );
  2345. {* Load icon from file. If file contains several icons (of
  2346. different dimensions), icon with the most appropriate size is loading. }
  2347. procedure LoadFromResourceID( Inst: Integer; ResID: Integer; DesiredSize: Integer );
  2348. {* Loads icon from resource. To load system default icon, pass 0 as Inst and
  2349. one of followin values as ResID:
  2350. |<pre>
  2351. IDI_APPLICATION Default application icon.
  2352. IDI_ASTERISK Asterisk (used in informative messages).
  2353. IDI_EXCLAMATION Exclamation point (used in warning messages).
  2354. IDI_HAND Hand-shaped icon (used in serious warning messages).
  2355. IDI_QUESTION Question mark (used in prompting messages).
  2356. IDI_WINLOGO Windows logo.
  2357. |</pre> It is also possible to load icon from resources of another module,
  2358. if pass instance handle of loaded module as Inst parameter. }
  2359. procedure LoadFromResourceName( Inst: Integer; ResName: PChar; DesiredSize: Integer );
  2360. {* Loads icon from resource. To load own application resource, pass
  2361. hInstance as Inst parameter. It is possible to load resource from
  2362. another module, if pass its instance handle as Inst. }
  2363. procedure LoadFromExecutable( const FileName: String; IconIdx: Integer );
  2364. {* Loads icon from executable (exe or dll file). Always default sized icon
  2365. is loaded. It is possible also to get know how much icons are contained
  2366. in executable using gloabl function GetFileIconCount. To obtain icon of
  2367. another size, try to load given executable and use LoadFromResourceID
  2368. method. }
  2369. procedure SaveToStream( Strm : PStream );
  2370. {* Saves single icon to stream. To save icons with several different
  2371. dimensions, use global procedure SaveIcons2Stream. }
  2372. procedure SaveToFile( const FileName : String );
  2373. {* Saves single icon to file. To save icons with several different
  2374. dimensions, use global procedure SaveIcons2File. }
  2375. function Convert2Bitmap( TranColor: TColor ): HBitmap;
  2376. {* Converts icon to bitmap, returning Windows GDI bitmap resource as
  2377. a result. It is possible later to assign returned bitmap handle to
  2378. Handle property of TBitmap object to use features of TBitmap.
  2379. Pass TranColor to replace transparent area of icon with given color. }
  2380. end;
  2381. //[END OF TIcon DEFINITION]
  2382. //[Icon save functions]
  2383. procedure SaveIcons2Stream( const Icons : array of PIcon; Strm : PStream );
  2384. {* Saves several icons (of different dimentions) to stream. }
  2385. function SaveIcons2StreamEx( const BmpHandles: array of HBitmap; Strm: PStream ): Boolean;
  2386. {* Saves icons creating it from pairs of bitmaps and their masks.
  2387. BmpHandles array must contain pairs of bitmap handles, each pair
  2388. of color bitmap and mask bitmap of the same size. }
  2389. procedure SaveIcons2File( const Icons : array of PIcon; const FileName : String );
  2390. {* Saves several icons (of different dimentions) to file. (Single file
  2391. with extension .ico can contain several different sized icon images
  2392. to use later one with the most appropriate size). }
  2393. //[NewIcon DECLARATION]
  2394. function NewIcon: PIcon;
  2395. {* Creates new icon object, setting its Size to 32 by default. Created icon
  2396. is Empty. }
  2397. //[GetFileIconCount DECLARATION]
  2398. function GetFileIconCount( const FileName: String ): Integer;
  2399. {* Returns number of icon resources stored in given (executable) file. }
  2400. //[ICON STRUCTURES]
  2401. type
  2402. TIconHeader = packed record
  2403. idReserved: Word; (* Always set to 0 *)
  2404. idType: Word; (* Always set to 1 *)
  2405. idCount: Word; (* Number of icon images *)
  2406. (* immediately followed by idCount TIconDirEntries *)
  2407. end;
  2408. TIconDirEntry = packed record
  2409. bWidth: Byte; (* Width *)
  2410. bHeight: Byte; (* Height *)
  2411. bColorCount: Byte; (* Nr. of colors used, see below *)
  2412. bReserved: Byte; (* not used, 0 *)
  2413. wPlanes: Word; (* not used, 0 *)
  2414. wBitCount: Word; (* not used, 0 *)
  2415. dwBytesInRes: Longint; (* total number of bytes in images *)
  2416. dwImageOffset: Longint;(* location of image from the beginning of file *)
  2417. end;
  2418. //[LoadImgIcon DECLARATION]
  2419. function LoadImgIcon( RsrcName: PChar; Size: Integer ): HIcon;
  2420. {* Loads icon of specified size from the resource. }
  2421. ////////////////////////////////////////////////////////////////////////////////
  2422. // UNIVERSAL CONTROL OBJECT //
  2423. ////////////////////////////////////////////////////////////////////////////////
  2424. //[CM_XXX CONSTANTS]
  2425. const
  2426. CM_EXECPROC = $8FFF;
  2427. CM_BASE = $B000;
  2428. CM_ACTIVATE = CM_BASE + 0;
  2429. CM_DEACTIVATE = CM_BASE + 1;
  2430. CM_ENTER = CM_BASE + 2;
  2431. CM_RELEASE = CM_BASE + 3;
  2432. CM_QUIT = CM_BASE + 4;
  2433. CM_COMMAND = CM_BASE + 5;
  2434. CM_MEASUREITEM = CM_BASE + 6;
  2435. CM_DRAWITEM = CM_BASE + 7;
  2436. CM_TRAYICON = CM_BASE + 8;
  2437. CM_INVALIDATE = CM_BASE + 9;
  2438. CM_UPDATE = CM_BASE + 10;
  2439. CM_NCUPDATE = CM_BASE + 11;
  2440. CM_SIZEPOS = CM_BASE + 12;
  2441. CM_SIZE = CM_BASE + 13;
  2442. CM_SETFOCUS = CM_BASE + 14;
  2443. CM_CBN_SELCHANGE = 15;
  2444. CM_UIACTIVATE = CM_BASE + 16;
  2445. CM_UIDEACTIVATE = CM_BASE + 17;
  2446. CM_PROCESS = CM_BASE + 18;
  2447. CM_SHOW = CM_BASE + 19;
  2448. //CM_CLOSE = CM_BASE + 20;
  2449. CM_MDIClientShowEdge = CM_BASE + 21;
  2450. CM_INVALIDATECHILD = CM_BASE + 22;
  2451. CM_FOCUSGRAPHCTL = CM_BASE + 23;
  2452. //[CN_XXX CONSTANTS]
  2453. CN_BASE = $BC00;
  2454. CN_CHARTOITEM = CN_BASE + WM_CHARTOITEM;
  2455. CN_COMMAND = CN_BASE + WM_COMMAND;
  2456. CN_COMPAREITEM = CN_BASE + WM_COMPAREITEM;
  2457. CN_CTLCOLORMSGBOX = CN_BASE + WM_CTLCOLORMSGBOX;
  2458. CN_CTLCOLOREDIT = CN_BASE + WM_CTLCOLOREDIT;
  2459. CN_CTLCOLORLISTBOX = CN_BASE + WM_CTLCOLORLISTBOX;
  2460. CN_CTLCOLORBTN = CN_BASE + WM_CTLCOLORBTN;
  2461. CN_CTLCOLORDLG = CN_BASE + WM_CTLCOLORDLG;
  2462. CN_CTLCOLORSCROLLBAR = CN_BASE + WM_CTLCOLORSCROLLBAR;
  2463. CN_CTLCOLORSTATIC = CN_BASE + WM_CTLCOLORSTATIC;
  2464. CN_DELETEITEM = CN_BASE + WM_DELETEITEM;
  2465. CN_DRAWITEM = CN_BASE + WM_DRAWITEM;
  2466. CN_HSCROLL = CN_BASE + WM_HSCROLL;
  2467. CN_MEASUREITEM = CN_BASE + WM_MEASUREITEM;
  2468. CN_PARENTNOTIFY = CN_BASE + WM_PARENTNOTIFY;
  2469. CN_VKEYTOITEM = CN_BASE + WM_VKEYTOITEM;
  2470. CN_VSCROLL = CN_BASE + WM_VSCROLL;
  2471. CN_KEYDOWN = CN_BASE + WM_KEYDOWN;
  2472. CN_KEYUP = CN_BASE + WM_KEYUP;
  2473. CN_CHAR = CN_BASE + WM_CHAR;
  2474. CN_SYSKEYDOWN = CN_BASE + WM_SYSKEYDOWN;
  2475. CN_SYSCHAR = CN_BASE + WM_SYSCHAR;
  2476. CN_NOTIFY = CN_BASE + WM_NOTIFY;
  2477. //[ID_SELF DEFINED]
  2478. ID_SELF: array[ 0..5 ] of Char = ( 'S','E','L','F','_',#0 );
  2479. {* Identifier for window property "Self", stored directly in window, when
  2480. it is created. This property is used to [fast] find TControl object,
  2481. correspondent to given window handle (using API call GetProp). }
  2482. //[ID_PREVPROC DEFINED]
  2483. ID_PREVPROC: array[ 0..9 ] of Char = ( 'P','R','E','V','_','P','R','O','C',#0 );
  2484. {* }
  2485. //[MK_ALT DEFINED]
  2486. MK_ALT = $20;
  2487. //[RICHEDIT STRUCTURES]
  2488. type
  2489. TCharFormat2A = packed record
  2490. cbSize: UINT;
  2491. dwMask: DWORD;
  2492. dwEffects: DWORD;
  2493. yHeight: Longint;
  2494. yOffset: Longint;
  2495. crTextColor: TColorRef;
  2496. bCharSet: Byte;
  2497. bPitchAndFamily: Byte;
  2498. szFaceName: array[0..LF_FACESIZE - 1] of AnsiChar;
  2499. R2Bytes: Word;
  2500. wWeight: Word; { Font weight (LOGFONT value) }
  2501. sSpacing: Smallint; { Amount to space between letters }
  2502. crBackColor: TColorRef; { Background color }
  2503. lid: LCID; { Locale ID }
  2504. dwReserved: DWORD; { Reserved. Must be 0 }
  2505. sStyle: Smallint; { Style handle }
  2506. wKerning: Word; { Twip size above which to kern char pair }
  2507. bUnderlineType: Byte; { Underline type }
  2508. bAnimation: Byte; { Animated text like marching ants }
  2509. bRevAuthor: Byte; { Revision author index }
  2510. bReserved1: Byte;
  2511. end;
  2512. TCharFormat2 = TCharFormat2A;
  2513. TParaFormat2 = packed record
  2514. cbSize: UINT;
  2515. dwMask: DWORD;
  2516. wNumbering: Word;
  2517. wReserved: Word;
  2518. dxStartIndent: Longint;
  2519. dxRightIndent: Longint;
  2520. dxOffset: Longint;
  2521. wAlignment: Word;
  2522. cTabCount: Smallint;
  2523. rgxTabs: array [0..MAX_TAB_STOPS - 1] of Longint;
  2524. dySpaceBefore: Longint; { Vertical spacing before para }
  2525. dySpaceAfter: Longint; { Vertical spacing after para }
  2526. dyLineSpacing: Longint; { Line spacing depending on Rule }
  2527. sStyle: Smallint; { Style handle }
  2528. bLineSpacingRule: Byte; { Rule for line spacing (see tom.doc) }
  2529. bCRC: Byte; { Reserved for CRC for rapid searching }
  2530. wShadingWeight: Word; { Shading in hundredths of a per cent }
  2531. wShadingStyle: Word; { Nibble 0: style, 1: cfpat, 2: cbpat }
  2532. wNumberingStart: Word; { Starting value for numbering }
  2533. wNumberingStyle: Word; { Alignment, roman/arabic, (), ), ., etc. }
  2534. wNumberingTab: Word; { Space bet 1st indent and 1st-line text }
  2535. wBorderSpace: Word; { Space between border and text (twips) }
  2536. wBorderWidth: Word; { Border pen width (twips) }
  2537. wBorders: Word; { Byte 0: bits specify which borders }
  2538. { Nibble 2: border style, 3: color index }
  2539. end;
  2540. TGetTextLengthEx = packed record
  2541. flags: DWORD; { flags (see GTL_XXX defines) }
  2542. codepage: UINT; { code page for translation (CP_ACP for default,
  2543. 1200 for Unicode }
  2544. end;
  2545. const
  2546. PFM_SPACEBEFORE = $00000040;
  2547. PFM_SPACEAFTER = $00000080;
  2548. PFM_LINESPACING = $00000100;
  2549. PFM_STYLE = $00000400;
  2550. PFM_BORDER = $00000800; { (*) }
  2551. PFM_SHADING = $00001000; { (*) }
  2552. PFM_NUMBERINGSTYLE = $00002000; { (*) }
  2553. PFM_NUMBERINGTAB = $00004000; { (*) }
  2554. PFM_NUMBERINGSTART = $00008000; { (*) }
  2555. PFM_RTLPARA = $00010000;
  2556. PFM_KEEP = $00020000; { (*) }
  2557. PFM_KEEPNEXT = $00040000; { (*) }
  2558. PFM_PAGEBREAKBEFORE = $00080000; { (*) }
  2559. PFM_NOLINENUMBER = $00100000; { (*) }
  2560. PFM_NOWIDOWCONTROL = $00200000; { (*) }
  2561. PFM_DONOTHYPHEN = $00400000; { (*) }
  2562. PFM_SIDEBYSIDE = $00800000; { (*) }
  2563. PFM_TABLE = $c0000000; { (*) }
  2564. EM_REDO = WM_USER + 84;
  2565. EM_AUTOURLDETECT = WM_USER + 91;
  2566. EM_GETAUTOURLDETECT = WM_USER + 92;
  2567. CFM_UNDERLINETYPE = $00800000; { (*) }
  2568. CFM_HIDDEN = $0100; { (*) }
  2569. CFM_BACKCOLOR = $04000000;
  2570. CFE_AUTOBACKCOLOR = CFM_BACKCOLOR;
  2571. GTL_USECRLF = 1; { compute answer using CRLFs for paragraphs }
  2572. GTL_PRECISE = 2; { compute a precise answer }
  2573. GTL_CLOSE = 4; { fast computation of a "close" answer }
  2574. GTL_NUMCHARS = 8; { return the number of characters }
  2575. GTL_NUMBYTES = 16; { return the number of _bytes_ }
  2576. EM_GETTEXTLENGTHEX = WM_USER + 95;
  2577. EM_SETLANGOPTIONS = WM_USER + 120;
  2578. EM_GETLANGOPTIONS = WM_USER + 121;
  2579. EM_SETEDITSTYLE = $400 + 204;
  2580. EM_GETEDITSTYLE = $400 + 205;
  2581. SES_EMULATESYSEDIT = 1;
  2582. SES_BEEPONMAXTEXT = 2;
  2583. SES_EXTENDBACKCOLOR = 4;
  2584. SES_MAPCPS = 8;
  2585. SES_EMULATE10 = 16;
  2586. SES_USECRLF = 32;
  2587. SES_USEAIMM = 64;
  2588. SES_NOIME = 128;
  2589. SES_ALLOWBEEPS = 256;
  2590. SES_UPPERCASE = 512;
  2591. SES_LOWERCASE = 1024;
  2592. SES_NOINPUTSEQUENCECHK = 2048;
  2593. SES_BIDI = 4096;
  2594. SES_SCROLLONKILLFOCUS = 8192;
  2595. SES_XLTCRCRLFTOCR = 16384;
  2596. //[CONTROLS]
  2597. type
  2598. {++}(*TControl = class;*){--}
  2599. PControl = {-}^{+}TControl;
  2600. {* Type of pointer to TControl visual object. All
  2601. |<a href="kol_pas.htm#visual_objects_constructors">
  2602. constructing functions
  2603. |</a>
  2604. New[ControlName] are returning
  2605. pointer of this type. Do not forget about some difference
  2606. of using objects from using classes. Identifier Self for
  2607. methods of object is not of pointer type, and to pass
  2608. pointer to Self, it is necessary to pass @Self instead.
  2609. At the same time, to use pointer to object in 'WITH' operator,
  2610. it is necessary to apply suffix '^' to pointer to get know
  2611. to compiler, what do You want. }
  2612. //[TWindowFunc TYPE]
  2613. TWindowFunc = function( Sender: PControl; var Msg: TMsg; var Rslt: Integer )
  2614. : Boolean;
  2615. {* Event type to define custom extended message handlers (as pointers to
  2616. procedure entry points). Such handlers are usually defined like add-ons,
  2617. extending behaviour of certain controls and attached using AttachProc
  2618. method of TControl. If the handler detects, that it is necessary to stop
  2619. further message processing, it should return True. }
  2620. //[Mouse TYPES]
  2621. TMouseButton = ( mbNone, mbLeft, mbRight, mbMiddle );
  2622. {* Available mouse buttons. mbNone is useful to get know, that
  2623. there were no mouse buttons pressed. }
  2624. TMouseEventData = packed Record
  2625. {* Record to pass it to mouse handling routines, assigned to OnMouseXXXX
  2626. events. }
  2627. Button: TMouseButton;
  2628. StopHandling: Boolean; // Set it to True in OnMouseXXXX event handler to
  2629. // stop further processing
  2630. R1, R2: Byte; // Not used
  2631. Shift : DWORD; // HiWord( Shift ) = zDelta in WM_MOUSEWHEEL
  2632. X, Y : SmallInt;
  2633. end;
  2634. TOnMouse = procedure( Sender: PControl; var Mouse: TMouseEventData ) of object;
  2635. {* Common mouse handling event type. }
  2636. //[Key TYPES]
  2637. TOnKey = procedure( Sender: PControl; var Key: Longint; Shift: DWORD ) of object;
  2638. {* Key events. Shift is a combination of flags MK_SHIFT, MK_CONTROL, MK_ALT.
  2639. (See GetShiftState funtion). }
  2640. TOnChar = procedure( Sender: PControl; var Key: Char; Shift: DWORD ) of object;
  2641. {* Char event. Shift is a combination of flags MK_SHIFT, MK_CONTROL, MK_ALT. }
  2642. TTabKey = ( tkTab, tkLeftRight, tkUpDown, tkPageUpPageDn );
  2643. {* Available tabulating key groups. }
  2644. TTabKeys = Set of TTabKey;
  2645. {* Set of tabulating key groups, allowed to be used in with a control
  2646. (are installed by TControl.LookTabKey property). }
  2647. //[Event TYPES]
  2648. TOnMessage = function( var Msg: TMsg; var Rslt: Integer ): Boolean of object;
  2649. {* Event type for events, which allows to extend behaviour of windowed controls
  2650. descendants using add-ons. }
  2651. TOnEventAccept = procedure( Sender: PObj; var Accept: Boolean ) of object;
  2652. {* Event type for OnClose event. }
  2653. TCloseQueryReason = ( qClose, qShutdown, qLogoff );
  2654. {* Request reason type to call OnClose and OnQueryEndSession. }
  2655. TWindowState = ( wsNormal, wsMinimized, wsMaximized );
  2656. {* Avalable states of TControl's window object. }
  2657. TOnSplit = function( Sender: PControl; NewSize1, NewSize2: Integer ): Boolean of object;
  2658. {* Event type for OnSplit event handler, designed specially for splitter
  2659. control. Event handler must return True to accept new size of previous
  2660. (to splitter) control and new size of the rest of client area of parent. }
  2661. TOnTVBeginDrag = procedure( Sender: PControl; Item: THandle ) of object;
  2662. {* Event type for OnTVBeginDrag event (defined for tree view control). }
  2663. TOnTVBeginEdit = function( Sender: PControl; Item: THandle ): Boolean of object;
  2664. {* Event type for OnTVBeginEdit event (for tree view control). }
  2665. TOnTVEndEdit = function( Sender: PControl; Item: THandle; const NewTxt: String )
  2666. : Boolean of object;
  2667. {* Event type for TOnTVEndEdit event. }
  2668. TOnTVExpanding = function( Sender: PControl; Item: THandle; Expand: Boolean )
  2669. : Boolean of object;
  2670. {* Event type for TOnTVExpanding event. }
  2671. TOnTVExpanded = procedure( Sender: PControl; Item: THandle; Expand: Boolean )
  2672. of object;
  2673. {* Event type for OnTVExpanded event. }
  2674. TOnTVDelete = procedure( Sender: PControl; Item: THandle ) of object;
  2675. {* Event type for OnTVDelete event. }
  2676. //--------- by Sergey Shisminzev:
  2677. TOnTVSelChanging = function(Sender: PControl; oldItem, newItem: THandle): Boolean //~ss
  2678. of object;
  2679. {* When the handler returns False, selection is not changed. }
  2680. //-------------------------------
  2681. TOnDrag = function( Sender: PControl; ScrX, ScrY: Integer; var CursorShape: Integer;
  2682. var Stop: Boolean ): Boolean of object;
  2683. {* Event, called during dragging operation (it is initiated
  2684. with method Drag, where callback function of type TOnDrag is
  2685. passed as a parameter). Callback function receives Stop parameter True,
  2686. when operation is finishing. Otherwise, it can set it to True to force
  2687. finishing the operation (in such case, returning False means cancelling
  2688. drag operation, True - successful drag and in this last case callback is
  2689. no more called). During the operation, when input Stop value is False,
  2690. callback function can control Cursor shape, and return True, if the operation
  2691. can be finished successfully at the given ScrX, ScrY position.
  2692. ScrX, ScrY are screen coordinates of the mouse cursor. }
  2693. //[Create Window STRUCTURES]
  2694. TCreateParams = packed record
  2695. {* Record to pass it through CreateSubClass method. }
  2696. Caption: PChar;
  2697. Style: cardinal;
  2698. ExStyle: cardinal;
  2699. X, Y: Integer;
  2700. Width, Height: Integer;
  2701. WndParent: HWnd;
  2702. Param: Pointer;
  2703. WindowClass: TWndClass;
  2704. WinClassName: array[0..63] of Char;
  2705. end;
  2706. TCreateWndParams = packed Record
  2707. ExStyle: DWORD;
  2708. WinClassName: PChar;
  2709. Caption: PChar;
  2710. Style: DWORD;
  2711. X, Y, Width, Height: Integer;
  2712. WndParent: HWnd;
  2713. Menu: HMenu;
  2714. Inst: THandle;
  2715. Param: Pointer;
  2716. WinClsNamBuf: array[ 0..63 ] of Char;
  2717. WindowClass: TWndClass;
  2718. end;
  2719. //[COMMAND ACTIONS TYPE FOR DIFFERENT CONTROLS]
  2720. PCommandActions = ^TCommandActions;
  2721. TCommandActions = packed Record
  2722. aClear: procedure( Sender: PControl );
  2723. aAddText: procedure( Sender: PControl; const S: String );
  2724. aClick, aEnter, aLeave: WORD; aChange: SmallInt; aSelChange: SmallInt;
  2725. aGetCount, aSetCount, aGetItemLength, aGetItemText, aSetItemText,
  2726. aGetItemData, aSetItemData: WORD;
  2727. aAddItem, aDeleteItem, aInsertItem: WORD;
  2728. aFindItem, aFindPartial: WORD;
  2729. aItem2Pos, aPos2Item: BYTE;
  2730. aGetSelCount, aGetSelected, aGetSelRange, aExGetSelRange, aGetCurrent,
  2731. aSetSelected, aSetCurrent, aSetSelRange, aExSetSelRange,
  2732. aGetSelection, aReplaceSel: WORD;
  2733. aTextAlignLeft, aTextAlignRight, aTextAlignCenter: WORD;
  2734. aTextAlignMask: Byte;
  2735. aVertAlignCenter, aVertAlignTop, aVertAlignBottom: Byte;
  2736. aDir, aSetLimit: Word; aSetImgList: Word;
  2737. aAutoSzX, aAutoSzY: Word;
  2738. aSetBkColor: Word;
  2739. aItem2XY: Word;
  2740. end;
  2741. //[Align TYPES]
  2742. TTextAlign = ( taLeft, taRight, taCenter );
  2743. {* Text alignments available. }
  2744. TRichTextAlign = ( raLeft, raRight, raCenter,
  2745. // all other are only set but can not be displayed:
  2746. raJustify, // displayed like raLeft (though stored normally)
  2747. raInterLetter, raScaled, raGlyphs, raSnapGrid );
  2748. {* Text alignment styles, available for RichEdit control. }
  2749. TVerticalAlign = ( vaCenter, vaTop, vaBottom );
  2750. {* Vertical alignments available. }
  2751. TControlAlign = ( caNone, caLeft, caTop, caRight, caBottom, caClient );
  2752. {* Control alignments available. }
  2753. //[BitBtn TYPES]
  2754. TBitBtnOption = ( bboImageList,
  2755. bboNoBorder,
  2756. bboNoCaption,
  2757. bboFixed );
  2758. {* Options available for NewBitBtn. }
  2759. TBitBtnOptions = set of TBitBtnOption;
  2760. {* Set of options, available for NewBitBtn. }
  2761. TGlyphLayout = ( glyphLeft, glyphTop, glyphRight, glyphBottom, glyphOver );
  2762. {* Layout of glyph (for NewBitBtn). Layout glyphOver means that text is
  2763. drawn over glyph. }
  2764. TOnBitBtnDraw = function( Sender: PControl; BtnState: Integer ): Boolean of object;
  2765. {* Event type for TControl.OnBitBtnDraw event (which is called just before
  2766. drawing the BitBtn). If handler returns True, there are no drawing occure.
  2767. BtnState, passed to a handler, determines current button state and can
  2768. be following: 0 - not pressed, 1 - pressed, 2 - disabled, 3 - focused.
  2769. Value 4 is reserved for highlight state (then mouse is over it), but
  2770. highlighting is provided only if property Flat is set to True (or one
  2771. of events OnMouseEnter / OnMouseLeave is assigned to something). }
  2772. //[ListView TYPES]
  2773. TListViewStyle = ( lvsIcon, lvsSmallIcon, lvsList, lvsDetail, lvsDetailNoHeader );
  2774. {* Styles of view for ListView control (see NewListVew). }
  2775. TListViewItemStates = ( lvisFocus, lvisSelect, lvisBlend, lvisHighlight );
  2776. TListViewItemState = Set of TListViewItemStates;
  2777. TListViewOption = (
  2778. lvoIconLeft, // in lvsIcon, lvsSmallIcon plce icon left from text (rather then top)
  2779. lvoAutoArrange, // keep icons auto arranged in lvsIcon and lvsSmallIcon view
  2780. lvoButton, // icons look like buttons in lvsIcon view
  2781. lvoEditLabel, // allows edit labels inplace (first column #0 text)
  2782. lvoNoLabelWrap, // item text on a single line in lvsIcon view (by default, item text may wrap in lvsIcon view).
  2783. lvoNoScroll, // obvious
  2784. lvoNoSortHeader, // click on header button does not lead to sort items
  2785. lvoHideSel, // hide selection when not in focus
  2786. lvoMultiselect, // allow to select multiple items
  2787. lvoSortAscending,
  2788. lvoSortDescending,
  2789. // extended styles (not documented in my Win32.hlp :( , got from VCL source:
  2790. lvoGridLines,
  2791. lvoSubItemImages,
  2792. lvoCheckBoxes,
  2793. lvoTrackSelect,
  2794. lvoHeaderDragDrop,
  2795. lvoRowSelect,
  2796. lvoOneClickActivate,
  2797. lvoTwoClickActivate,
  2798. lvoFlatsb,
  2799. lvoRegional,
  2800. lvoInfoTip,
  2801. lvoUnderlineHot,
  2802. lvoMultiWorkares,
  2803. // virtual list view style:
  2804. lvoOwnerData,
  2805. // custom draw style:
  2806. lvoOwnerDrawFixed
  2807. );
  2808. TListViewOptions = Set of TListViewOption;
  2809. TOnEditLVItem = function( Sender: PControl; Idx, Col: Integer; NewText: PChar ): Boolean
  2810. of object;
  2811. {* Event type for OnEndEditLVItem. Return True in handler to accept new text value. }
  2812. TOnDeleteLVItem = procedure( Sender: PControl; Idx: Integer ) of object;
  2813. {* Event type for OnDeleteLVItem event. }
  2814. TOnLVData = procedure( Sender: PControl; Idx, SubItem: Integer;
  2815. var Txt: String; var ImgIdx: Integer; var State: DWORD;
  2816. var Store: Boolean ) of object;
  2817. {* Event type for OnLVData event. Used to provide virtual list view control
  2818. (i.e. having lvoOwnerData style) with actual data on request. Use parameter
  2819. Store as a flag if control should store obtained data by itself or not. }
  2820. {$IFNDEF _D2}
  2821. {$IFNDEF _FPC}
  2822. TOnLVDataW = procedure( Sender: PControl; Idx, SubItem: Integer;
  2823. var Txt: WideString; var ImgIdx: Integer; var State: DWORD;
  2824. var Store: Boolean ) of object;
  2825. {* Event type for OnLVDataW event (the same as OnLVData, but for unicode verion
  2826. of the control OnLVDataW allows to return WideString text in the event
  2827. handler). Used to provide virtual list view control
  2828. (i.e. having lvoOwnerData style) with actual data on request. Use parameter
  2829. Store as a flag if control should store obtained data by itself or not. }
  2830. {$ENDIF _FPC}
  2831. {$ENDIF _D2}
  2832. TOnCompareLVItems = function( Sender: PControl; Idx1, Idx2: Integer ): Integer
  2833. of object;
  2834. {* Event type to compare two items of the list view (while sorting it). }
  2835. TOnLVColumnClick = procedure( Sender: PControl; Idx: Integer ) of object;
  2836. {* Event type for OnColumnClick event. }
  2837. TOnLVStateChange = procedure( Sender: PControl; IdxFrom, IdxTo: Integer; OldState, NewState: DWORD )
  2838. of object;
  2839. {* Event type for OnLVStateChange event, called in responce to select/unselect
  2840. a single item or items range in list view control). }
  2841. TOnLVDelete = procedure( Sender: PControl; Idx: Integer ) of object;
  2842. {* Event type for OnLVDelete event, called when an item is been deleting. }
  2843. TDrawActions = ( odaEntire, odaFocus, odaSelect );
  2844. TDrawAction = Set of TDrawActions;
  2845. TDrawStates = ( odsSelected, odsGrayed, odsDisabled, odsChecked, odsFocused,
  2846. odsDefault, odsHotlist, odsInactive,
  2847. odsNoAccel, odsNoFocusRect,
  2848. ods400reserved, ods800reserved,
  2849. odsComboboxEdit,
  2850. // specific for common controls:
  2851. odsMarked, odsIndeterminate );
  2852. {* Possible draw states.
  2853. |<br>odsSelected - The menu item's status is selected.
  2854. |<br>odsGrayed - The item is to be grayed. This bit is used only in a menu.
  2855. |<br>odsDisabled - The item is to be drawn as disabled.
  2856. |<br>odsChecked - The menu item is to be checked. This bit is used only in
  2857. a menu.
  2858. |<br>odsFocused - The item has the keyboard focus.
  2859. |<br>odsDefault - The item is the default item.
  2860. |<br>odsHotList - <b>Windows 98, Windows 2000:</b> The item is being
  2861. hot-tracked, that is, the item will be highlighted when
  2862. the mouse is on the item.
  2863. |<br>odsInactive - <b>Windows 98, Windows 2000:</b> The item is inactive
  2864. and the window associated with the menu is inactive.
  2865. |<br>odsNoAccel - <b>Windows 2000:</b> The control is drawn without the
  2866. keyboard accelerator cues.
  2867. |<br>odsNoFocusRect - <b>Windows 2000:</b> The control is drawn without
  2868. focus indicator cues.
  2869. |<br>odsComboboxEdit - The drawing takes place in the selection field
  2870. (edit control) of an owner-drawn combo box.
  2871. |<br>odsMarked - for Common controls only. The item is marked. The meaning
  2872. of this is up to the implementation.
  2873. |<br>odsIndeterminate - for Common Controls only. The item is in an
  2874. indeterminate state. }
  2875. TDrawState = Set of TDrawStates;
  2876. {* Set of possible draw states. }
  2877. TOnDrawItem = function( Sender: PObj; DC: HDC; const Rect: TRect; ItemIdx: Integer;
  2878. DrawAction: TDrawAction; ItemState: TDrawState ): Boolean of object;
  2879. {* Event type for OnDrawItem event (applied to list box, combo box, list view). }
  2880. TOnMeasureItem = function( Sender: PObj; Idx: Integer ): Integer of object;
  2881. {* Event type for OnMeasureItem event. The event handler must return height of list box
  2882. item as a result. }
  2883. TGetLVItemPart = ( lvipBounds, lvipIcon, lvipLabel, lvupIconAndLabel );
  2884. {* }
  2885. TWherePosLVItem = ( lvwpOnIcon, lvwpOnLabel, lvwpOnStateIcon, lvwpOnColumn,
  2886. lvwpOnItem );
  2887. {* }
  2888. TOnLVCustomDraw = function( Sender: PControl; DC: HDC; Stage: DWORD;
  2889. ItemIdx, SubItemIdx: Integer; const Rect: TRect;
  2890. ItemState: TDrawState; var TextColor, BackColor: TColor )
  2891. : DWORD of object;
  2892. {* Event type for OnLVCustomDraw event. }
  2893. //[Paint TYPES]
  2894. TOnPaint = procedure( Sender: PControl; DC: HDC ) of object;
  2895. TPaintProc = procedure( DC: HDC ) of object;
  2896. TGradientStyle = ( gsVertical, gsHorizontal, gsRectangle, gsElliptic, gsRombic );
  2897. {* Gradient fill styles. See also TGradientLayout. }
  2898. TGradientLayout = ( glTopLeft, glTop, glTopRight,
  2899. glLeft, glCenter, glRight,
  2900. glBottomLeft, glBottom, glBottomRight );
  2901. {* Position of starting line / point for gradient filling. Depending on
  2902. TGradientStyle, means either position of first line of first rectangle
  2903. (ellipse) to be expanded in a loop to fit entire gradient panel area. }
  2904. //[Edit TYPES]
  2905. TEditOption = ( eoNoHScroll, eoNoVScroll, eoLowercase, eoMultiline,
  2906. eoNoHideSel, eoOemConvert, eoPassword, eoReadonly,
  2907. eoUpperCase, eoWantReturn, eoWantTab, eoNumber );
  2908. {* Available edit options.
  2909. |<br> Please note, that eoWantTab option just removes TAB key from a list
  2910. of keys available to tabulate from the edit control. To provide insertion
  2911. of tabulating key, do so in TControl.OnChar event handler. Sorry for
  2912. inconvenience, but this is because such behaviour is not must in all cases.
  2913. See also TControl.EditTabChar property. }
  2914. TEditOptions = Set of TEditOption;
  2915. {* Set of available edit options. }
  2916. TRichFmtArea = ( raSelection, raWord, raAll );
  2917. {* Characters formatting area for RichEdit. }
  2918. TRETextFormat = ( reRTF, reText, rePlainRTF, reRTFNoObjs, rePlainRTFNoObjs,
  2919. reTextized );
  2920. {* Available formats for transfer RichEdit text using property
  2921. TControl.RE_Text.
  2922. |<pre>
  2923. reRTF - normal rich text (no transformations)
  2924. reText - plain text only (without OLE objects)
  2925. reTextized - plain text with text representation of OLE objects
  2926. rePlainRTF - reRTF without language-specific keywords
  2927. reRTFNoObjs - reRTF without OLE objects
  2928. rePlainRTFNoObjs - rePlainRTF without OLE objects
  2929. |</pre> }
  2930. TRichUnderline = ( ruSingle, ruWord, ruDouble, ruDotted,
  2931. //all other - only for RichEditv3.0:
  2932. ruDash, ruDashDot, ruDashDotDot, ruWave, ruThick, ruHairLine );
  2933. {* Rich text exteded underline styles (available only for RichEdit v2.0,
  2934. and even for RichEdit v2.0 additional styles can not displayed - but
  2935. ruDotted under Windows2000 is working). }
  2936. TRichTextSizes = ( rtsNoUseCRLF, rtsNoPrecise, rtsClose, rtsBytes );
  2937. {* Options to calculate size of rich text. Available only for RichEdit2.0
  2938. or higher. }
  2939. TRichTextSize = set of TRichTextSizes;
  2940. {* Set of all available optioins to calculate rich text size using
  2941. property TControl.RE_TextSize[ options ]. }
  2942. TRichNumbering = ( rnNone, rnBullets, rnArabic, rnLLetter, rnULetter,
  2943. rnLRoman, rnURoman );
  2944. {* Advanced numbering styles for paragraph (RichEdit).
  2945. |<pre>
  2946. rnNone - no numbering
  2947. rnBullets - bullets only
  2948. rnArabic - 1, 2, 3, 4, ...
  2949. rnLLetter - a, b, c, d, ...
  2950. rnULetter - A, B, C, D, ...
  2951. rnLRoman - i, ii, iii, iv, ...
  2952. rnURoman - I, II, III, IV, ...
  2953. rnNoNumber - do not show any numbers (but numbering is taking place).
  2954. |</pre> }
  2955. TRichNumBrackets = ( rnbRight, rnbBoth, rnbPeriod, rnbPlain, rnbNoNumber );
  2956. {* Brackets around number:
  2957. |<pre>
  2958. rnbRight - 1) 2) 3) - this is default !
  2959. rnbBoth - (1) (2) (3)
  2960. rnbPeriod - 1. 2. 3.
  2961. rnbPlain - 1 2 3
  2962. |</pre> }
  2963. TBorderEdge = (beLeft, beTop, beRight, beBottom);
  2964. {* Borders of rectangle. }
  2965. TCharFormat = TCharFormat2;
  2966. TParaFormat = TParaFormat2;
  2967. TOnTestMouseOver = function( Sender: PControl ): Boolean of object;
  2968. {* Event type for TControl.OnTestMouseOver event. The handler should
  2969. return True, if it dectects, that mouse is over control. }
  2970. TEdgeStyle = ( esRaised, esLowered, esNone );
  2971. {* Edge styles (for panel - see NewPanel). }
  2972. //[List TYPES]
  2973. TListOption = ( loNoHideScroll, loNoExtendSel, loMultiColumn, loMultiSelect,
  2974. loNoIntegralHeight, loNoSel, loSort, loTabstops,
  2975. loNoStrings, loNoData, loOwnerDrawFixed, loOwnerDrawVariable );
  2976. {* Options for ListBox (see NewListbox). }
  2977. TListOptions = Set of TListOption;
  2978. {* Set of available options for Listbox. }
  2979. TComboOption = ( coReadOnly, coNoHScroll, coAlwaysVScroll, coLowerCase,
  2980. coNoIntegralHeight, coOemConvert, coSort, coUpperCase,
  2981. coOwnerDrawFixed, coOwnerDrawVariable, coSimple );
  2982. {* Options for combobox. }
  2983. TComboOptions = Set of TComboOption;
  2984. {* Set of options available for combobox. }
  2985. //[Progress TYPES]
  2986. TProgressbarOption = ( pboVertical, pboSmooth );
  2987. {* Options for progress bar. }
  2988. TProgressbarOptions = set of TProgressbarOption;
  2989. {* Set of options available for progress bar. }
  2990. //[TreeView TYPES]
  2991. TTreeViewOption = ( tvoNoLines, tvoLinesRoot, tvoNoButtons, tvoEditLabels, tvoHideSel,
  2992. tvoDragDrop, tvoNoTooltips, tvoCheckBoxes, tvoTrackSelect,
  2993. tvoSingleExpand, tvoInfoTip, tvoFullRowSelect, tvoNoScroll,
  2994. tvoNonEvenHeight );
  2995. {* Tree view options. }
  2996. TTreeViewOptions = set of TTreeViewOption;
  2997. {* Set of tree view options. }
  2998. //[TabControl TYPES]
  2999. TTabControlOption = ( tcoButtons, tcoFixedWidth, tcoFocusTabs,
  3000. tcoIconLeft, tcoLabelLeft,
  3001. tcoMultiline, tcoMultiselect, tcoFitRows, tcoScrollOpposite,
  3002. tcoBottom, tcoVertical, tcoFlat, tcoHotTrack, tcoBorder,
  3003. tcoOwnerDrawFixed );
  3004. {* Options, available for TabControl. }
  3005. TTabControlOptions = set of TTabControlOption;
  3006. {* Set of options, available for TAbControl during its creation (by
  3007. NewTabControl function). }
  3008. //[Toolbar TYPES]
  3009. TToolbarOption = ( tboTextRight, tboTextBottom, tboFlat, tboTransparent,
  3010. tboWrapable, tboNoDivider, tbo3DBorder );
  3011. {* Toolbar options. When tboFlat is set and toolbar is placed onto panel,
  3012. set its property Transparent to TRUE to provide its correct view. }
  3013. TToolbarOptions = Set of TToolbarOption;
  3014. {* Set of toolbar options. }
  3015. TOnToolbarButtonClick = procedure( Sender: PControl; BtnID: Integer ) of object;
  3016. {* Special event type to handle separate toolbar buttons click events. }
  3017. TDateTimePickerOption = ( dtpoTime, dtpoDateLong, dtpoUpDown, dtpoRightAlign,
  3018. dtpoShowNone, dtpoParseInput );
  3019. {* }
  3020. TDateTimePickerOptions = set of TDateTimePickerOption;
  3021. {* }
  3022. TDTParseInputEvent = procedure(Sender: PControl; const UserString: string;
  3023. var DateAndTime: TDateTime; var AllowChange: Boolean) of object;
  3024. {* }
  3025. TDateTimeRange = array[ 0..1 ] of TDateTime;
  3026. {* }
  3027. TDateTimePickerColor = ( dtpcBackground, dtpcMonthBk, dtpcText, dtpcTitleBk,
  3028. dtpcTitleText, dtpcTrailingText );
  3029. //[TOnDropFiles TYPE]
  3030. TOnDropFiles = procedure( Sender: PControl; const FileList: String; const Pt: TPoint ) of object;
  3031. {* An event type for OnDropFiles event. When the event is occur, FileList
  3032. parameter contains a list of files dropped. File names in a list are
  3033. separated with #13 character. This allows You to assign it to TStrList
  3034. object using its property Text (for example):
  3035. ! procedure TSomeObject.DropFiles( Sender: PControl; const FileList: String;
  3036. ! const Pt: TPoint ); )
  3037. ! var FList: PStrList;
  3038. ! I: Integer;
  3039. ! begin
  3040. ! FList := NewStrList;
  3041. ! FList.Text := FileList;
  3042. ! for I := 0 to FList.Count-1 do
  3043. ! begin
  3044. ! // do something with FList.Items[ I ]
  3045. ! end;
  3046. ! FList.Free;
  3047. ! end; }
  3048. //[Scroll TYPES]
  3049. TScrollerBar = ( sbHorizontal, sbVertical );
  3050. TScrollerBars = set of TScrollerBar;
  3051. TOnScroll = procedure( Sender: PControl; Bar: TScrollerBar; ScrollCmd: DWORD;
  3052. ThumbPos: DWORD ) of object;
  3053. //[TOnHelp EVENT TYPE]
  3054. TOnHelp = procedure( var Sender: PControl; var Context: Integer; var Popup: Boolean )
  3055. of object;
  3056. //[ScrollBar TYPES]
  3057. TOnSBBeforeScroll =
  3058. procedure(
  3059. Sender: PControl; OldPos, NewPos: Integer; Cmd: Word;
  3060. var AllowChange: Boolean) of object;
  3061. TOnSBScroll = procedure(Sender: PControl; Cmd: Word) of object;
  3062. TOnGraphCtlMouse = procedure( var Msg: TMsg ) of object;
  3063. TTriStateCheck = (tsUnchecked{=0}, tsChecked{=1}, tsIndeterminate{=2});
  3064. {$IFDEF USE_MHTOOLTIP}
  3065. {$DEFINE pre_interface}
  3066. {$I KOLMHToolTip}
  3067. {$UNDEF pre_interface}
  3068. {$ENDIF}
  3069. { ----------------------------------------------------------------------
  3070. TControl - object to implement any visual control
  3071. ----------------------------------------------------------------------- }
  3072. //[TControl DEFINITION]
  3073. TControl = object( TObj )
  3074. protected
  3075. fSBMinMax: TPoint;
  3076. fSBPageSize: Integer;
  3077. fSBPosition: Integer;
  3078. procedure SetSBMax(Value: Longint);
  3079. procedure SetSBMin(Value: Longint);
  3080. procedure SetSBPageSize(Value: Integer);
  3081. procedure SetSBPosition(Value: Integer);
  3082. procedure SetSBMinMax(const Value: TPoint);
  3083. function GetDate: TDateTime;
  3084. function GetTime: TDateTime;
  3085. procedure SetDate(const Value: TDateTime);
  3086. procedure SetTime(const Value: TDateTime);
  3087. {*! TControl is the basic visual object of KOL. And now, all visual
  3088. objects have the same type PControl, differing only in "constructor",
  3089. which during creating of object adjusts it so it can play role of
  3090. desired control. Idea of incapsulating of all visual objects having
  3091. the most common set of properties, is belonging to Vladimir Kladov,
  3092. (C) 2000.
  3093. |<br>&nbsp;&nbsp;&nbsp;<b> Since all visual objects are represented
  3094. in KOL by this single object type, not all methods, properties and
  3095. events defined in TControl, are applicable to different visual objects.
  3096. See also notes about certain control kinds, located together with its
  3097. |<a href="kol_pas.htm#visual_objects_constructors">
  3098. |constructing functions definitions</a></b>. }
  3099. protected
  3100. function GetHelpPath: String;
  3101. procedure SetHelpPath(const Value: String);
  3102. procedure SetOnQueryEndSession(const Value: TOnEventAccept);
  3103. procedure SetOnMinMaxRestore(const Index: Integer; const Value: TOnEvent);
  3104. procedure SetConstraint(const Index, Value: Integer);
  3105. {$IFDEF F_P}
  3106. function GetOnMinMaxRestore(const Index: Integer): TOnEvent;
  3107. function GetConstraint(const Index: Integer): Integer;
  3108. {$ENDIF F_P}
  3109. procedure SetOnScroll(const Value: TOnScroll);
  3110. function GetLVColalign(Idx: Integer): TTextAlign;
  3111. procedure SetLVColalign(Idx: Integer; const Value: TTextAlign);
  3112. procedure SetParent( Value: PControl );
  3113. function GetLeft: Integer;
  3114. procedure SetLeft( Value: Integer );
  3115. function GetTop: Integer;
  3116. procedure SetTop( Value: Integer );
  3117. function GetWidth: Integer;
  3118. procedure SetWidth( Value: Integer );
  3119. function GetHeight: Integer;
  3120. procedure SetHeight( Value: Integer );
  3121. function GetPosition: TPoint;
  3122. procedure Set_Position( Value: TPoint );
  3123. function GetMembers(Idx: Integer): PControl;
  3124. function GetFont: PGraphicTool;
  3125. procedure FontChanged( Sender: PGraphicTool );
  3126. function GetBrush: PGraphicTool;
  3127. procedure BrushChanged( Sender: PGraphicTool );
  3128. function GetClientHeight: Integer;
  3129. function GetClientWidth: Integer;
  3130. procedure SetClientHeight(const Value: Integer);
  3131. procedure SetClientWidth(const Value: Integer);
  3132. function GetHasBorder: Boolean;
  3133. procedure SetHasBorder(const Value: Boolean);
  3134. function GetHasCaption: Boolean;
  3135. procedure SetHasCaption(const Value: Boolean);
  3136. function GetCanResize: Boolean;
  3137. procedure SetCanResize( const Value: Boolean );
  3138. function GetStayOnTop: Boolean;
  3139. procedure SetStayOnTop(const Value: Boolean);
  3140. function GetChecked: Boolean;
  3141. procedure Set_Checked(const Value: Boolean);
  3142. function GetCheck3: TTriStateCheck;
  3143. procedure SetCheck3(value: TTriStateCheck);
  3144. function GetSelStart: Integer;
  3145. procedure SetSelStart(const Value: Integer);
  3146. function GetSelLength: Integer;
  3147. procedure SetSelLength(const Value: Integer);
  3148. function GetItems(Idx: Integer): String;
  3149. procedure SetItems(Idx: Integer; const Value: String);
  3150. function GetItemsCount: Integer;
  3151. function GetItemSelected(ItemIdx: Integer): Boolean;
  3152. procedure SetItemSelected(ItemIdx: Integer; const Value: Boolean);
  3153. procedure SetCtl3D(const Value: Boolean);
  3154. function GetCurIndex: Integer;
  3155. procedure SetCurIndex(const Value: Integer);
  3156. function GetTextAlign: TTextAlign;
  3157. function GetVerticalAlign: TVerticalAlign;
  3158. procedure SetTextAlign(const Value: TTextAlign);
  3159. procedure SetVerticalAlign(const Value: TVerticalAlign);
  3160. function GetCanvas: PCanvas;
  3161. function Dc2Canvas( Sender: PCanvas ): HDC;
  3162. procedure SetShadowDeep(const Value: Integer);
  3163. procedure SetDoubleBuffered(const Value: Boolean);
  3164. procedure SetStatusText(Index: Integer; Value: PChar);
  3165. function GetStatusText( Index: Integer ): PChar;
  3166. function GetStatusPanelX(Idx: Integer): Integer;
  3167. procedure SetStatusPanelX(Idx: Integer; const Value: Integer);
  3168. procedure SetTransparent(const Value: Boolean);
  3169. function GetImgListIdx(const Index: Integer): PImageList;
  3170. procedure SetImgListIdx(const Index: Integer; const Value: PImageList);
  3171. function GetLVColText(Idx: Integer): String;
  3172. procedure SetLVColText(Idx: Integer; const Value: String);
  3173. {$IFNDEF _FPC}
  3174. {$IFNDEF _D2}
  3175. function GetLVColTextW(Idx: Integer): WideString;
  3176. procedure SetLVColTextW(Idx: Integer; const Value: WideString);
  3177. {$ENDIF _D2}
  3178. {$ENDIF _FPC}
  3179. function LVGetItemText(Idx, Col: Integer): String;
  3180. procedure LVSetItemText(Idx, Col: Integer; const Value: String);
  3181. {$IFNDEF _FPC}
  3182. {$IFNDEF _D2}
  3183. function LVGetItemTextW(Idx, Col: Integer): WideString;
  3184. procedure LVSetItemTextW(Idx, Col: Integer; const Value: WideString);
  3185. {$ENDIF _D2}
  3186. {$ENDIF _FPC}
  3187. procedure SetLVOptions(const Value: TListViewOptions);
  3188. procedure SetLVStyle(const Value: TListViewStyle);
  3189. function GetLVColEx(Idx: Integer; const Index: Integer): Integer;
  3190. procedure SetLVColEx(Idx: Integer; const Index: Integer;
  3191. const Value: Integer);
  3192. function GetChildCount: Integer;
  3193. function LVGetItemPos(Idx: Integer): TPoint;
  3194. procedure LVSetItemPos(Idx: Integer; const Value: TPoint);
  3195. procedure LVSetColorByIdx(const Index: Integer; const Value: TColor);
  3196. {$IFDEF F_P}
  3197. function LVGetColorByIdx(const Index: Integer): TColor;
  3198. {$ENDIF F_P}
  3199. function GetIntVal(const Index: Integer): Integer;
  3200. procedure SetIntVal(const Index, Value: Integer);
  3201. function GetItemVal(Item: Integer; const Index: Integer): Integer;
  3202. procedure SetItemVal(Item: Integer; const Index, Value: Integer);
  3203. function TBGetButtonVisible(BtnID: Integer): Boolean;
  3204. procedure TBSetButtonVisible(BtnID: Integer; const Value: Boolean);
  3205. function TBGetBtnStt(BtnID: Integer; const Index: Integer): Boolean;
  3206. procedure TBSetBtnStt(BtnID: Integer; const Index: Integer; const Value: Boolean);
  3207. function TBGetButtonText(BtnID: Integer): String;
  3208. function TBGetButtonRect(BtnID: Integer): TRect;
  3209. function TBGetRows: Integer;
  3210. procedure TBSetRows(const Value: Integer);
  3211. procedure SetProgressColor(const Value: TColor);
  3212. function TBGetBtnImgIdx(BtnID: Integer): Integer;
  3213. procedure TBSetBtnImgIdx(BtnID: Integer; const Value: Integer);
  3214. procedure TBSetButtonText(BtnID: Integer; const Value: String);
  3215. function TBGetBtnWidth(BtnID: Integer): Integer;
  3216. procedure TBSetBtnWidth(BtnID: Integer; const Value: Integer);
  3217. procedure TBSetBtMinMaxWidth(const Idx: Integer; const Value: Integer);
  3218. {$IFDEF F_P}
  3219. function TBGetBtMinMaxWidth(const Idx: Integer): Integer;
  3220. {$ENDIF F_P}
  3221. procedure TBFreeTBevents;
  3222. procedure Set_Align(const Value: TControlAlign);
  3223. function GetSelection: String;
  3224. procedure SetSelection(const Value: String);
  3225. procedure SetTabOrder(const Value: Integer);
  3226. function GetFocused: Boolean;
  3227. procedure SetFocused(const Value: Boolean);
  3228. function REGetFont: PGraphicTool;
  3229. procedure RESetFont(Value: PGraphicTool);
  3230. procedure RESetFontEx(const Index: Integer);
  3231. function REGetFontEffects(const Index: Integer): Boolean;
  3232. function REGetFontMask(const Index: Integer): Boolean;
  3233. procedure RESetFontEffect(const Index: Integer; const Value: Boolean);
  3234. function REGetFontAttr(const Index: Integer): Integer;
  3235. procedure RESetFontAttr(const Index, Value: Integer);
  3236. procedure RESetFontAttr1(const Index, Value: Integer);
  3237. function REGetFontSizeValid: Boolean;
  3238. function REGetCharformat: TCharFormat;
  3239. procedure RESetCharFormat(const Value: TCharFormat);
  3240. function REReadText(Format: TRETextFormat;
  3241. SelectionOnly: Boolean): String;
  3242. procedure REWriteText(Format: TRETextFormat; SelectionOnly: Boolean;
  3243. const Value: String);
  3244. function REGetFontName: String;
  3245. procedure RESetFontName(const Value: String);
  3246. function REGetParaFmt: TParaFormat;
  3247. procedure RESetParaFmt(const Value: TParaFormat);
  3248. function REGetNumbering: Boolean;
  3249. function REGetParaAttr( const Index: Integer ): Integer;
  3250. function REGetParaAttrValid( const Index: Integer ): Boolean;
  3251. function REGetTabCount: Integer;
  3252. function REGetTabs(Idx: Integer): Integer;
  3253. function REGetTextAlign: TRichTextAlign;
  3254. procedure RESetNumbering(const Value: Boolean);
  3255. procedure RESetParaAttr(const Index, Value: Integer);
  3256. procedure RESetTabCount(const Value: Integer);
  3257. procedure RESetTabs(Idx: Integer; const Value: Integer);
  3258. procedure RESetTextAlign(const Value: TRichTextAlign);
  3259. function REGetStartIndentValid: Boolean;
  3260. function REGetAutoURLDetect: Boolean;
  3261. procedure RESetAutoURLDetect(const Value: Boolean);
  3262. function GetMaxTextSize: DWORD;
  3263. procedure SetMaxTextSize(const Value: DWORD);
  3264. procedure SetOnResize(const Value: TOnEvent);
  3265. procedure DoSelChange;
  3266. function REGetUnderlineEx: TRichUnderline;
  3267. procedure RESetUnderlineEx(const Value: TRichUnderline);
  3268. function GetTextSize: Integer;
  3269. function REGetTextSize(Units: TRichTextSize): Integer;
  3270. function REGetNumStyle: TRichNumbering;
  3271. procedure RESetNumStyle(const Value: TRichNumbering);
  3272. function REGetNumBrackets: TRichNumBrackets;
  3273. procedure RESetNumBrackets(const Value: TRichNumBrackets);
  3274. function REGetNumTab: Integer;
  3275. procedure RESetNumTab(const Value: Integer);
  3276. function REGetNumStart: Integer;
  3277. procedure RESetNumStart(const Value: Integer);
  3278. function REGetSpacing(const Index: Integer): Integer;
  3279. procedure RESetSpacing(const Index, Value: Integer);
  3280. function REGetSpacingRule: Integer;
  3281. procedure RESetSpacingRule(const Value: Integer);
  3282. function REGetLevel: Integer;
  3283. function REGetBorder(Side: TBorderEdge; const Index: Integer): Integer;
  3284. procedure RESetBorder(Side: TBorderEdge; const Index: Integer;
  3285. const Value: Integer);
  3286. function REGetParaEffect(const Index: Integer): Boolean;
  3287. procedure RESetParaEffect(const Index: Integer; const Value: Boolean);
  3288. function REGetOverwite: Boolean;
  3289. procedure RESetOverwrite(const Value: Boolean);
  3290. procedure RESetOvrDisable(const Value: Boolean);
  3291. function REGetTransparent: Boolean;
  3292. procedure RESetTransparent(const Value: Boolean);
  3293. procedure RESetOnURL(const Index: Integer; const Value: TOnEvent);
  3294. {$IFDEF F_P}
  3295. function REGetOnURL(const Index: Integer): TOnEvent;
  3296. {$ENDIF F_P}
  3297. function REGetLangOptions(const Index: Integer): Boolean;
  3298. procedure RESetLangOptions(const Index: Integer; const Value: Boolean);
  3299. function LVGetItemImgIdx(Idx: Integer): Integer;
  3300. procedure LVSetItemImgIdx(Idx: Integer; const Value: Integer);
  3301. procedure SetFlat(const Value: Boolean);
  3302. procedure SetOnMouseEnter(const Value: TOnEvent);
  3303. procedure SetOnMouseLeave(const Value: TOnEvent);
  3304. procedure EdSetTransparent(const Value: Boolean);
  3305. procedure SetOnTestMouseOver(const Value: TOnTestMouseOver);
  3306. function GetPages(Idx: Integer): PControl;
  3307. function TCGetItemText(Idx: Integer): String;
  3308. procedure TCSetItemText(Idx: Integer; const Value: String);
  3309. function TCGetItemImgIDx(Idx: Integer): Integer;
  3310. procedure TCSetItemImgIdx(Idx: Integer; const Value: Integer);
  3311. function TCGetItemRect(Idx: Integer): TRect;
  3312. function TVGetItemIdx(const Index: Integer): THandle;
  3313. procedure TVSetItemIdx(const Index: Integer; const Value: THandle);
  3314. function TVGetItemNext(Item: THandle; const Index: Integer): THandle;
  3315. function TVGetItemRect(Item: THandle; TextOnly: Boolean): TRect;
  3316. function TVGetItemVisible(Item: THandle): Boolean;
  3317. procedure TVSetITemVisible(Item: THandle; const Value: Boolean);
  3318. function TVGetItemStateFlg(Item: THandle; const Index: Integer): Boolean;
  3319. procedure TVSetItemStateFlg(Item: THandle; const Index: Integer;
  3320. const Value: Boolean);
  3321. function TVGetItemImage(Item: THandle; const Index: Integer): Integer;
  3322. procedure TVSetItemImage(Item: THandle; const Index: Integer;
  3323. const Value: Integer);
  3324. function TVGetItemText(Item: THandle): String;
  3325. procedure TVSetItemText(Item: THandle; const Value: String);
  3326. {$IFNDEF _FPC}
  3327. {$IFNDEF _D2}
  3328. function TVGetItemTextW(Item: THandle): WideString;
  3329. procedure TVSetItemTextW(Item: THandle; const Value: WideString);
  3330. {$ENDIF _D2}
  3331. {$ENDIF _FPC}
  3332. function TV_GetItemHasChildren(Item: THandle): Boolean;
  3333. procedure TV_SetItemHasChildren(Item: THandle; const Value: Boolean);
  3334. function TV_GetItemChildCount(Item: THandle): Integer;
  3335. function TVGetItemData(Item: THandle): Pointer;
  3336. procedure TVSetItemData(Item: THandle; const Value: Pointer);
  3337. function GetToBeVisible: Boolean;
  3338. procedure SetAlphaBlend(const Value: Integer);
  3339. procedure SetMaxProgress(const Index, Value: Integer);
  3340. procedure SetDroppedWidth(const Value: Integer);
  3341. function LVGetItemState(Idx: Integer): TListViewItemState;
  3342. procedure LVSetItemState(Idx: Integer; const Value: TListViewItemState);
  3343. function LVGetSttImgIdx(Idx: Integer): Integer;
  3344. procedure LVSetSttImgIdx(Idx: Integer; const Value: Integer);
  3345. function LVGetOvlImgIdx(Idx: Integer): Integer;
  3346. procedure LVSetOvlImgIdx(Idx: Integer; const Value: Integer);
  3347. function LVGetItemData(Idx: Integer): DWORD;
  3348. procedure LVSetItemData(Idx: Integer; const Value: DWORD);
  3349. function LVGetItemIndent(Idx: Integer): Integer;
  3350. procedure LVSetItemIndent(Idx: Integer; const Value: Integer);
  3351. procedure SetOnDeleteAllLVItems(const Value: TOnEvent);
  3352. procedure SetOnDeleteLVItem(const Value: TOnDeleteLVItem);
  3353. procedure SetOnEditLVItem(const Value: TOnEditLVItem);
  3354. procedure SetOnLVData(const Value: TOnLVData);
  3355. {$IFNDEF _FPC}
  3356. {$IFNDEF _D2}
  3357. procedure SetOnLVDataW(const Value: TOnLVDataW);
  3358. {$ENDIF _D2}
  3359. {$ENDIF _FPC}
  3360. procedure SetOnColumnClick(const Value: TOnLVColumnClick);
  3361. procedure SetOnDrawItem(const Value: TOnDrawItem);
  3362. procedure SetOnMeasureItem(const Value: TOnMeasureItem);
  3363. procedure SetItemsCount(const Value: Integer);
  3364. function GetItemData(Idx: Integer): DWORD;
  3365. procedure SetItemData(Idx: Integer; const Value: DWORD);
  3366. function GetLVCurItem: Integer;
  3367. procedure SetLVCurItem(const Value: Integer);
  3368. function GetLVFocusItem: Integer;
  3369. procedure SetOnDropFiles(const Value: TOnDropFiles);
  3370. procedure SetOnHide(const Value: TOnEvent);
  3371. procedure SetOnShow(const Value: TOnEvent);
  3372. procedure SetClientMargin(const Index, Value: Integer);
  3373. {$IFDEF F_P}
  3374. function GetClientMargin(const Index: Integer): Integer;
  3375. {$ENDIF F_P}
  3376. procedure SetOnPaint(const Value: TOnPaint);
  3377. procedure SetOnEraseBkgnd(const Value: TOnPaint);
  3378. procedure SetTVRightClickSelect(const Value: Boolean);
  3379. procedure SetOnLVStateChange(const Value: TOnLVStateChange);
  3380. procedure SetOnLVDelete(const Value: TOnLVDelete);
  3381. procedure SetOnMove(const Value: TOnEvent);
  3382. procedure SetColor1(const Value: TColor);
  3383. procedure SetColor2(const Value: TColor);
  3384. procedure SetGradientLayout(const Value: TGradientLayout);
  3385. procedure SetGradientStyle(const Value: TGradientStyle);
  3386. procedure SetDroppedDown(const Value: Boolean);
  3387. function get_ClassName: String;
  3388. procedure set_ClassName(const Value: String);
  3389. procedure SetClsStyle( Value: DWord );
  3390. procedure SetStyle( Value: DWord );
  3391. procedure SetExStyle( Value: DWord );
  3392. procedure SetCursor( Value: HCursor );
  3393. procedure SetIcon( Value: HIcon );
  3394. procedure SetMenu( Value: HMenu );
  3395. function GetCaption: String;
  3396. procedure SetCaption( const Value: String );
  3397. procedure SetWindowState( Value: TWindowState );
  3398. function GetWindowState: TWindowState;
  3399. procedure ApplyFont2Wnd;
  3400. procedure DoClick;
  3401. function TBAddInsButtons( Idx: Integer; const Buttons: array of PChar; const BtnImgIdxArray: array
  3402. of Integer ): Integer; stdcall;
  3403. procedure SetBitBtnDrawMnemonic(const Value: Boolean);
  3404. function GetBitBtnImgIdx: Integer;
  3405. procedure SetBitBtnImgIdx(const Value: Integer);
  3406. function GetBitBtnImageList: THandle;
  3407. procedure SetBitBtnImageList(const Value: THandle);
  3408. function GetModal: Boolean;
  3409. {$IFDEF USE_SETMODALRESULT}
  3410. procedure SetModalResult( const Value: Integer );
  3411. {$ENDIF}
  3412. protected
  3413. fHandle: HWnd;
  3414. fFocusHandle: HWnd;
  3415. fClsStyle: DWord;
  3416. fStyle: DWord;
  3417. fExStyle: DWord;
  3418. fCursor: HCursor;
  3419. fCursorShared: Boolean;
  3420. fIcon: HIcon;
  3421. fIconShared: Boolean;
  3422. fCaption: PChar; // it is now preferred to store Caption as PChar (null-
  3423. // terminated string), dynamically allocated in memory.
  3424. fIgnoreWndCaption: Boolean;
  3425. fWindowState: TWindowState;
  3426. fShowAction: Integer;
  3427. fCanvas: PCanvas;
  3428. fDefWndProc: Pointer;
  3429. fNCDestroyed: Boolean;
  3430. FParent: PControl;
  3431. //FTag: Integer;
  3432. fEnabled: Boolean; // Caution!!! fVisible must follow fEnabled! ___
  3433. fVisible: Boolean; //____________________________________________//
  3434. fTabstop: Boolean;
  3435. fTabOrder: Integer;
  3436. fTextAlign: TTextAlign;
  3437. fVerticalAlign: TVerticalAlign;
  3438. fWordWrap: Boolean;
  3439. fPreventResize: Boolean;
  3440. fAlphaBlend: Integer;
  3441. FDroppedWidth: Integer;
  3442. fChildren: PList;
  3443. {* List of children. }
  3444. fMDIClient: PControl;
  3445. {* MDI client window control }
  3446. fPass2DefProc: function( Self_: PControl; var Msg: TMsg; var Rslt: Integer ): Boolean;
  3447. {* MDI children list }
  3448. fMDIChildren: PList;
  3449. {* List of MDI children. It is filled for MDI client window. }
  3450. fWndFunc: Pointer;
  3451. {* Initially pointer to WndFunc. For MDI child window, points to DefMDIChildProc. }
  3452. fExMsgProc: function( Applet: PControl; var Msg: TMsg ): Boolean;
  3453. {* Additional message handler called directly from Applet.ProcessMessage.
  3454. Used to call TranslateMDISysAccel API function for MDI application. }
  3455. fMDIDestroying: Boolean;
  3456. {* }
  3457. fTmpBrush: HBrush;
  3458. {* Brush handle to return in response to some color set messages.
  3459. Intended for internal use instead of Brush.Color if possible
  3460. to avoid using it. }
  3461. fTmpBrushColorRGB: TColor;
  3462. { }
  3463. fMembersCount: Integer;
  3464. {* Memebers count is first used in XCustomControl to separate
  3465. some internal child controls from common XControl.Children
  3466. and make it invisible among Children[]. }
  3467. fDrawCtrl1st: PControl;
  3468. {* Child control to draw it first, i.e. foreground of others. }
  3469. FCreating: Boolean;
  3470. {* True, when creating of object is in progress. }
  3471. fDestroying: Boolean;
  3472. {* True, when destroying of the window is started. Made protected to
  3473. be accessible in descending classes. }
  3474. fMenu: HMenu;
  3475. {* Usually used to store handle of attached main menu, but sometimes
  3476. is used to store control ID (for standard GUI controls only). }
  3477. fMenuObj: PObj;
  3478. {* PMenu pointer to TMenu object. Freed automatically with entire
  3479. chain of menu objects attached to a control (or form). }
  3480. {$IFNDEF NEW_MENU_ACCELL}
  3481. fAccelTable: HAccel;
  3482. {$ENDIF}
  3483. {* Handle of accelerator table created by menu(s). }
  3484. fImageList: PImageList;
  3485. {* Pointer to first private image list. Control can own several image,
  3486. lists, linked to a chain of image list objects. All these image lists
  3487. are released automatically, when control is destroyed. }
  3488. fCtlImageListSml: PImageList;
  3489. {* ImageList object (with small icons 16x16) to use with a control (e.g.,
  3490. with ListView control).
  3491. If not set, but control has a list of image list objects, last added
  3492. image list with small icons is used automatically. }
  3493. fCtlImageListNormal: PImageList;
  3494. {* ImageList object (with big icons 32x32) to use with a control.
  3495. If not set, last added image list with big icons is used. }
  3496. fCtlImgListState: PImageList;
  3497. {* ImageList object to use as a state image list (for ListView control). }
  3498. fIsApplet: Boolean;
  3499. {* True, if the object represent application taskbar button. }
  3500. fIsForm: Boolean;
  3501. {* True, if the object is form. }
  3502. fIsMDIChild: Boolean;
  3503. {* TRUE, if the object is MDI child form. }
  3504. fIsControl: Boolean;
  3505. {* True, if it is a control on form. }
  3506. fIsStaticControl: Byte;
  3507. {* True, if it is static control with a caption. (To prevent flickering
  3508. it in DoubleBuffered mode. }
  3509. fIsCommonControl: Boolean;
  3510. {* True, if it is common control. }
  3511. fChangedPosSz: Byte;
  3512. {* Flags of changing left (1), top (2), width (4) or height (8) }
  3513. fCannotDoubleBuf: Boolean;
  3514. {* True, if cannot set DoubleBuffered to True (RichEdit). }
  3515. fUpdRgn: HRgn;
  3516. fCollectUpdRgn: HRGN;
  3517. fEraseUpdRgn: Boolean;
  3518. fPaintDC: HDC;
  3519. fDblBufBmp: HBitmap;
  3520. {* Memory bitmap, used for DoubleBuffered painting. }
  3521. fDblBufW, fDblBufH: Integer;
  3522. {* Dimensions of fDblBufBmp. }
  3523. fDblBufPainting: Boolean;
  3524. fLookTabKeys: TTabKeys;
  3525. fNotUpdate: Boolean;
  3526. fDynHandlers: PList;
  3527. fColumn: Integer;
  3528. FSupressTab: Boolean;
  3529. fUpdateCount: Integer;
  3530. fPaintLater: Boolean;
  3531. fOnLeave: TOnEvent;
  3532. fEditing: Boolean;
  3533. fAutoPopupMenu: PObj;
  3534. fHelpContext: Integer;
  3535. // Order of following fields is important:
  3536. //_______________________________________________________________________________________________
  3537. fOnDynHandlers: TWindowFunc; //
  3538. fWndProcKeybd: function( Self_: PControl; var Msg: TMsg; var Rslt: Integer ): Boolean; //
  3539. fControlClick: procedure( Sender : PObj ); //
  3540. fControlClassName: PChar; //
  3541. fWindowed: Boolean; //
  3542. {* True, if control is windowed (or is a form). Now always True, //
  3543. because KOL does not yet contain Graphic controls. } //
  3544. // //
  3545. fCtlClsNameChg: Boolean; //
  3546. {* True, if control class name changed and memory is allocated to store it. } //
  3547. fWndProcResizeFlicks: function( Self_: PControl; var Msg: TMsg; var Rslt: Integer ): Boolean; //
  3548. fGotoControl: function( Self_: PControl; Key: DWORD; CheckOnly: Boolean ): Boolean; //
  3549. fCtl3Dchild: Boolean; //
  3550. fCtl3D: Boolean; //
  3551. fTextColor: TColor; //
  3552. {* Color of text. Used instead of fFont.Color internally to //
  3553. avoid usage of Font object if user is not accessing and changing it. } //
  3554. fFont: PGraphicTool; //
  3555. fColor: TColor; //
  3556. {* Color of control background. } //
  3557. fBrush: PGraphicTool; //
  3558. fMargin: Integer; //
  3559. fBoundsRect: TRect; //
  3560. fClientTop, fClientBottom, fClientLeft, fClientRight: Integer; //
  3561. {* Store adjustment factor of ClientRect for some 'idiosincrasies' windows, //
  3562. such as Groupbox or Tabcontrol. } //
  3563. //_____________________________________________________________________________________________//
  3564. // this is the end of fiels set, which order is important
  3565. fDoubleBuffered: Boolean; //
  3566. fTransparent: Boolean; //
  3567. fOnMessage: TOnMessage;
  3568. fOldOnMessage: TOnMessage;
  3569. fOnClick: TOnEvent;
  3570. fRightClick: Boolean;
  3571. fCurrentControl: PControl;
  3572. fCreateVisible, fCreateHidden: Boolean;
  3573. fRadio1st, fRadioLast : THandle;
  3574. fDropDownProc: procedure( Sender : PObj );
  3575. fDropped: Boolean;
  3576. fCurIdxAtDrop: Integer;
  3577. fPrevWndProc: Pointer;
  3578. fClickDisabled: Byte;
  3579. fCurItem, fCurIndex: Integer;
  3580. FOnScroll: TOnScroll;
  3581. FScrollLineDist: array[ 0..1 ] of Integer;
  3582. fDefaultBtn: Boolean;
  3583. fCancelBtn: Boolean;
  3584. fDefaultBtnCtl: PControl;
  3585. fCancelBtnCtl: PControl;
  3586. fAllBtnReturnClick: Boolean;
  3587. fIgnoreDefault: Boolean;
  3588. fOnMouseDown: TOnMouse; // CAUTION!!! Order of mouse event handlers is important. ____
  3589. fOnMouseUp: TOnMouse; //
  3590. fOnMouseMove: TOnMouse; //
  3591. fOnMouseDblClk: TOnMouse; //
  3592. fOnMouseWheel: TOnMouse; //_____________________________________________________//
  3593. fOldDefWndProc: Pointer;
  3594. fOnChange: TOnEvent;
  3595. fOnEnter: TOnEvent;
  3596. FOnLVCustomDraw: TOnLVCustomDraw;
  3597. FOnSBBeforeScroll: TOnSBBeforeScroll;
  3598. FOnSBScroll: TOnSBScroll;
  3599. protected
  3600. procedure SetOnLVCustomDraw(const Value: TOnLVCustomDraw);
  3601. public
  3602. fCommandActions: TCommandActions;
  3603. protected
  3604. fOnChar: TOnChar;
  3605. fOnKeyUp: TOnKey;
  3606. fOnKeyDown: TOnKey;
  3607. fOnPaint: TOnPaint;
  3608. fOnPaint2: TOnPaint;
  3609. fPaintMsg: TMsg;
  3610. fOnPrepaint: TOnPaint;
  3611. fOnPostPaint: TOnPaint;
  3612. fPaintProc: TPaintProc;
  3613. FMaxWidth: Integer;
  3614. FMinWidth: Integer;
  3615. FMaxHeight: Integer;
  3616. FMinHeight: Integer;
  3617. fShadowDeep: Integer;
  3618. fStatusCtl: PControl;
  3619. fStatusWnd: HWnd;
  3620. fStatusTxt: PChar;
  3621. fColor1: TColor;
  3622. fColor2: TColor;
  3623. fLVColCount: Integer;
  3624. fLVOptions: TListViewOptions;
  3625. fLVStyle: TListViewStyle;
  3626. fOnEditLVITem: TOnEditLVItem;
  3627. fLVTextBkColor: TColor;
  3628. fLVItemHeight: Integer;
  3629. fOnDropDown: TOnEvent;
  3630. fOnCloseUp: TOnEvent;
  3631. fModalResult: Integer;
  3632. fModal: Integer;
  3633. fModalForm: PControl;
  3634. FAlign: TControlAlign;
  3635. fNotUseAlign: Boolean;
  3636. fDragCallback: TOnDrag;
  3637. fDragging: Boolean;
  3638. fDragStartPos: TPoint;
  3639. fMouseStartPos: TPoint;
  3640. fSplitStartPos: TPoint;
  3641. fSplitStartPos2: TPoint;
  3642. fSplitStartSize: Integer;
  3643. fSplitMinSize1, fSplitMinSize2: Integer;
  3644. fOnSplit: TOnSplit;
  3645. fSecondControl: PControl;
  3646. fOnSelChange: TOnEvent;
  3647. fTmpFont: PGraphicTool;
  3648. fRECharFormatRec: TCharFormat2;
  3649. fREError: Integer;
  3650. fREStream: PStream;
  3651. fREStrLoadLen: DWORD;
  3652. fREParaFmtRec: TParaFormat2;
  3653. FOnResize: TOnEvent;
  3654. fOnProgress: TOnEvent;
  3655. fCharFmtDeltaSz: Integer;
  3656. fParaFmtDeltaSz: Integer;
  3657. fREOvr: Boolean;
  3658. fReOvrDisable: Boolean;
  3659. fOnREInsModeChg: TOnEvent;
  3660. fREScrolling: Boolean;
  3661. fUpdCount: Integer;
  3662. fOnREOverURL: TOnEvent;
  3663. fOnREURLClick: TOnEvent;
  3664. fRECharArea: TRichFmtArea;
  3665. fBitBtnOptions : TBitBtnOptions;
  3666. fGlyphLayout : TGlyphLayout;
  3667. fGlyphBitmap : HBitmap;
  3668. fGlyphCount : Integer;
  3669. fGlyphWidth, fGlyphHeight: Integer;
  3670. fOnBitBtnDraw: TOnBitBtnDraw;
  3671. fFlat: Boolean;
  3672. fSizeRedraw: Boolean; {YS}
  3673. fOnMouseLeave: TOnEvent;
  3674. fOnMouseEnter: TOnEvent;
  3675. fOnTestMouseOver: TOnTestMouseOver;
  3676. fMouseInControl: Boolean;
  3677. fRepeatInterval: Integer;
  3678. fChecked: Boolean;
  3679. fPushed: Boolean;
  3680. fPrevFocusWnd: HWnd;
  3681. fOnTVBeginDrag: TOnTVBeginDrag;
  3682. fOnTVBeginEdit: TOnTVBeginEdit;
  3683. fOnTVEndEdit: TOnTVEndEdit;
  3684. fOnTVExpanded: TOnTVExpanded;
  3685. fOnTVExpanding: TOnTVExpanding;
  3686. fOnTVDelete: TOnTVDelete;
  3687. fOnDeleteLVItem: TOnDeleteLVItem;
  3688. fOnDeleteAllLVItems: TOnEvent;
  3689. fOnLVData: TOnLVData;
  3690. {$IFNDEF _FPC}
  3691. {$IFNDEF _D2}
  3692. fOnLVDataW: TOnLVDataW;
  3693. {$ENDIF _D2}
  3694. {$ENDIF _FPC}
  3695. fOnCompareLVItems: TOnCompareLVItems;
  3696. fOnColumnClick: TOnLVColumnClick;
  3697. fOnDrawItem: TOnDrawItem;
  3698. fOnMeasureItem: TOnMeasureItem;
  3699. fREUrl: String;
  3700. FMinimizeWnd: PControl;
  3701. FFixWidth: Integer;
  3702. FFixHeight: Integer;
  3703. FOnDropFiles: TOnDropFiles;
  3704. FOnHide: TOnEvent;
  3705. FOnShow: TOnEvent;
  3706. fOnEraseBkgnd: TOnPaint;
  3707. fCustomData: Pointer;
  3708. fCustomObj: PObj;
  3709. fOnTVSelChanging: TOnTVSelChanging;
  3710. fOnClose: TOnEventAccept;
  3711. fOnQueryEndSession: TOnEventAccept;
  3712. fCloseQueryReason: TCloseQueryReason;
  3713. //----- order of following 3 events important: //
  3714. fOnMinimize: TOnEvent; //
  3715. fOnMaximize: TOnEvent; //
  3716. fOnRestore: TOnEvent; //
  3717. //---------------------------------------------//
  3718. //fCreateParamsExt: procedure( Self_: PControl; var Params: TCreateParams );
  3719. fCreateWndExt: procedure( Sender: PControl );
  3720. fTBttCmd: PList;
  3721. fTBttTxt: PStrList;
  3722. fTBevents: PList; // events for TBAssignEvents
  3723. fTBBtnImgWidth: Integer; // custom toolbar bitmap width
  3724. FTBBtMinWidth: Integer;
  3725. FTBBtMaxWidth: Integer;
  3726. fGradientStyle: TGradientStyle;
  3727. fGradientLayout: TGradientLayout;
  3728. fVisibleWoParent: Boolean;
  3729. fTVRightClickSelect: Boolean;
  3730. FOnMove: TOnEvent;
  3731. FOnLVStateChange: TOnLVStateChange;
  3732. FOnLVDelete: TOnLVDelete;
  3733. fAutoSize: procedure( Self_: PControl );
  3734. fIsButton: Boolean;
  3735. fSizeGrip: Boolean;
  3736. fNotAvailable: Boolean;
  3737. FPressedMnemonic: DWORD;
  3738. FBitBtnDrawMnemonic: Boolean;
  3739. FBitBtnGetCaption: function( Self_: PControl; const S: String ): String;
  3740. FBitBtnExtDraw: procedure( Self_: PControl; DC: HDC; X, Y: Integer; const R: TRect;
  3741. const CapText, CapTxtOrig: String; Color: TColor );
  3742. FTextShiftX, FTextShiftY: Integer;
  3743. fNotifyChild: procedure( Self_, Child: PControl );
  3744. fScrollChildren: procedure( Self_: PControl );
  3745. fOnHelp: TOnHelp;
  3746. FOnDTPUserString: TDTParseInputEvent;
  3747. {$IFDEF USE_MHTOOLTIP}
  3748. {$DEFINE var}
  3749. {$I KOLMHToolTip}
  3750. {$UNDEF var}
  3751. {$DEFINE function}
  3752. {$I KOLMHToolTip}
  3753. {$UNDEF function}
  3754. {$ENDIF}
  3755. procedure Init; {-}virtual;{+}{++}(*override;*){--}
  3756. {* }
  3757. procedure InitParented( AParent: PControl ); virtual;
  3758. {* Initialization of visual object. }
  3759. procedure DestroyChildren;
  3760. {* Destroys children. Is called in destructor, and can be
  3761. called in descending classes as earlier as needed to
  3762. prevent problems of too late destroying of visuals. }
  3763. function GetParentWnd( NeedHandle: Boolean ): HWnd;
  3764. {* Returns handle of parent window. }
  3765. function GetParentWindow: HWnd;
  3766. {* }
  3767. procedure SetEnabled( Value: Boolean );
  3768. {* Changes Enabled property value. Overriden here to change enabling
  3769. status of a window. }
  3770. function GetEnabled: Boolean;
  3771. {* Returns True, if Enabled. Overriden here to obtain real window
  3772. state. }
  3773. procedure SetVisible( Value: Boolean );
  3774. {* Sets Visible property value. Overriden here to change visibility
  3775. of correspondent window. }
  3776. procedure Set_Visible( Value: Boolean );
  3777. {* }
  3778. function GetVisible: Boolean;
  3779. {* Returns True, if correspondent window is Visible. Overriden
  3780. to get visibility of real window, not just value stored in object. }
  3781. function Get_Visible: Boolean;
  3782. {* Returns True, if correspondent window is Visible, for forms and applet,
  3783. or if fVisible flag is set, for controls. }
  3784. procedure SetCtlColor( Value: TColor );
  3785. {* Sets TControl's Color property value. }
  3786. procedure SetBoundsRect( const Value: TRect );
  3787. {* Sets BoudsRect property value. }
  3788. function GetBoundsRect: TRect;
  3789. {* Returns bounding rectangle. }
  3790. function GetIcon: HIcon;
  3791. {* Returns Icon property. By default, if it is not set,
  3792. returns Icon property of an Applet. }
  3793. procedure CreateSubclass( var Params: TCreateParams; ControlClassName: PChar );
  3794. {* Can be used in descending classes to subclass window with given
  3795. standard Windows ControlClassName - must be called after
  3796. creating Params but before CreateWindow. Usually it is called
  3797. in overriden method CreateParams after calling of the inherited one. }
  3798. function UpdateWndStyles: PControl;
  3799. {* Updates fStyle, fExStyle, fClsStyle from window handle }
  3800. procedure SetOnChar(const Value: TOnChar);
  3801. {* }
  3802. procedure SetOnKeyDown(const Value: TOnKey);
  3803. {* }
  3804. procedure SetOnKeyUp(const Value: TOnKey);
  3805. {* }
  3806. procedure SetMouseDown(const Value: TOnMouse);
  3807. {* }
  3808. procedure SetMouseMove(const Value: TOnMouse);
  3809. {* }
  3810. procedure SetMouseUp(const Value: TOnMouse);
  3811. {* }
  3812. procedure SetMouseWheel(const Value: TOnMouse);
  3813. {* }
  3814. procedure SetMouseDblClk(const Value: TOnMouse);
  3815. {* }
  3816. procedure SetHelpContext( Value: Integer );
  3817. {* }
  3818. procedure SetOnTVDelete( const Value: TOnTVDelete );
  3819. {* }
  3820. procedure SetDefaultBtn(const Index: Integer; const Value: Boolean);
  3821. {$IFDEF F_P}
  3822. function GetDefaultBtn(const Index: Integer): Boolean;
  3823. {$ENDIF F_P}
  3824. function DefaultBtnProc( var Msg: TMsg; var Rslt: Integer ): Boolean;
  3825. {* }
  3826. procedure SetDateTime( Value: TDateTime );
  3827. function GetDateTime: TDateTime;
  3828. procedure SetDateTimeRange( Value: TDateTimeRange );
  3829. function GetDateTimeRange: TDateTimeRange;
  3830. procedure SetDateTimePickerColor( Index: TDateTimePickerColor; Value: TColor );
  3831. function GetDateTimePickerColor( Index: TDateTimePickerColor ): TColor;
  3832. procedure SetDateTimeFormat( const Value: String );
  3833. public
  3834. constructor CreateParented( AParent: PControl );
  3835. {* Creates new instance of TControl object, calling InitParented }
  3836. //FormPointer_DoNotUseItPlease_ItIsUsedByMCK: Pointer;
  3837. { ^ no more needed }
  3838. destructor Destroy; {-}virtual;{+}{++}(*override;*){--}
  3839. {* Destroyes object. First of all, destructors for all children
  3840. are called. }
  3841. function GetWindowHandle: HWnd;
  3842. {* Returns window handle. If window is not yet created,
  3843. method CreateWindow is called. }
  3844. procedure CreateChildWindows;
  3845. {* Enumerates all children recursively and calls CreateWindow for all
  3846. of these. }
  3847. property Parent: PControl read fParent write SetParent;
  3848. {* Parent of TParent object. Also must be of TParent type or derived from TParent. }
  3849. //property Tag: Integer read FTag write FTag; //--------- moved to TObj --------
  3850. {* User-defined pointer, which can contain any data or reference to
  3851. anywhere in memory (when used as a pointer).
  3852. }
  3853. function ChildIndex( Child: PControl ): Integer;
  3854. {* Returns index of given child. }
  3855. procedure MoveChild( Child: PControl; NewIdx: Integer );
  3856. {* Moves given Child into new position. }
  3857. property Enabled: Boolean read GetEnabled write SetEnabled;
  3858. {* Enabled usually used to decide if control can get keyboard focus
  3859. or been clicked by mouse. }
  3860. procedure EnableChildren( Enable, Recursive: Boolean );
  3861. {* Enables (Enable = TRUE) or disables (Enable = FALSE) all the children
  3862. of the control. If Recursive = TRUE then all the children of all the
  3863. children are enabled or disabled recursively. }
  3864. property Visible: Boolean read Get_Visible write SetVisible;
  3865. {* Obvious. }
  3866. property ToBeVisible: Boolean read GetToBeVisible;
  3867. {* Returns True, if a control is supposed to be visible when its
  3868. form is showing. Thus is, True is returned if either control
  3869. is Visible or hidden, but marked with flag fCreateHidden. }
  3870. property CreateVisible: Boolean read fCreateVisible write fCreateVisible;
  3871. {* False by default. If You want your form to be created visible and
  3872. flick due creation, set it to True. This does not affect size of
  3873. executable anyway. }
  3874. property Align: TControlAlign read FAlign write Set_Align;
  3875. {* Align style of a control. If this property is not used in your
  3876. application, there are no additional code added. Aligning of
  3877. controls is made in KOL like in VCL. To align controls when
  3878. initially create ones, use "transparent" function SetAlign
  3879. ("transparent" means that it returns @Self as a result).
  3880. |<br>
  3881. Note, that it is better not to align combobox caClient, caLeft or
  3882. caRight (better way is to place a panel with Border = 0 and
  3883. EdgeStyle = esNone, align it as desired and to place a combobox on it
  3884. aligning caTop or caBottom). Otherwise, big problems could be under
  3885. Win9x/Me, and some delay could occur under any other systems.
  3886. |<br> Do not attempt to align some kinds of controls (like combobox or
  3887. toolbar) caLeft or caRight, this can cause infinite recursion in the
  3888. application. }
  3889. property BoundsRect: TRect read GetBoundsRect write SetBoundsRect;
  3890. {* Bounding rectangle of the visual. Coordinates are relative
  3891. to top left corner of parent's ClientRect, or to top left corner
  3892. of screen (for TForm). }
  3893. property Left: Integer read GetLeft write SetLeft;
  3894. {* Left horizontal position. }
  3895. property Top: Integer read GetTop write SetTop;
  3896. {* Top vertical position. }
  3897. property Width: Integer read GetWidth write SetWidth;
  3898. {* Width of TVisual object. }
  3899. property Height: Integer read GetHeight write SetHeight;
  3900. {* Height of TVisual object. }
  3901. property Position: TPoint read GetPosition write Set_Position;
  3902. {* Represents top left position of the object. See also BoundsRect. }
  3903. property MinWidth: Integer index 0
  3904. {$IFDEF F_P} read GetConstraint
  3905. {$ELSE DELPHI} read FMinWidth
  3906. {$ENDIF F_P/DELPHI} write SetConstraint;
  3907. {* Minimal width constraint. }
  3908. property MinHeight: Integer index 1
  3909. {$IFDEF F_P} read GetConstraint
  3910. {$ELSE DELPHI} read FMinHeight
  3911. {$ENDIF F_P/DELPHI} write SetConstraint;
  3912. {* Minimal height constraint. }
  3913. property MaxWidth: Integer index 2
  3914. {$IFDEF F_P} read GetConstraint
  3915. {$ELSE DELPHI} read FMaxWidth
  3916. {$ENDIF F_P/DELPHI} write SetConstraint;
  3917. {* Maximal width constraint. }
  3918. property MaxHeight: Integer index 3
  3919. {$IFDEF F_P} read GetConstraint
  3920. {$ELSE DELPHI} read FMaxHeight
  3921. {$ENDIF F_P/DELPHI} write SetConstraint;
  3922. {* Maximal height constraint. }
  3923. function ClientRect: TRect;
  3924. {* Client rectangle of TControl. Contrary to VCL, for some
  3925. classes (e.g. for graphic controls) can be relative
  3926. not to itself, but to top left corner of the parent's ClientRect
  3927. rectangle. }
  3928. property ClientWidth: Integer read GetClientWidth write SetClientWidth;
  3929. {* Obvious. Accessing this property, program forces window latent creation. }
  3930. property ClientHeight: Integer read GetClientHeight write SetClientHeight;
  3931. {* Obvious. Accessing this property, program forces window latent creation. }
  3932. function ControlRect: TRect;
  3933. {* Absolute bounding rectangle relatively to nearest
  3934. Windowed parent client rectangle (at least to a form, but usually to
  3935. a Parent).
  3936. Useful while drawing on device context, provided by such
  3937. Windowed parent. For form itself is the same as BoundsRect. }
  3938. function ControlAtPos( X, Y: Integer; IgnoreDisabled: Boolean ): PControl;
  3939. {* Searches TVisual at the given position (relatively to top left
  3940. corner of the ClientRect). }
  3941. procedure Invalidate;
  3942. {* Invalidates rectangle, occupied by the visual (but only if Showing =
  3943. True). }
  3944. procedure InvalidateEx;
  3945. {* Invalidates the window and all its children. }
  3946. procedure InvalidateNC( Recursive: Boolean );
  3947. {* Invalidates the window and all its children including non-client area. }
  3948. procedure Update;
  3949. {* Updates control's window and calls Update for all child controls. }
  3950. procedure BeginUpdate;
  3951. {* |<#treeview>
  3952. |<#listview>
  3953. |<#richedit>
  3954. |<#memo>
  3955. |<#listbox>
  3956. Call this method to stop visual updates of the control until correspondent
  3957. EndUpdate called (pairs BeginUpdate - EndUpdate can be nested). }
  3958. procedure EndUpdate;
  3959. {* See BeginUpdate. }
  3960. property Windowed: Boolean read fWindowed;
  3961. {* Constantly returns True, if object is windowed (i.e. owns
  3962. correspondent window handle). Otherwise, returns False.
  3963. |<br>
  3964. By now, all the controls are windowed (there are no controls in KOL, which are
  3965. emulating window, acually belonging to Parent - like TGraphicControl
  3966. in VCL). }
  3967. function HandleAllocated: Boolean;
  3968. {* Returns True, if window handle is allocated. Has no sense for
  3969. non-Windowed objects (but now, the KOL has no non-Windowed controls). }
  3970. property MDIClient: PControl read fMDIClient;
  3971. {* For MDI forms only: returns MDI client window control, containng all MDI
  3972. children. Use this window to send specific messages to rule MDI children. }
  3973. property ChildCount: Integer read GetChildCount;//GetChildCountWOMembers;
  3974. {* Returns number of commonly accessed child objects (without
  3975. MembersCount). }
  3976. property Children[ Idx: Integer ]: PControl read GetMembers;
  3977. {* Child items of TVisual object. Property is reintroduced here
  3978. to separate access to always visible Children[] from restricted
  3979. a bit Members[]. }
  3980. property MembersCount: Integer read FMembersCount;
  3981. {* Returns number of "internal" child objects, which are
  3982. not accessible through common Children[] property. }
  3983. property Members[ Idx: Integer ]: PControl read GetMembers;
  3984. {* Members and children array of the object (first from 0 to
  3985. MembersCount-1 are Members[], and Children[] are followed by
  3986. them. Usually You do not need to use this list. Use instead
  3987. Children[0..ChildCount] property, Members[] is intended for
  3988. internal needs of XCL (and in KOL by now Members and Children
  3989. actually are the same properties). }
  3990. procedure PaintBackground( DC: HDC; Rect: PRect );
  3991. {* Is called to paint background in given rectangle. This
  3992. method is filling clipped area of the Rect rectangle with
  3993. Color, but only if global event Global_OnPaintBkgnd is
  3994. not assigned. If assigned, this one is called instead here.
  3995. |<br>&nbsp;&nbsp;&nbsp;
  3996. This method made public, so it can be called directly to
  3997. fill some device context's rectangle. But remember, that
  3998. independantly of Rect, top left corner of background piece
  3999. will be located so, if drawing is occure into ControlRect
  4000. rectangle. }
  4001. property WindowedParent: PControl read fParent;
  4002. {* Returns nearest windowed parent, the same as Parent. }
  4003. function ParentForm: PControl;
  4004. {* |<#form>
  4005. Returns parent form for a control (of @Self for form itself. }
  4006. property ActiveControl: PControl read fCurrentControl write fCurrentControl;
  4007. {* }
  4008. function Client2Screen( const P: TPoint ): TPoint;
  4009. {* Converts the client coordinates of a specified point to screen coordinates. }
  4010. function Screen2Client( const P: TPoint ): TPoint;
  4011. {* Converts screen coordinates of a specified point to client coordinates. }
  4012. function CreateWindow: Boolean; virtual;
  4013. {* |<#form>
  4014. Creates correspondent window object. Returns True if success (if
  4015. window is already created, False is returned). If applied to a form,
  4016. all child controls also allocates handles that time.
  4017. |<br>&nbsp;&nbsp;&nbsp;
  4018. Call this method to ensure, that a hanle is allocated for a form,
  4019. an application button or a control. (It is not necessary to do so in
  4020. the most cases, even if You plan to work with control's handle directly.
  4021. But immediately after creating the object, if You want to pass its
  4022. handle to API function, this can be helpful). }
  4023. procedure Close;
  4024. {* |<#appbutton>
  4025. |<#form>
  4026. Closes window. If a window is the main form, this closes application,
  4027. terminating it. Also it is possible to call Close method for Applet
  4028. window to stop application. }
  4029. {$IFDEF USE_MHTOOLTIP}
  4030. {$DEFINE public}
  4031. {$I KOLMHToolTip}
  4032. {$UNDEF public}
  4033. {$ENDIF}
  4034. property Handle: HWnd read fHandle; //GetHandle;
  4035. {* Returns descriptor of system window object. If window is not yet
  4036. created, 0 is returned. To allocate handle, call CreateWindow method. }
  4037. property ParentWindow: HWnd read GetParentWindow;
  4038. {* Returns handle of parent window (not TControl object, but system
  4039. window object handle). }
  4040. property ClsStyle: DWord read fClsStyle write SetClsStyle;
  4041. {* Window class style. Available styles are:
  4042. |<table border=0>
  4043. |&L=<tr><td valign=top><font face=Fixedsys>%1</font></td><td>
  4044. |&E=</td></tr>
  4045. |&N=<br>&nbsp;&nbsp;&nbsp;
  4046. <L CS_BYTEALIGNCLIENT> - Aligns the window's client area on the byte boundary
  4047. (in the x direction) to enhance performance during
  4048. drawing operations. <E>
  4049. <L CS_BYTEALIGNWINDOW> - Aligns a window on a byte boundary (in the x
  4050. direction). <E>
  4051. <L CS_CLASSDC> - Allocates one device context to be shared by all
  4052. windows in the class. <E>
  4053. <L CS_DBLCLKS> - Sends double-click messages to the window
  4054. procedure when the user double-clicks the mouse while the
  4055. cursor is within a window belonging to the class. <E>
  4056. <L CS_GLOBALCLASS> - Allows an application to create a window of
  4057. the class regardless of the value of the hInstance parameter.
  4058. <N> You can create a global class by creating
  4059. the window class in a dynamic-link library (DLL) and listing the
  4060. name of the DLL in the registry under specific keys. <E>
  4061. <L CS_HREDRAW> - Redraws the entire window if a movement or
  4062. size adjustment changes the width of the client area. <E>
  4063. <L CS_NOCLOSE> - Disables the Close command on the System menu. <E>
  4064. <L CS_OWNDC> - Allocates a unique device context for each window
  4065. in the class. <E>
  4066. <L CS_PARENTDC> - Sets the clipping region of the child window to
  4067. that of the parent window so that the child can draw on the parent. <E>
  4068. <L CS_SAVEBITS> - Saves, as a bitmap, the portion of the screen
  4069. image obscured by a window. Windows uses the saved bitmap to re-create
  4070. the screen image when the window is removed. <E>
  4071. <L CS_VREDRAW> - Redraws the entire window if a movement or size
  4072. adjustment changes the height of the client area. <E>
  4073. |</table> For more info, see Win32.hlp (keyword 'WndClass');
  4074. }
  4075. property Style: DWord read fStyle write SetStyle;
  4076. {* Window styles. Available styles are:
  4077. |<table border=0>
  4078. <L WS_BORDER> Creates a window that has a thin-line border. <E>
  4079. <L WS_CAPTION> Creates a window that has a title bar (includes the
  4080. WS_BORDER style). <E>
  4081. <L WS_CHILD> Creates a child window. This style cannot be used with
  4082. the WS_POPUP style. <E>
  4083. <L WS_CHILDWINDOW> Same as the WS_CHILD style. <E>
  4084. <L WS_CLIPCHILDREN> Excludes the area occupied by child windows
  4085. when drawing occurs within the parent window. This style is used
  4086. when creating the parent window. <E>
  4087. <L WS_CLIPSIBLINGS> Clips child windows relative to each other;
  4088. that is, when a particular child window receives a WM_PAINT message,
  4089. the WS_CLIPSIBLINGS style clips all other overlapping child windows
  4090. out of the region of the child window to be updated. If
  4091. WS_CLIPSIBLINGS is not specified and child windows overlap, it is
  4092. possible, when drawing within the client area of a child window,
  4093. to draw within the client area of a neighboring child window. <E>
  4094. <L WS_DISABLED> Creates a window that is initially disabled. A
  4095. disabled window cannot receive input from the user. <E>
  4096. <L WS_DLGFRAME> Creates a window that has a border of a style
  4097. typically used with dialog boxes. A window with this style cannot
  4098. have a title bar. <E>
  4099. <L WS_GROUP> Specifies the first control of a group of controls.
  4100. The group consists of this first control and all controls defined
  4101. after it, up to the next control with the WS_GROUP style.
  4102. The first control in each group usually has the WS_TABSTOP
  4103. style so that the user can move from group to group. The user
  4104. can subsequently change the keyboard focus from one control in
  4105. the group to the next control in the group by using the direction
  4106. keys. <E>
  4107. <L WS_HSCROLL> Creates a window that has a horizontal scroll bar. <E>
  4108. <L WS_ICONIC> Creates a window that is initially minimized. Same as
  4109. the WS_MINIMIZE style. <E>
  4110. <L WS_MAXIMIZE> Creates a window that is initially maximized. <E>
  4111. <L WS_MAXIMIZEBOX> Creates a window that has a Maximize button.
  4112. Cannot be combined with the WS_EX_CONTEXTHELP style. The WS_SYSMENU
  4113. style must also be specified. <E>
  4114. <L WS_MINIMIZE> Creates a window that is initially minimized.
  4115. Same as the WS_ICONIC style. <E>
  4116. <L WS_MINIMIZEBOX> Creates a window that has a Minimize button.
  4117. Cannot be combined with the WS_EX_CONTEXTHELP style. The WS_SYSMENU
  4118. style must also be specified. <E>
  4119. <L WS_OVERLAPPED> Creates an overlapped window. An overlapped
  4120. window has a title bar and a border. Same as the WS_TILED style. <E>
  4121. <L WS_OVERLAPPEDWINDOW> Creates an overlapped window with the
  4122. WS_OVERLAPPED, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX,
  4123. and WS_MAXIMIZEBOX styles. Same as the WS_TILEDWINDOW style. <E>
  4124. <L WS_POPUP> Creates a pop-up window. This style cannot be used with
  4125. the WS_CHILD style. <E>
  4126. <L WS_POPUPWINDOW> Creates a pop-up window with WS_BORDER,
  4127. WS_POPUP, and WS_SYSMENU styles. The WS_CAPTION and WS_POPUPWINDOW
  4128. styles must be combined to make the window menu visible. <E>
  4129. <L WS_SIZEBOX> Creates a window that has a sizing border. Same as the
  4130. WS_THICKFRAME style. <E>
  4131. <L WS_SYSMENU> Creates a window that has a window-menu on its title
  4132. bar. The WS_CAPTION style must also be specified. <E>
  4133. <L WS_TABSTOP> Specifies a control that can receive the keyboard focus
  4134. when the user presses the TAB key. Pressing the TAB key changes
  4135. the keyboard focus to the next control with the WS_TABSTOP style. <E>
  4136. <L WS_THICKFRAME> Creates a window that has a sizing border.
  4137. Same as the WS_SIZEBOX style. <E>
  4138. <L WS_TILED> Creates an overlapped window. An overlapped window has
  4139. a title bar and a border. Same as the WS_OVERLAPPED style. <E>
  4140. <L WS_TILEDWINDOW> Creates an overlapped window with the
  4141. WS_OVERLAPPED, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME,
  4142. WS_MINIMIZEBOX, and WS_MAXIMIZEBOX styles. Same as the
  4143. WS_OVERLAPPEDWINDOW style. <E>
  4144. <L WS_VISIBLE> Creates a window that is initially visible. <E>
  4145. <L WS_VSCROLL> Creates a window that has a vertical scroll bar. <E>
  4146. |</table>
  4147. See also Win32.hlp (topic CreateWindow).
  4148. }
  4149. property ExStyle: DWord read fExStyle write SetExStyle;
  4150. {* Extra window styles. Available flags are following:
  4151. |<table border=0>
  4152. <L WS_EX_ACCEPTFILES> Specifies that a window created with this style
  4153. accepts drag-drop files. <E>
  4154. <L WS_EX_APPWINDOW> Forces a top-level window onto the taskbar
  4155. when the window is minimized. <E>
  4156. <L WS_EX_CLIENTEDGE> Specifies that a window has a border with a
  4157. sunken edge. <E>
  4158. <L WS_EX_CONTEXTHELP> Includes a question mark in the title bar of
  4159. the window. When the user clicks the question mark, the cursor
  4160. changes to a question mark with a pointer. If the user then clicks
  4161. a child window, the child receives a WM_HELP message. The child
  4162. window should pass the message to the parent window procedure,
  4163. which should call the WinHelp function using the HELP_WM_HELP
  4164. command. The Help application displays a pop-up window that
  4165. typically contains help for the child window.WS_EX_CONTEXTHELP
  4166. cannot be used with the WS_MAXIMIZEBOX or WS_MINIMIZEBOX styles. <E>
  4167. <L WS_EX_CONTROLPARENT> Allows the user to navigate among the child
  4168. windows of the window by using the TAB key. <E>
  4169. <L WS_EX_DLGMODALFRAME> Creates a window that has a double border;
  4170. the window can, optionally, be created with a title bar by
  4171. specifying the WS_CAPTION style in the dwStyle parameter. <E>
  4172. <L WS_EX_LEFT> Window has generic "left-aligned" properties. This
  4173. is the default. <E>
  4174. <L WS_EX_LEFTSCROLLBAR> If the shell language is Hebrew, Arabic, or
  4175. another language that supports reading order alignment, the
  4176. vertical scroll bar (if present) is to the left of the client
  4177. area. For other languages, the style is ignored and not treated
  4178. as an error. <E>
  4179. <L WS_EX_LTRREADING> The window text is displayed using Left to
  4180. Right reading-order properties. This is the default. <E>
  4181. <L WS_EX_MDICHILD> Creates an MDI child window. <E>
  4182. <L WS_EX_NOPARENTNOTIFY> Specifies that a child window created
  4183. with this style does not send the WM_PARENTNOTIFY message to its
  4184. parent window when it is created or destroyed. <E>
  4185. <L WS_EX_OVERLAPPEDWINDOW> Combines the WS_EX_CLIENTEDGE and
  4186. WS_EX_WINDOWEDGE styles. <E>
  4187. <L WS_EX_PALETTEWINDOW> Combines the WS_EX_WINDOWEDGE,
  4188. WS_EX_TOOLWINDOW, and WS_EX_TOPMOST styles. <E>
  4189. <L WS_EX_RIGHT> Window has generic "right-aligned" properties.
  4190. This depends on the window class. This style has an effect only
  4191. if the shell language is Hebrew, Arabic, or another language that
  4192. supports reading order alignment; otherwise, the style is
  4193. ignored and not treated as an error. <E>
  4194. <L WS_EX_RIGHTSCROLLBAR> Vertical scroll bar (if present) is to the
  4195. right of the client area. This is the default. <E>
  4196. <L WS_EX_RTLREADING> If the shell language is Hebrew, Arabic, or
  4197. another language that supports reading order alignment, the
  4198. window text is displayed using Right to Left reading-order
  4199. properties. For other languages, the style is ignored and not
  4200. treated as an error. <E>
  4201. <L WS_EX_STATICEDGE> Creates a window with a three-dimensional
  4202. border style intended to be used for items that do not accept
  4203. user input. <E>
  4204. <L WS_EX_TOOLWINDOW> Creates a tool window; that is, a window
  4205. intended to be used as a floating toolbar. A tool window has
  4206. a title bar that is shorter than a normal title bar, and the
  4207. window title is drawn using a smaller font. A tool window does
  4208. not appear in the taskbar or in the dialog that appears when
  4209. the user presses ALT+TAB. <E>
  4210. <L WS_EX_TOPMOST> Specifies that a window created with this style
  4211. should be placed above all non-topmost windows and should stay
  4212. above them, even when the window is deactivated. To add or remove
  4213. this style, use the SetWindowPos function. <E>
  4214. <L WS_EX_TRANSPARENT> Specifies that a window created with this
  4215. style is to be transparent. That is, any windows that are
  4216. beneath the window are not obscured by the window. A window
  4217. created with this style receives WM_PAINT messages only after
  4218. all sibling windows beneath it have been updated. <E>
  4219. <L WS_EX_WINDOWEDGE> Specifies that a window has a border with
  4220. a raised edge. <E>
  4221. |</table>
  4222. See also Win32.hlp (topic CreateWindowEx).
  4223. }
  4224. property Cursor: HCursor read fCursor write SetCursor;
  4225. {* Current cursor. For most of controls, sets initially to IDC_ARROW. See
  4226. also ScreenCursor. }
  4227. procedure CursorLoad( Inst: Integer; ResName: PChar );
  4228. {* Loads Cursor from the resource. See also comments for Icon property. }
  4229. property Icon: HIcon read GetIcon write SetIcon;
  4230. {* |<#appbutton>
  4231. |<#form>
  4232. Icon. By default, icon of the Applet is used. To load icon from the
  4233. resource, use IconLoad or IconLoadCursor method - this is more correct, because
  4234. in such case a special flag is set to prevent attempts to destroy
  4235. shared icon object in the destructor of the control. }
  4236. procedure IconLoad( Inst: Integer; ResName: PChar );
  4237. {* |<#appbutton>
  4238. |<#form>
  4239. See Icon property. }
  4240. procedure IconLoadCursor( Inst: Integer; ResName: PChar );
  4241. {* |<#appbutton>
  4242. |<#form>
  4243. Loads Icon from the cursor resource. See also Icon property. }
  4244. property Menu: HMenu read fMenu write SetMenu;
  4245. {* Menu (or ID of control - for standard GUI controls). }
  4246. property HelpContext: Integer read fHelpContext write SetHelpContext;
  4247. {* Help context. }
  4248. function AssignHelpContext( Context: Integer ): PControl;
  4249. {* Assigns HelpContext and returns @ Self (can be used in initialization
  4250. of a control in a chain of "transparent" calls). }
  4251. procedure CallHelp( Context: Integer; CtxCtl: PControl {; CtlID: Integer} );
  4252. {* Method of a form or Applet. Call it to show help with the given context
  4253. ID. If the Context = 0, help contents is displayed. By default,
  4254. WinHelp is used. To allow using HtmlHelp, call AssignHtmlHelp global
  4255. function. When WinHelp used, HelpPath variable can be assigned directly.
  4256. If HelpPath variable is not assigned, application name
  4257. (and path) is used, with extension replaced to '.hlp'. }
  4258. property HelpPath: String read GetHelpPath write SetHelpPath;
  4259. {* Property of a form or an Applet. Change it to provide custom path to
  4260. WinHelp format help file. If HtmlHelp used, call global procedure
  4261. AssignHtmlHelp instead. }
  4262. property OnHelp: TOnHelp read fOnHelp write fOnHelp;
  4263. {* An event of a form, it is called when F1 pressed or help topic requested
  4264. by any other way. To prevent showing help, nullify Sender. Set Popup to
  4265. TRUE to provide showing help in a pop-up window. It is also possible to
  4266. change Context dynamically. }
  4267. property Caption: String read GetCaption write SetCaption;
  4268. {* |<#appbutton>
  4269. |<#form>
  4270. |<#button>
  4271. |<#bitbtn>
  4272. |<#label>
  4273. |<#wwlabel>
  4274. |<#3dlabel>
  4275. Caption of a window. For standard Windows buttons, labels and so on
  4276. not a caption of a window, but text of the window. }
  4277. property Text: String read GetCaption write SetCaption;
  4278. {* |<#edit>
  4279. |<#memo>
  4280. The same as Caption. To make more convenient with Edit controls. For
  4281. Rich Edit control, use property RE_Text. }
  4282. property SelStart: Integer read GetSelStart write SetSelStart;
  4283. {* |<#edit>
  4284. |<#memo>
  4285. |<#richedit>
  4286. |<#listbox>
  4287. |<#combo>
  4288. Start of selection (editbox - character position, listbox and combobox -
  4289. index of [the first] selected item). }
  4290. property SelLength: Integer read GetSelLength write SetSelLength;
  4291. {* |<#edit>
  4292. |<#memo>
  4293. |<#richedit>
  4294. |<#listbox>
  4295. |<#listview>
  4296. Length of selection (editbox - number of characters selected, multiline
  4297. listbox - number of items selected). }
  4298. property Selection: String read GetSelection write SetSelection;
  4299. {* |<#edit>
  4300. |<#memo>
  4301. |<#richedit>
  4302. Selected text (editbox, richedit) as string. Can be useful to replace
  4303. selection. For rich edit, use RE_Text[ reText, TRUE ], if you want to
  4304. read correctly characters from another locale then ANSI only. }
  4305. procedure SelectAll;
  4306. {* |<#edit>
  4307. |<#memo>
  4308. |<#richedit>
  4309. Makes all the text in editbox or RichEdit, or all items in listbox
  4310. selected. }
  4311. procedure ReplaceSelection( const Value: String; aCanUndo: Boolean );
  4312. {* |<#edit>
  4313. |<#memo>
  4314. |<#richedit>
  4315. Replaces selection (in edit, RichEdit). Unlike assigning new value
  4316. to Selection property, it is possible to specify, if operation can
  4317. be undone. }
  4318. procedure DeleteLines( FromLine, ToLine: Integer );
  4319. {* |<#edit>
  4320. |<#memo>
  4321. |<#richedit>
  4322. Deletes lines from FromLine to ToLine (inclusively, i.e. 0 to 0 deletes
  4323. one line with index 0). Current selection is restored as possible. }
  4324. property CurIndex: Integer read GetCurIndex write SetCurIndex;
  4325. {* |<#listbox>
  4326. |<#combo>
  4327. |<#toolbar>
  4328. Index of current item (for listbox, combobox) or button index pressed
  4329. or dropped down (for toolbar button, and only in appropriate event
  4330. handler call).
  4331. |<br>
  4332. You cannot use it to set or remove a selection in a multiple-selection
  4333. list box, so you should set option loNoExtendSel to true.
  4334. |<br>
  4335. In OnClick event handler, CurIndex has not yet changed. Use OnSelChange
  4336. to respond to selection changes. }
  4337. property Count: Integer read GetItemsCount write SetItemsCount;
  4338. {* |<#listbox>
  4339. |<#combo>
  4340. |<#listview>
  4341. |<#treeview>
  4342. |<#edit>
  4343. |<#memo>
  4344. |<#richedit>
  4345. |<#toolbar>
  4346. Number of items (listbox, combobox, listview) or lines (multiline
  4347. editbox, richedit control) or buttons (toolbar). It is possible to
  4348. assign a value to this property only for listbox control with loNoData
  4349. style and for list view control with lvoOwnerData style (virtual list
  4350. box and list view). }
  4351. property Items[ Idx: Integer ]: String read GetItems write SetItems;
  4352. {* |<#edit>
  4353. |<#listbox>
  4354. |<#combo>
  4355. |<#memo>
  4356. |<#richedit>
  4357. Obvious. Used with editboxes, listbox, combobox. With list view, use
  4358. property LVItems instead. }
  4359. function Item2Pos( ItemIdx: Integer ): Integer;
  4360. {* |<#edit>
  4361. |<#memo>
  4362. Only for edit controls: converts line index to character position. }
  4363. function Pos2Item( Pos: Integer ): Integer;
  4364. {* |<#edit>
  4365. |<#memo>
  4366. Only for edit controls: converts character position to line index. }
  4367. function EditTabChar: PControl;
  4368. {* |<#edit>
  4369. |<#memo>
  4370. Call this method (once) to provide insertion of tab character (code #9)
  4371. when tab key is pressed on keyboard. }
  4372. function IndexOf( const S: String ): Integer;
  4373. {* |<#listbox>
  4374. |<#combobox>
  4375. |<#tabcontrol>
  4376. Works for the most of control types, though some of those
  4377. have its own methods to search given item. If a control is not
  4378. list box or combobox, item is finding by enumerating all
  4379. the Items one by one. See also SearchFor method. }
  4380. function SearchFor( const S: String; StartAfter: Integer; Partial: Boolean ): Integer;
  4381. {* |<#listbox>
  4382. |<#combobox>
  4383. |<#tabcontrol>
  4384. Works for the most of control types, though some of those
  4385. have its own methods to search given item. If a control is not
  4386. list box or combobox, item is finding by enumerating all
  4387. the Items one by one. See also IndexOf method. }
  4388. property ItemSelected[ ItemIdx: Integer ]: Boolean read GetItemSelected write SetItemSelected;
  4389. {* |<#edit>
  4390. |<#memo>
  4391. |<#listbox>
  4392. |<#combo>
  4393. Returns True, if a line (in editbox) or an item (in listbox, combobox) is
  4394. selected.
  4395. Can be set only for listboxes. For listboxes, which are not multiselect, and
  4396. for combo lists, it is possible only to set to True, to change selection. }
  4397. property ItemData[ Idx: Integer ]: DWORD read GetItemData write SetItemData;
  4398. {* |<#listbox>
  4399. |<#combo>
  4400. Access to user-defined data, associated with the item of a list box and
  4401. combo box. }
  4402. property OnDropDown: TOnEvent read fOnDropDown write fOnDropDown;
  4403. {* |<#combo>
  4404. |<#toolbar>
  4405. Is called when combobox is dropped down (or drop-down button of
  4406. toolbar is pressed - see also OnTBDropDown). }
  4407. property OnCloseUp: TOnEvent read fOnCloseUp write fOnCloseUp;
  4408. {* |<#combo>
  4409. Is called when combobox is closed up. When drop down list is closed
  4410. because user pressed "Escape" key, previous selection is restored.
  4411. To test if it is so, call GetKeyState( VK_ESCAPE ) and check, if
  4412. negative value is returned (i.e. Escape key is pressed when event
  4413. handler is calling). }
  4414. property DroppedWidth: Integer read FDroppedWidth write SetDroppedWidth;
  4415. {* |<#combo>
  4416. Allows to change width of dropped down items list for combobox (only!)
  4417. control. }
  4418. property DroppedDown: Boolean read fDropped write SetDroppedDown;
  4419. {* |<#combo>
  4420. Dropped down state for combo box. Set it to TRUE or FALSE to change
  4421. dropped down state. }
  4422. procedure AddDirList( const Filemask: String; Attrs: DWORD );
  4423. {* |<#listbox>
  4424. |<#combo>
  4425. Can be used only with listbox and combobox - to add directory list items,
  4426. filtered by given Filemask (can contain wildcards) and Attrs. Following
  4427. flags can be combined in Attrs:
  4428. |<table border=0>
  4429. |&L=<tr><td>%1</td><td>
  4430. <L DDL_ARCHIVE> Include archived files. <E>
  4431. <L DDL_DIRECTORY> Includes subdirectories. Subdirectory names are
  4432. enclosed in square brackets ([ ]). <E>
  4433. <L DDL_DRIVES> Includes drives. Drives are listed in the form [-x-],
  4434. where x is the drive letter. <E>
  4435. <L DDL_EXCLUSIVE> Includes only files with the specified attributes.
  4436. By default, read-write files are listed even if DDL_READWRITE is
  4437. not specified. Also, this flag needed to list directories only,
  4438. etc. <E>
  4439. <L DDL_HIDDEN> Includes hidden files. <E>
  4440. <L DDL_READONLY> Includes read-only files. <E>
  4441. <L DDL_READWRITE> Includes read-write files with no additional
  4442. attributes. <E>
  4443. <L DDL_SYSTEM> Includes system files. <E>
  4444. </table>
  4445. If the listbox is sorted, directory items will be sorted (alpabetically). }
  4446. property OnBitBtnDraw: TOnBitBtnDraw read fOnBitBtnDraw write fOnBitBtnDraw;
  4447. {* |<#bitbtn>
  4448. Special event for BitBtn. Using it, it is possible to provide
  4449. additional effects, such as highlighting button text (by changing
  4450. its Font and other properties). If the handler returns True, it is
  4451. supposed that it made all drawing and there are no further drawing
  4452. occure. }
  4453. property BitBtnDrawMnemonic: Boolean read FBitBtnDrawMnemonic write SetBitBtnDrawMnemonic;
  4454. {* |<#bitbtn>
  4455. Set this property to TRUE to provide correct drawing of bit btn control
  4456. caption with '&' characters (to remove such characters, and underline
  4457. follow ones). }
  4458. property TextShiftX: Integer read fTextShiftX write fTextShiftX;
  4459. {* |<#bitbtn>
  4460. Horizontal shift for bitbtn text when the bitbtn is pressed. }
  4461. property TextShiftY: Integer read fTextShiftY write fTextShiftY;
  4462. {* |<#bitbtn>
  4463. Vertical shift for bitbtn text when the bitbtn is pressed. }
  4464. property BitBtnImgIdx: Integer read GetBitBtnImgIdx write SetBitBtnImgIdx;
  4465. {* |<#bitbtn>
  4466. BitBtn image index for the first image in list view, used as bitbtn
  4467. image. It is used only in case when BitBtn is created with bboImageList
  4468. option. }
  4469. property BitBtnImgList: THandle read GetBitBtnImageList write SetBitBtnImageList;
  4470. {* |<#bitbtn>
  4471. BitBtn Image list. Assign image list handle to change it. }
  4472. function SetButtonIcon( aIcon: HIcon ): PControl;
  4473. {* |<#button>
  4474. Sets up button icon image and changes its styles. Returns button itself. }
  4475. function SetButtonBitmap( aBmp: HBitmap ): PControl;
  4476. {* |<#button>
  4477. Sets up button icon image and changes its styles. Returns button itself. }
  4478. property OnMeasureItem: TOnMeasureItem read fOnMeasureItem write SetOnMeasureItem;
  4479. {* |<#combo>
  4480. |<#listbox>
  4481. |<#listview>
  4482. This event is called for owner-drawn controls, such as list box, combo box,
  4483. list view with appropriate owner-drawn style. For fixed item height controls
  4484. (list box with loOwnerDrawFixed style, combobox with coOwnerDrawFixed and
  4485. list view with lvoOwnerDrawFixed option) this event is called once. For
  4486. list box with loOwnerDrawVariable style and for combobox with coOwnerDrawVariable
  4487. style this event is called for every item. }
  4488. property DefaultBtn: Boolean index 13
  4489. {$IFDEF F_P} read GetDefaultBtn
  4490. {$ELSE DELPHI} read fDefaultBtn
  4491. {$ENDIF F_P/DELPHI} write SetDefaultBtn;
  4492. {* |<#button>
  4493. |<#bitbtn>
  4494. Set this property to true to make control clicked when ENTER key is pressed.
  4495. This property uses OnMessage event of the parent form, storing it into
  4496. fOldOnMessage field and calling in chain. So, assign default button
  4497. after setting OnMessage event for the form. }
  4498. property CancelBtn: Boolean index 27
  4499. {$IFDEF F_P} read GetDefaultBtn
  4500. {$ELSE DELPHI} read fCancelBtn
  4501. {$ENDIF F_P/DELPHI} write SetDefaultBtn;
  4502. {* |<#button>
  4503. |<#bitbtn>
  4504. Set this property to true to make control clicked when escape key is pressed.
  4505. This property uses OnMessage event of the parent form, storing it into
  4506. fOldOnMessage field and calling in chain. So, assign cancel button
  4507. after setting OnMessage event for the form. }
  4508. function AllBtnReturnClick: PControl;
  4509. {* Call this method for a form or any its control to provide clicking
  4510. a focused button when ENTER pressed. By default, a button can be clicked
  4511. only by SPACE key from the keyboard, or by mouse. }
  4512. property IgnoreDefault: Boolean read fIgnoreDefault write fIgnoreDefault;
  4513. {* Change this property to TRUE to ignore default button reaction on
  4514. press ENTER key when a focus is grabbed of the control. Default
  4515. value is different for different controls. By default, DefaultBtn
  4516. ignored in memo, richedit (even if read-only). }
  4517. property Color: TColor read fColor write SetCtlColor;
  4518. {* Property Color is one of the most common for all visual
  4519. elements (like form, control etc.) Please note, that standard GUI button
  4520. can not change its color and the most characteristics of the Font. Also,
  4521. standard button can not become Transparent. Use bitbtn for such purposes.
  4522. Also, changing Color property for some kinds of control has no effect (rich edit,
  4523. list view, tree view, etc.). To solve this, use native (for such controls)
  4524. color property, or call Perform method with appropriate message to set the
  4525. background color. }
  4526. property Font: PGraphicTool read GetFont;
  4527. {* If the Font property is not accessed, correspondent TGraphicTool object
  4528. is not created and its methods are not included into executable. Leaving
  4529. properties Font and Brush untouched can economy executable size a lot. }
  4530. property Brush: PGraphicTool read GetBrush;
  4531. {* If not accessed, correspondent TGraphicTool object is not created
  4532. and its methods are not referenced. See also note on Font property. }
  4533. property Ctl3D: Boolean read fCtl3D write SetCtl3D;
  4534. {* Inheritable from parent controls to child ones. }
  4535. procedure Show;
  4536. {* |<#appbutton>
  4537. |<#form>
  4538. Makes control visible and activates it. }
  4539. function ShowModal: Integer;
  4540. {* |<#form>
  4541. Can be used only with a forms to show it modal. See also global function
  4542. ShowMsgModal.
  4543. |<br>
  4544. To use a form as a modal, it is possible to make it either auto-created
  4545. or dynamically created. For a first case, You (may be prefer to hide a
  4546. form after showing it as a modal:
  4547. !
  4548. ! procedure TForm1.Button1Click( Sender: PObj );
  4549. ! begin
  4550. ! Form2.Form.ShowModal;
  4551. ! Form2.Form.Hide;
  4552. ! end;
  4553. !
  4554. Another way is to create modal form just before showing it (this economies
  4555. system resources):
  4556. !
  4557. ! procedure TForm1.Button1Click( Sender: PObj );
  4558. ! begin
  4559. ! NewForm2( Form2, Applet );
  4560. ! Form2.Form.ShowModal;
  4561. ! Form2.Form.Free; // Never call Form2.Free or Form2.Form.Close
  4562. ! end; // but always Form2.Form.Free; (!)
  4563. !
  4564. In samples above, You certainly can place any wished code before and after
  4565. calling ShowModal method.
  4566. |<br>
  4567. Do not forget that if You have more than a single form in your project,
  4568. separate Applet object should be used.
  4569. |<br>
  4570. See also ShowModalEx.
  4571. }
  4572. function ShowModalParented( const AParent: PControl ): Integer;
  4573. {* by Alexander Pravdin. The same as ShowModal, but with a certain
  4574. form as a parent. }
  4575. function ShowModalEx: Integer;
  4576. {* The same as ShowModal, but all the windows of current thread are
  4577. disabled while showing form modal. This is useful if KOL form from
  4578. a DLL is used modally in non-KOL application. }
  4579. property ModalResult: Integer read fModalResult write
  4580. {$IFDEF USE_SETMODALRESULT}
  4581. SetModalResult;
  4582. {$ELSE}
  4583. fModalResult;
  4584. {$ENDIF}
  4585. {* |<#form>
  4586. Modal result. Set it to value<>0 to stop modal dialog. By agreement,
  4587. value 1 corresponds 'OK', 2 - 'Cancel'. But it is totally by decision
  4588. of yours how to interpret this value. }
  4589. property Modal: Boolean read GetModal;
  4590. {* |<#form>
  4591. TRUE, if the form is shown modal. }
  4592. property ModalForm: PControl read fModalForm write fModalForm;
  4593. {* |<#form>
  4594. |<#appbutton>
  4595. Form currently shown modal from this form or from Applet. }
  4596. procedure Hide;
  4597. {* |<#appbutton>
  4598. |<#form>
  4599. Makes control hidden. }
  4600. property OnShow: TOnEvent read FOnShow write SetOnShow;
  4601. {* Is called when a control or form is to be shown. This event is not fired
  4602. for a form, if its WindowState initially is set to wsMaximized or
  4603. wsMinimized. This behaviour is by design (the window does not receive
  4604. WM_SHOW message in such case). }
  4605. property OnHide: TOnEvent read FOnHide write SetOnHide;
  4606. {* Is called when a control or form becomes hidden. }
  4607. property WindowState: TWindowState read GetWindowState write SetWindowState;
  4608. {* |<#form>
  4609. Window state. }
  4610. property Canvas: PCanvas read GetCanvas;
  4611. {* |<#paintbox>
  4612. Placeholder for Canvas: PCanvas. But in KOL, it is possible to
  4613. create applets without canvases at all. To do so, avoid using
  4614. Canvas and use DC directly (which is passed in OnPaint event). }
  4615. function CallDefWndProc( var Msg: TMsg ): Integer;
  4616. {* Function to be called in WndProc method to redirect message handling
  4617. to default window procedure. }
  4618. function DoSetFocus: Boolean;
  4619. {* Sets focus for Enabled window. Returns True, if success. }
  4620. procedure MinimizeNormalAnimated;
  4621. {* |<#form>
  4622. Apply this method to a main form (not to another form or Applet,
  4623. even when separate Applet control is not used and main form matches it!).
  4624. This provides normal animated visual minimization for the application.
  4625. It therefore has no effect, if animation during minimize/resore is
  4626. turned off by user. }
  4627. property OnMessage: TOnMessage read fOnMessage write fOnMessage;
  4628. {* |<#appbutton>
  4629. |<#form>
  4630. Is called for every message processed by TControl object. And for
  4631. Applet window, this event is called also for all messages, handled by
  4632. all its child windows (forms). }
  4633. function IsMainWindow: Boolean;
  4634. {* |<#appbutton>
  4635. |<#form>
  4636. Returns True, if a window is the main in application (created first
  4637. after the Applet, or matches the Applet). }
  4638. property IsApplet: Boolean read FIsApplet;
  4639. {* Returns true, if the control is created using NewApplet (or CreateApplet).
  4640. }
  4641. property IsForm: Boolean read fIsForm;
  4642. {* Returns True, if the object is form window. }
  4643. property IsMDIChild: Boolean read fIsMDIChild;
  4644. {* Returns TRUE, if the object is MDI child form. In such case, IsForm also
  4645. returns TRUE. }
  4646. property IsControl: Boolean read fIsControl;
  4647. {* Returns True, is the control is control (not form or applet). }
  4648. property IsButton: Boolean read fIsButton;
  4649. {* Returns True, if the control is button-like or containing buttons (button,
  4650. bitbtn, checkbox, radiobox, toolbar). }
  4651. function ProcessMessage: Boolean;
  4652. {* |<#appbutton>
  4653. Processes one message. See also ProcessMessages. }
  4654. procedure ProcessMessages;
  4655. {* |<#appbutton>
  4656. Processes pending messages during long cycle of calculation,
  4657. allowing to window to be repainted if needed and to respond to other
  4658. messages. But if there are no such messages, your application can be
  4659. stopped until such one appear in messages queue. To prevent such
  4660. situation, use method ProcessPendingMessages instead. }
  4661. procedure ProcessMessagesEx;
  4662. {* Version of ProcessMessages, which works always correctly, even if
  4663. the application is minimized or background. }
  4664. procedure ProcessPendingMessages;
  4665. {* |<#appbutton>
  4666. Similar to ProcessMessages, but without waiting of
  4667. message in messages queue. I.e., if there are no pending
  4668. messages, this method immediately returns control to your
  4669. code. This method is better to call during long cycle of
  4670. calculation (then ProcessMessages). }
  4671. procedure ProcessPaintMessages;
  4672. {* }
  4673. function WndProc( var Msg: TMsg ): Integer; virtual;
  4674. {* Responds to all Windows messages, posted (sended) to the
  4675. window, before all other proceeding. You can override it in
  4676. derived controls, but in KOL there are several other ways
  4677. to control message flow of existing controls without deriving
  4678. another costom controls for only such purposes. See OnMessage,
  4679. AttachProc. }
  4680. property HasBorder: Boolean read GetHasBorder write SetHasBorder;
  4681. {* |<#form>
  4682. Obvious. Form-aware. }
  4683. property HasCaption: Boolean read GetHasCaption write SetHasCaption;
  4684. {* |<#form>
  4685. Obvious. Form-aware. }
  4686. property CanResize: Boolean read GetCanResize write SetCanResize;
  4687. {* |<#form>
  4688. Obvious. Form-aware. }
  4689. property StayOnTop: Boolean read GetStayOnTop write SetStayOnTop;
  4690. {* |<#form>
  4691. Obvious. Form-aware, but can be applied to controls. }
  4692. property Border: Integer read fMargin write fMargin;
  4693. {* |<#form>
  4694. Distance between edges and child controls and between child
  4695. controls by default (if methods PlaceRight, PlaceDown, PlaceUnder,
  4696. ResizeParent, ResizeParentRight, ResizeParentBottom are called).
  4697. |<br>
  4698. Originally was named Margin, now I recommend to use the name 'Border' to
  4699. avoid confusion with MarginTop, MarginBottom, MarginLeft and
  4700. MarginRight properties.
  4701. |<br>
  4702. Initial value is always 2. Border property is used in realigning
  4703. child controls (when its Align property is not caNone), and value
  4704. of this property determines size of borders between edges of children
  4705. and its parent and between aligned controls too.
  4706. |<br>
  4707. See also properties MarginLeft, MarginRight, MarginTop, MarginBottom. }
  4708. function SetBorder( Value: Integer ): PControl;
  4709. {* Assigns new Border value, and returns @ Self. }
  4710. property Margin: Integer read fMargin write fMargin;
  4711. {* |<#form>
  4712. Old name for property Border. }
  4713. property MarginTop: Integer index 1
  4714. {$IFDEF F_P} read GetClientMargin
  4715. {$ELSE DELPHI} read fClientTop
  4716. {$ENDIF F_P/DELPHI} write SetClientMargin;
  4717. {* Additional distance between true window client top and logical top of
  4718. client rectangle. This value is added to Top of rectangle, returning
  4719. by property ClientRect. Together with other margins and property Border,
  4720. this property allows to change view of form for case, that Align property
  4721. is used to align controls on parent (it is possible to provide some
  4722. distance from child controls to its parent, and between child controls.
  4723. |<br>
  4724. Originally this property was introduced to compensate incorrect
  4725. ClientRect property, calculated for some types of controls.
  4726. |<br>
  4727. See also properties Border, MarginBottom, MarginLeft, MarginRight. }
  4728. property MarginBottom: Integer index 2
  4729. {$IFDEF F_P} read GetClientMargin
  4730. {$ELSE DELPHI} read fClientBottom
  4731. {$ENDIF F_P/DELPHI} write SetClientMargin;
  4732. {* The same as MarginTop, but a distance between true window Bottom of
  4733. client rectangle and logical bottom one. Take in attention, that this value
  4734. should be POSITIVE to make logical bottom edge located above true edge.
  4735. |<br>
  4736. See also properties Border, MarginTop, MarginLeft, MarginRight. }
  4737. property MarginLeft: Integer index 3
  4738. {$IFDEF F_P} read GetClientMargin
  4739. {$ELSE DELPHI} read fClientLeft
  4740. {$ENDIF F_P/DELPHI} write SetClientMargin;
  4741. {* The same as MarginTop, but a distance between true window Left of
  4742. client rectangle and logical left edge.
  4743. |<br>
  4744. See also properties Border, MarginTop, MarginRight, MarginBottom. }
  4745. property MarginRight: Integer index 4
  4746. {$IFDEF F_P} read GetClientMargin
  4747. {$ELSE DELPHI} read fClientRight
  4748. {$ENDIF F_P/DELPHI} write SetClientMargin;
  4749. {* The same as MarginLeft, but a distance between true window Right of
  4750. client rectangle and logical bottom one. Take in attention, that this value
  4751. should be POSITIVE to make logical right edge located left of true edge.
  4752. |<br>
  4753. See also properties Border, MarginTop, MarginLeft, MarginBottom. }
  4754. property Tabstop: Boolean read fTabstop write fTabstop;
  4755. {* True, if control can be focused using tabulating between controls.
  4756. Set it to False to make control unavailable for keyboard, but only
  4757. for mouse. }
  4758. property TabOrder: Integer read fTabOrder write SetTabOrder;
  4759. {* Order of tabulating of controls. Initially, TabOrder is equal to
  4760. creation order of controls. If TabOrder changed, TabOrder of
  4761. all controls with not less value of one is shifted up. To place
  4762. control before another, assign TabOrder of one to another.
  4763. For example:
  4764. ! Button1.TabOrder := EditBox1.TabOrder;
  4765. In code above, Button1 is placed just before EditBox1 in tabulating
  4766. order (value of TabOrder of EditBox1 is incremented, as well as
  4767. for all follow controls). }
  4768. property Focused: Boolean read GetFocused write SetFocused;
  4769. {* True, if the control is current on form (but check also, what form
  4770. itself is focused). For form it is True, if the form is active (i.e.
  4771. it is foreground and capture keyboard). Set this value to True to make
  4772. control current and focused (if applicable). }
  4773. function BringToFront: PControl;
  4774. {* Changes z-order of the control, bringing it to the topmost level. }
  4775. function SendToBack: PControl;
  4776. {* Changes z-order of the control, sending it to the back of siblings. }
  4777. property TextAlign: TTextAlign read GetTextAlign write SetTextAlign;
  4778. {* |<#label>
  4779. |<#panel>
  4780. |<#button>
  4781. |<#bitbtn>
  4782. |<#edit>
  4783. |<#memo>
  4784. Text horizontal alignment. Applicable to labels, buttons,
  4785. multi-line edit boxes, panels. }
  4786. property VerticalAlign: TVerticalAlign read GetVerticalAlign write SetVerticalAlign;
  4787. {* |<#button>
  4788. |<#label>
  4789. |<#panel>
  4790. Text vertical alignment. Applicable to buttons, labels and panels. }
  4791. property WordWrap: Boolean read fWordWrap write fWordWrap;
  4792. {* TRUE, if this is a label, created using NewWordWrapLabel. }
  4793. property ShadowDeep: Integer read FShadowDeep write SetShadowDeep;
  4794. {* |<#3dlabel>
  4795. Deep of a shadow (for label effect only, created calling NewLabelEffect). }
  4796. property CannotDoubleBuf: Boolean read fCannotDoubleBuf write fCannotDoubleBuf;
  4797. {* }
  4798. property DoubleBuffered: Boolean read fDoubleBuffered write SetDoubleBuffered;
  4799. {* Set it to true for some controls, which are flickering in repainting
  4800. (like label effect). Slow, and requires additional code. This property
  4801. is inherited by all child controls.
  4802. |<br>&nbsp;&nbsp;&nbsp;
  4803. Note: RichEdit control can not become DoubleBuffered. }
  4804. //function IsSelfOrParentDblBuf: Boolean;
  4805. {* Returns true, if DoubleBuffered or one of parents is DoubleBuffered. }
  4806. function DblBufTopParent: PControl;
  4807. {* Returns the topmost DoubleBuffered Parent control. }
  4808. property Transparent: Boolean read fTransparent write SetTransparent;
  4809. {* Set it to true to get special effects. Transparency also uses
  4810. DoubleBuffered and inherited by child controls.
  4811. |<br>&nbsp;&nbsp;&nbsp;
  4812. Please note, that some controls can not be shown properly, when
  4813. Transparent is set to True for it. If You want to make edit control
  4814. transparent (e.g., over gradient filled panel), handle its OnChanged
  4815. property and call there Invalidate to provide repainting of edit
  4816. control content. Note also, that for RichEdit control property
  4817. Transparent has no effect (as well as DoubleBuffered). But special
  4818. property RE_Transparent is designed especially for RichEdit control
  4819. (it works fine, but with great number of flicks while resizing
  4820. of a control). Another note is about Edit control. To allow editing
  4821. of transparent edit box, it is necessary to invalidate it for
  4822. every pressed character. Or, use Ed_Transparent property instead. }
  4823. property Ed_Transparent: Boolean read fTransparent write EdSetTransparent;
  4824. {* |<#edit>
  4825. |<#memo>
  4826. Use this property for editbox to make it really Transparent. Remember,
  4827. that though Transparent property is inherited by child controls from
  4828. its parent, this is not so for Ed_Transparent. So, it is necessary to
  4829. set Ed_Transparent to True for every edit control explicitly. }
  4830. property AlphaBlend: Integer read fAlphaBlend write SetAlphaBlend;
  4831. {* |<#form>
  4832. If assigned to 0..254, makes window (form or control) semi-transparent
  4833. (Win2K only).
  4834. |<br>
  4835. Depending on value assigned, it is possible to adjust transparency
  4836. level ( 0 - totally transparent, 255 - totally opaque). }
  4837. property LookTabKeys: TTabKeys read fLookTabKeys write fLookTabKeys;
  4838. {* Set of keys which can be used as tabulation keys in a control. }
  4839. procedure GotoControl( Key: DWORD );
  4840. {* |<#form>
  4841. Emulates tabulation key press w/o sending message to current control.
  4842. Can be applied to a form or to any its control. If VK_TAB is used,
  4843. state of shift kay is checked in: if it is pressed, tabulate is in
  4844. backward direction. }
  4845. property SubClassName: String read get_ClassName write set_ClassName;
  4846. {* Name of window class - unique for every window class
  4847. in every run session of a program. }
  4848. property OnClose: TOnEventAccept read fOnClose write fOnClose;
  4849. {* |<#form>
  4850. |<#applet>
  4851. Called before closing the window. It is possible to set Accept
  4852. parameter to False to prevent closing the window. This event events
  4853. is not called when windows session is finishing (to handle this
  4854. event, handle WM_QUERYENDSESSION message, or assign OnQueryEndSession
  4855. event to another or the same event handler). }
  4856. property OnQueryEndSession: TOnEventAccept read fOnQueryEndSession write SetOnQueryEndSession;
  4857. {* |<#form>
  4858. |<#applet>
  4859. Called when WM_QUERYENDSESSION message come in. It is possible to set Accept
  4860. parameter to False to prevent closing the window (in such case session ending
  4861. is halted). It is possible to check CloseQueryReason property to find out,
  4862. why event occur. }
  4863. property CloseQueryReason: TCloseQueryReason read fCloseQueryReason;
  4864. {* Reason why OnClose or OnQueryEndSession called. }
  4865. property OnMinimize: TOnEvent index 0
  4866. {$IFDEF F_P} read GetOnMinMaxRestore
  4867. {$ELSE DELPHI} read fOnMinimize
  4868. {$ENDIF F_P/DELPHI} write SetOnMinMaxRestore;
  4869. {* |<#form>
  4870. Called when window is minimized. }
  4871. property OnMaximize: TOnEvent index 8
  4872. {$IFDEF F_P} read GetOnMinMaxRestore
  4873. {$ELSE DELPHI} read fOnMaximize
  4874. {$ENDIF F_P/DELPHI} write SetOnMinMaxRestore;
  4875. {* |<#form>
  4876. Called when window is maximized. }
  4877. property OnRestore: TOnEvent index 16
  4878. {$IFDEF F_P} read GetOnMinMaxRestore
  4879. {$ELSE DELPHI} read fOnRestore
  4880. {$ENDIF F_P/DELPHI} write SetOnMinMaxRestore;
  4881. {* |<#form>
  4882. Called when window is restored from minimized or maximized state. }
  4883. property UpdateRgn: HRgn read fUpdRgn;
  4884. {* A handle of update region. Valid only in OnPaint method. You
  4885. can use it to improve painting (for speed), if necessary. When
  4886. UpdateRgn is obtained in response to WM_PAINT message, value
  4887. of the property EraseBackground is used to pass it to the API
  4888. function GetUpdateRgn. If UpdateRgn = 0, this means that entire
  4889. window should be repainted. Otherwise, You (e.g.) can check
  4890. if the rectangle is in clipping region using API function
  4891. RectInRegion. }
  4892. property EraseBackground: Boolean read fEraseUpdRgn write fEraseUpdRgn;
  4893. {* This value is used to pass it to the API function GetUpdateRgn,
  4894. when UpadateRgn property is obtained first in responce to WM_PAINT
  4895. message. If EraseBackground is set to True, system is responsible
  4896. for erasing background of update region before painting. If not
  4897. (default), the entire region invalidated should be painted by your
  4898. event handler. }
  4899. property OnPaint: TOnPaint read fOnPaint write SetOnPaint;
  4900. {* Event to set to override standard control painting. Can be applied
  4901. to any control (though originally was designed only for paintbox
  4902. control). When an event handler is called, it is possible to use
  4903. UpdateRgn to examine what parts of window require painting to
  4904. improve performance of the painting operation. }
  4905. property OnPrePaint: TOnPaint read fOnPrePaint write fOnPrePaint;
  4906. {* Only for graphic controls. If you assign it, call Invalidate also. }
  4907. property OnPostPaint: TOnPaint read fOnPostPaint write fOnPostPaint;
  4908. {* Only for graphic controls. If you assign it, call Invalidate also. }
  4909. property OnEraseBkgnd: TOnPaint read fOnEraseBkgnd write SetOnEraseBkgnd;
  4910. {* This event allows to override erasing window background in response
  4911. to WM_ERASEBKGND message. This allows to add some decorations to
  4912. standard controls without overriding its painting in total.
  4913. Note: When erase background, remember, that property ClientRect can
  4914. return not true client rectangle of the window - use GetClientRect
  4915. API function instead. For example:
  4916. !
  4917. !var BkBmp: HBitmap;
  4918. !
  4919. !procedure TForm1.KOLForm1FormCreate(Sender: PObj);
  4920. !begin
  4921. ! Toolbar1.OnEraseBkgnd := DecorateToolbar;
  4922. ! BkBmp := LoadBitmap( hInstance, 'BK1' );
  4923. !end;
  4924. !
  4925. !procedure TForm1.DecorateToolbar(Sender: PControl; DC: HDC);
  4926. !var CR: TRect;
  4927. !begin
  4928. ! GetClientRect( Sender.Handle, CR );
  4929. ! Sender.Canvas.Brush.BrushBitmap := BkBmp;
  4930. ! Sender.Canvas.FillRect( CR );
  4931. !end;
  4932. !
  4933. }
  4934. property OnClick: TOnEvent read fOnClick write fOnClick;
  4935. {* |<#button>
  4936. |<#checkbox>
  4937. |<#radiobox>
  4938. |<#toolbar>
  4939. Called on click at control. For buttons, checkboxes and radioboxes
  4940. is called regadless if control clicked by mouse or keyboard. For toolbar,
  4941. the same event is used for all toolbar buttons and toolbar itself.
  4942. To determine which toolbar button is clicked, check CurIndex property.
  4943. And note, that all the buttons including separator buttons are enumerated
  4944. starting from 0. Though images are stored (and prepared) only for
  4945. non-separator buttons. And to determine, if toolbar button was clicked
  4946. with right mouse button, check RightClick property. }
  4947. property RightClick: Boolean read fRightClick;
  4948. {* |<#toolbar>
  4949. |<#listview>
  4950. Use this property to determine which mouse button was clicked
  4951. (applicable to toolbar in the OnClick event handler). }
  4952. property OnEnter: TOnEvent read fOnEnter write fOnEnter;
  4953. {* Called when control receives focus. }
  4954. property OnLeave: TOnEvent read fOnLeave write fOnLeave;
  4955. {* Called when control looses focus. }
  4956. property OnChange: TOnEvent read fOnChange write fOnChange;
  4957. {* |<#edit>
  4958. |<#memo>
  4959. |<#listbox>
  4960. |<#combo>
  4961. |<#tabcontrol>
  4962. Called when edit control is changed, or selection in listbox or
  4963. current index in combobox is changed (but if OnSelChanged assigned,
  4964. the last is called for change selection). To respond to check/uncheck
  4965. checkbox or radiobox events, use OnClick instead. }
  4966. property OnSelChange: TOnEvent read fOnSelChange write fOnSelChange;
  4967. {* |<#richedit>
  4968. |<#listbox>
  4969. |<#combo>
  4970. |<#treeview>
  4971. Called for rich edit control, listbox, combobox or treeview when current selection
  4972. (range, or current item) is changed. If not assigned, but OnChange is
  4973. assigned, OnChange is called instead. }
  4974. property OnResize: TOnEvent read FOnResize write SetOnResize;
  4975. {* Called whenever control receives message WM_SIZE (thus is, if
  4976. control is resized. }
  4977. property OnMove: TOnEvent read FOnMove write SetOnMove;
  4978. {* Called whenever control receives message WM_MOVE (i.e. when control is
  4979. moved over its parent). }
  4980. property MinSizePrev: Integer read fSplitMinSize1 write fSplitMinSize1;
  4981. {* |<#splitter>
  4982. Minimal allowed (while dragging splitter) size of previous control
  4983. for splitter (see NewSplitter). }
  4984. property SplitMinSize1: Integer read fSplitMinSize1 write fSplitMinSize1;
  4985. {* The same as MinSizePrev. }
  4986. property MinSizeNext: Integer read fSplitMinSize2 write fSplitMinSize2;
  4987. {* |<#splitter>
  4988. Minimal allowed (while dragging splitter) size of the rest of parent
  4989. of splitter or of SecondControl (see NewSplitter). }
  4990. property SplitMinSize2: Integer read fSplitMinSize2 write fSplitMinSize2;
  4991. {* The same as MinSizeNext. }
  4992. property SecondControl: PControl read fSecondControl write fSecondControl;
  4993. {* |<#splitter>
  4994. Second control to check (while dragging splitter) if its size not less
  4995. than SplitMinSize2 (see NewSplitter). By default, second control is
  4996. not necessary, and needed only in rare case when SecondControl can not
  4997. be determined automatically to restrict splitter right (bottom) position. }
  4998. property OnSplit: TOnSplit read fOnSplit write fOnSplit;
  4999. {* |<#splitter>
  5000. Called when splitter control is dragging - to allow for
  5001. your event handler to decide if to accept new size of
  5002. left (top) control, and new size of the rest area of parent. }
  5003. property Dragging: Boolean read FDragging;
  5004. {* |<#splitter>
  5005. True, if splitter control is dragging now by user with left
  5006. mouse button. Also, this property can be used to detect if the control
  5007. is dragging with mouse (after calling DragStartEx method). }
  5008. procedure DragStart;
  5009. {* Call this method for a form or control to drag it with left mouse button,
  5010. when mouse left button is already down. Dragging is stopped when left mouse
  5011. button is released. See also DragStartEx, DragStopEx. }
  5012. procedure DragStartEx;
  5013. {* Call this method to start dragging the form by mouse. To stop
  5014. dragging, call DragStopEx method. (Tip: to detect mouse up event,
  5015. use OnMouseUp event of the dragging control). This method can be used
  5016. to move any control with the mouse, not only entire form. State of
  5017. mouse button is not significant. Determine dragging state of the control
  5018. checking its Dragging property. }
  5019. procedure DragStopEx;
  5020. {* Call this method to stop dragging the form (started by DragStopEx). }
  5021. procedure DragItem( OnDrag: TOnDrag );
  5022. {* Starts dragging something with mouse. During the process,
  5023. callback function OnDrag is called, which allows to control
  5024. drop target, change cursor shape, etc. }
  5025. property OnKeyDown: TOnKey read fOnKeyDown write SetOnKeyDown;
  5026. {* Obvious. }
  5027. property OnKeyUp: TOnKey read fOnKeyUp write SetOnKeyUp;
  5028. {* Obvious. }
  5029. property OnChar: TOnChar read fOnChar write SetOnChar;
  5030. {* Obvious. }
  5031. property OnMouseDown: TOnMouse read fOnMouseDown write SetMouseDown;
  5032. {* Obvious. }
  5033. property OnMouseUp: TOnMouse read fOnMouseUp write SetMouseUp;
  5034. {* Obvious. }
  5035. property OnMouseMove: TOnMouse read fOnMouseMove write SetMouseMove;
  5036. {* Obvious. }
  5037. property OnMouseDblClk: TOnMouse read fOnMouseDblClk write SetMouseDblClk;
  5038. {* Obvious. }
  5039. property OnMouseWheel: TOnMouse read fOnMouseWheel write SetMouseWheel;
  5040. {* Obvious. }
  5041. property OnMouseEnter: TOnEvent read fOnMouseEnter write SetOnMouseEnter;
  5042. {* Is called when mouse is entered into control. See also OnMouseLeave. }
  5043. property OnMouseLeave: TOnEvent read fOnMouseLeave write SetOnMouseLeave;
  5044. {* Is called when mouse is leaved control. If this event is assigned,
  5045. then mouse is captured on mouse enter event to handle all other
  5046. mouse events until mouse cursor leaves the control. }
  5047. property OnTestMouseOver: TOnTestMouseOver read fOnTestMouseOver write SetOnTestMouseOver;
  5048. {* |<#bitbtn>
  5049. Special event, which allows to extend OnMouseEnter / OnMouseLeave
  5050. (and also Flat property for BitBtn control). If a handler is assigned
  5051. to this event, actual testing whether mouse is in control or not,
  5052. is occuring in the handler. So, it is possible to simulate more
  5053. careful hot tracking for controls with non-rectangular shape (such
  5054. as glyphed BitBtn control). }
  5055. property MouseInControl: Boolean read fMouseInControl;
  5056. {* |<#bitbtn>
  5057. This property can return True only if OnMouseEnter / OnMouseLeave
  5058. event handlers are set for a control (or, for BitBtn, property Flat
  5059. is set to True. Otherwise, False is returned always. }
  5060. property Flat: Boolean read fFlat write SetFlat;
  5061. {* |<#bitbtn>
  5062. Set it to True for BitBtn, to provide either flat border for a button
  5063. or availability of "highlighting" (correspondent to glyph index 4).
  5064. |<br>
  5065. Note: this can work incorrectly a bit under win95 without comctl32.dll
  5066. updated. Therefore, application will launch. To enforce correct working
  5067. even under Win95, use your own timer, which event handler checks for
  5068. mouse over bitbtn control, e.g.:
  5069. ! procedure TForm1.Timer1Timer(Sender: PObj);
  5070. ! var P: TPoint;
  5071. ! begin
  5072. ! if not BitBtn1.MouseInControl then Exit;
  5073. ! GetCursorPos( P );
  5074. ! P := BitBtn1.Screen2Client( P );
  5075. ! if not PtInRect( BitBtn1.ClientRect, P ) then
  5076. ! begin
  5077. ! BitBtn1.Flat := FALSE;
  5078. ! BitBtn1.Flat := TRUE;
  5079. ! end;
  5080. ! end;
  5081. }
  5082. property RepeatInterval: Integer read fRepeatInterval write fRepeatInterval;
  5083. {* |<#bitbtn>
  5084. If this property is set to non-zero, it is interpreted (for BitBtn
  5085. only) as an interval in milliseconds between repeat button down events,
  5086. which are generated after first mouse or button click and until
  5087. button is released. Though, if the button is pressed with keyboard (with
  5088. space key), RepeatInterval value is ignored and frequency of repeatitive
  5089. clicking is determined by user keyboard settings only. }
  5090. function LikeSpeedButton: PControl;
  5091. {* |<#button>
  5092. |<#bitbtn>
  5093. Transparent method (returns control itself). Makes button not focusable. }
  5094. function Add( const S: String ): Integer;
  5095. {* |<#listbox>
  5096. |<#combo>
  5097. Only for listbox and combobox. }
  5098. function Insert( Idx: Integer; const S: String ): Integer;
  5099. {* |<#listbox>
  5100. |<#combo>
  5101. Only for listbox and combobox. }
  5102. procedure Delete( Idx: Integer );
  5103. {* |<#listbox>
  5104. |<#combo>
  5105. Only for listbox and combobox. }
  5106. procedure Clear;
  5107. {* Clears object content. Has different sense for different controls.
  5108. E.g., for label, editbox, button and other simple controls it
  5109. assigns empty string to Caption property. For listbox, combobox,
  5110. listview it deletes all items. For toolbar, it deletes all buttons.
  5111. Et so on. }
  5112. property Progress: Integer index ((PBM_SETPOS or $8000) shl 16) or PBM_GETPOS
  5113. read GetIntVal write SetIntVal;
  5114. {* |<#progressbar>
  5115. Only for ProgressBar. }
  5116. property MaxProgress: Integer index ((PBM_SETRANGE32 or $8000) shl 16) or PBM_GETRANGE
  5117. read GetIntVal write SetMaxProgress;
  5118. {* |<#progressbar>
  5119. Only for ProgressBar. 100 is the default value. }
  5120. property ProgressColor: TColor read fTextColor write SetProgressColor;
  5121. {* |<#progressbar>
  5122. Only for ProgressBar. }
  5123. property ProgressBkColor: TColor read fColor write SetCtlColor; //SetProgressBkColor;
  5124. {* |<#progressbar>
  5125. Obsolete. Now the same as Color. }
  5126. property StatusText[ Idx: Integer ]: PChar read GetStatusText write SetStatusText;
  5127. {* |<#form>
  5128. Only for forms to set/retrieve status text to/from given status panel.
  5129. Panels are enumerated from 0 to 254, 255 is to indicate simple
  5130. status bar. Size grip in right bottom corner of status window is
  5131. displayed only if form still CanResize.
  5132. |<br>
  5133. When a status text is set first time, status bar window is created
  5134. (always aligned to bottom), and form is resizing to preset client height.
  5135. While status bar is showing, client height value is returned without
  5136. height of status bar. To remove status bar, call RemoveStatus method for
  5137. a form.
  5138. |<br>
  5139. By default, text is left-aligned within the specified part of a status
  5140. window. You can embed tab characters (#9) in the text to center or
  5141. right-align it. Text to the right of a single tab character is centered,
  5142. and text to the right of a second tab character is right-aligned.
  5143. |<br>
  5144. If You use separate status bar onto several panels, these automatically
  5145. align its widths to the same value (width divided to number of panels).
  5146. To adjust status panel widths for every panel, use property StatusPanelRightX.
  5147. }
  5148. property SimpleStatusText: PChar index 255 read GetStatusText write SetStatusText;
  5149. {* |<#form>
  5150. Only for forms to set/retrive status text to/from simple status bar.
  5151. Size grip in right bottom corner of status window is displayed only
  5152. if form CanResize.
  5153. |<br>
  5154. When status text set first time, (simple) status bar window is created
  5155. (always aligned to bottom), and form is resizing to preset client height.
  5156. While status bar is showing, client height value is returned without
  5157. height of status bar. To remove status bar, call RemoveStatus method for
  5158. a form.
  5159. |<br>
  5160. By default, text is left-aligned within the specified part of a status
  5161. window. You can embed tab characters (#9) in the text to center or
  5162. right-align it. Text to the right of a single tab character is centered,
  5163. and text to the right of a second tab character is right-aligned.
  5164. }
  5165. property StatusCtl: PControl read fStatusCtl;
  5166. {* Pointer to Status bar control. To "create" child controls on
  5167. the status bar, first create it as a child of form, for instance, and
  5168. then change its property Parent, e.g.:
  5169. ! var Progress1: PControl;
  5170. ! ...
  5171. ! Progress1 := NewProgressBar( Form1 );
  5172. ! Progress1.Parent := Form1.StatusCtl;
  5173. (If you use MCK, code should be another a bit, and in this case it is
  5174. possible to create and adjust the control at design-time, and at run-time
  5175. change its parent control. E.g. (Progress1 is created at run-time here too):
  5176. ! Progress1 := NewProgressBar( Form );
  5177. ! Progress1.Parent := Form.StatusCtl;
  5178. ).
  5179. Do not forget to provide StatusCtl to be existing first (e.g. assign
  5180. one-space string to SimpleStatusText property of the form, for MCK do
  5181. so using Object Inspector).
  5182. }
  5183. property SizeGrip: Boolean read fSizeGrip write fSizeGrip;
  5184. {* Size grip for status bar. Has effect only before creating window. }
  5185. procedure RemoveStatus;
  5186. {* |<#form>
  5187. Call it to remove status bar from a form (created in result of assigning
  5188. value(s) to StatusText[], SimpleStatusText properties). When status bar is
  5189. removed, form is resized to preset client height. }
  5190. function StatusPanelCount: Integer;
  5191. {* |<#form>
  5192. Returns number of status panels defined in status bar. }
  5193. property StatusPanelRightX[ Idx: Integer ]: Integer read GetStatusPanelX write SetStatusPanelX;
  5194. {* |<#form>
  5195. Use this property to adjust status panel right edges (if the status bar is
  5196. divided onto several subpanels). If the right edge for the last panel is
  5197. set to -1 (by default) it is expanded to the right edge of a form window.
  5198. Otherwise, status bar can be shorter then form width. }
  5199. property StatusWindow: HWND read fStatusWnd;
  5200. {* |<#form>
  5201. Provided for case if You want to use API direct message sending to
  5202. status bar. }
  5203. property Color1: TColor read fColor1 write SetColor1;
  5204. {* |<#gradient>
  5205. Top line color for GradientPanel. }
  5206. property Color2: TColor read fColor2 write SetColor2;
  5207. {* |<#gradient>
  5208. |<#3Dlabel>
  5209. Bottom line color for GradientPanel, or shadow color for LabelEffect.
  5210. (If clNone, shadow color for LabelEffect is calculated as a mix bitween
  5211. TextColor and clBlack). }
  5212. property GradientStyle: TGradientStyle read FGradientStyle write SetGradientStyle;
  5213. {* |<#gradient>
  5214. Styles other then gsVertical and gsHorizontal has effect only for
  5215. gradient panel, created by NewGradientPanelEx. }
  5216. property GradientLayout: TGradientLayout read FGradientLayout write SetGradientLayout;
  5217. {* |<#gradient>
  5218. Has only effect for gradient panel, created by NewGradientPanelEx.
  5219. Ignored for styles gsVertical and gsHorizontal. }
  5220. //======== Image lists (for ListView, TreeView, ToolBar and TabControl):
  5221. property ImageListSmall: PImageList index 16 read GetImgListIdx write SetImgListIdx;
  5222. {* |<#listview>
  5223. Image list with small icons used with List View control. If not set,
  5224. last added (i.e. created with a control as an owner) image list with
  5225. small icons is used. }
  5226. property ImageListNormal: PImageList index 32 read GetImgListIdx write SetImgListIdx;
  5227. {* |<#listview>
  5228. |<#treeview>
  5229. |<#tabcontrol>
  5230. |<#bitbtn>
  5231. Image list with normal size icons used with List View control (or with
  5232. icons for BitBtn, TreeView, ToolBar or TabControl). If not set,
  5233. last added (i.e. created with a control as an owner) image list is used.
  5234. }
  5235. property ImageListState: PImageList index 0 read GetImgListIdx write SetImgListIdx;
  5236. {* |<#listview>
  5237. |<#treeview>
  5238. Image list used as a state images list for ListView or TreeView control. }
  5239. //========
  5240. function SetUnicode( Unicode: Boolean ): PControl;
  5241. {* |<#listview>
  5242. |<#treeview>
  5243. |<#tabcontrol>
  5244. Sets control as Unicode or not. The control itself is returned as for
  5245. other "transparent" functions. A conditional define UNICODE_CTRLS must
  5246. be added to a project to provide handling unicode messages. }
  5247. //======== TabControl-specific properties and methods:
  5248. property Pages[ Idx: Integer ]: PControl read GetPages;
  5249. {* |<#tabcontrol>
  5250. Returns controls, which can be used as parent for controls, placed on
  5251. different pages of a tab control. Use it like in follows example:
  5252. | Label1 := NewLabel( TabControl1.Pages[ 0 ], 'Label1' );
  5253. To find number of pages available, check out Count property of the tab
  5254. control. Pages are enumerated from 0 to Count - 1, as usual. }
  5255. property TC_Pages[ Idx: Integer ]: PControl read GetPages;
  5256. {* |<#tabcontrol>
  5257. The same as above. }
  5258. function TC_Insert( Idx: Integer; const TabText: String; TabImgIdx: Integer ): PControl;
  5259. {* |<#tabcontrol>
  5260. Inserts new tab before given, returns correspondent page control
  5261. (which can be used as a parent for controls to place on the page). }
  5262. procedure TC_Delete( Idx: Integer );
  5263. {* |<#tabcontrol>
  5264. Removes tab from tab control, destroying all its child controls. }
  5265. property TC_Items[ Idx: Integer ]: String read TCGetItemText write TCSetItemText;
  5266. {* |<#tabcontrol>
  5267. Text, displayed on tab control tabs. }
  5268. property TC_Images[ Idx: Integer ]: Integer read TCGetItemImgIDx write TCSetItemImgIdx;
  5269. {* |<#tabcontrol>
  5270. Image index for a tab in tab control. }
  5271. property TC_ItemRect[ Idx: Integer ]: TRect read TCGetItemRect;
  5272. {* |<#tabcontrol>
  5273. Item rectangle for a tab in tab control. }
  5274. procedure TC_SetPadding( cx, cy: Integer );
  5275. {* |<#tabcontrol>
  5276. Sets space padding around tab text in a tab of tab control. }
  5277. function TC_TabAtPos( x, y: Integer ): Integer;
  5278. {* |<#tabcontrol>
  5279. Returns index of tab, found at the given position (relative to
  5280. a client rectangle of tab control). If no tabs found at the
  5281. position, -1 is returned. }
  5282. function TC_DisplayRect: TRect;
  5283. {* |<#tabcontrol>
  5284. Returns rectangle, occupied by a page rather then tab. }
  5285. function TC_IndexOf(const S: String): Integer;
  5286. {* |<#tabcontrol>
  5287. By Mr Brdo. Index of page by its Caption. }
  5288. function TC_SearchFor(const S: String; StartAfter: Integer; Partial: Boolean): Integer;
  5289. {* |<#tabcontrol>
  5290. By Mr Brdo. Index of page by its Caption. }
  5291. //======== ListView style and options:
  5292. property LVStyle: TListViewStyle read fLVStyle write SetLVStyle;
  5293. {* |<#listview>
  5294. ListView style of view. Can be changed at run time. }
  5295. property LVOptions: TListViewOptions read fLVOptions write SetLVOptions;
  5296. {* |<#listview>
  5297. ListView options. Can be changed at run time. }
  5298. property LVTextColor: TColor index LVM_GETTEXTCOLOR
  5299. {$IFDEF F_P} read LVGetColorByIdx
  5300. {$ELSE DELPHI} read fTextColor
  5301. {$ENDIF F_P/DELPHI} write LVSetColorByIdx;
  5302. {* |<#listview>
  5303. ListView text color. Use it instead of TextColor. }
  5304. property LVTextBkColor: TColor index LVM_GETTEXTBKCOLOR
  5305. {$IFDEF F_P} read LVGetColorByIdx
  5306. {$ELSE DELPHI} read fLVTextBkColor
  5307. {$ENDIF F_P/DELPHI} write LVSetColorByIdx;
  5308. {* |<#listview>
  5309. ListView background color for text. }
  5310. property LVBkColor: TColor read fColor write SetCtlColor; //LVSetBkColor;
  5311. {* |<#listview>
  5312. ListView background color. Use it instead of Color. }
  5313. //======== List View columns handling:
  5314. property LVColCount: Integer read fLVColCount;
  5315. {* |<#listview>
  5316. ListView (additional) column count. Value 0 means that there are
  5317. no columns (single item text / icon is used). If You want
  5318. to provide several columns, first call LVColAdd to "insert" column 0,
  5319. i.e. to provide header text for first column (with index 0).
  5320. If there are no column, nothing will be shown in lvsDetail /
  5321. lvsDetailNoHeader view style. }
  5322. procedure LVColAdd( const aText: String; aalign: TTextAlign; aWidth: Integer );
  5323. {* |<#listview>
  5324. Adds new column. Pass 'width' <= 0 to provide default column width.
  5325. 'text' is a column header text. }
  5326. {$IFNDEF _FPC}
  5327. {$IFNDEF _D2}
  5328. procedure LVColAddW( const aText: WideString; aalign: TTextAlign; aWidth: Integer );
  5329. {* |<#listview>
  5330. Adds new column (unicode version). }
  5331. {$ENDIF _D2}
  5332. {$ENDIF _FPC}
  5333. procedure LVColInsert( ColIdx: Integer; const aText: String; aAlign: TTextAlign; aWidth: Integer );
  5334. {* |<#listview>
  5335. Inserts new column at the Idx position (1-based column index). }
  5336. {$IFNDEF _FPC}
  5337. {$IFNDEF _D2}
  5338. procedure LVColInsertW( ColIdx: Integer; const aText: WideString; aAlign: TTextAlign; aWidth: Integer );
  5339. {* |<#listview>
  5340. Inserts new column at the Idx position (1-based column index). }
  5341. {$ENDIF _D2}
  5342. {$ENDIF _FPC}
  5343. procedure LVColDelete( ColIdx: Integer );
  5344. {* |<#listview>
  5345. Deletes column from List View }
  5346. property LVColWidth[ Item: Integer ]: Integer index LVM_GETCOLUMNWIDTH
  5347. read GetItemVal write SetItemVal;
  5348. {* |<#listview>
  5349. Retrieves or changes column width. For lvsList view style, the same width
  5350. is returned for all columns (ColIdx is ignored). It is possible to use
  5351. special values to assign to a property:
  5352. |<br> LVSCW_AUTOSIZE - Automatically sizes the column
  5353. |<br> LVSCW_AUTOSIZE_USEHEADER - Automatically sizes the column to fit
  5354. the header text
  5355. |<br>
  5356. To set coumn width in lvsList view mode, column index must be -1
  5357. (and Width to set must be in range 0..32767 always). }
  5358. property LVColText[ Idx: Integer ]: String read GetLVColText write SetLVColText;
  5359. {* |<#listview>
  5360. Allows to get/change column header text at run time. }
  5361. {$IFNDEF _FPC}
  5362. {$IFNDEF _D2}
  5363. property LVColTextW[ Idx: Integer ]: WideString read GetLVColTextW write SetLVColTextW;
  5364. {* |<#listview>
  5365. Allows to get/change column header text at run time. }
  5366. {$ENDIF _D2}
  5367. {$ENDIF _FPC}
  5368. property LVColAlign[ Idx: Integer ]: TTextAlign read GetLVColalign write SetLVColalign;
  5369. {* |<#listview>
  5370. Column text aligning. }
  5371. property LVColImage[ Idx: Integer ]: Integer index LVCF_IMAGE or (24 shl 16) read GetLVColEx write SetLVColEx;
  5372. {* |<#listview>
  5373. Only starting from comctrl32.dll of version 4.70 (IE4+). Allows to
  5374. set an image for list view column itself from the ImageListSmall.
  5375. }
  5376. property LVColOrder[ Idx: Integer ]: Integer index LVCF_ORDER or (28 shl 16) read GetLVColEx write SetLVColEx;
  5377. {* |<#listview>
  5378. Only starting from comctrl32.dll of version 4.70 (IE4+). Allows to
  5379. set visual order of the list view column from the ImageListSmall.
  5380. This value does not affect the index, by which the column is still
  5381. accessible in the column array.
  5382. }
  5383. //======== List View items handling:
  5384. property LVCount: Integer read GetItemsCount write SetItemsCount;
  5385. {* |<#listview>
  5386. Returns item count for ListView control. It is possible to use Count
  5387. property instead when obtaining of item count is needed only. But this this
  5388. property allows also to set actual count of list view items when a list
  5389. view is virtual. }
  5390. property LVCurItem: Integer read GetLVCurItem write SetLVCurItem;
  5391. {* |<#listview>
  5392. Returns first selected item index in a list view. See also LVNextSelected,
  5393. LVNextItem and LVFocusItem functions. }
  5394. property LVFocusItem: Integer read GetLVFocusItem;
  5395. {* |<#listview>
  5396. Returns focused item index in a list view. See also LVCurItem. }
  5397. function LVNextItem( IdxPrev: Integer; Attrs: DWORD ): Integer;
  5398. {* |<#listview>
  5399. Returns an index of the next after IdxPrev item with given attributes in
  5400. the list view. }
  5401. function LVNextSelected( IdxPrev: Integer ): Integer;
  5402. {* |<#listview>
  5403. Returns an index of next (after IdxPrev) selected item in a list view. }
  5404. function LVAdd( const aText: String; ImgIdx: Integer; State: TListViewItemState;
  5405. StateImgIdx, OverlayImgIdx: Integer; Data: DWORD ): Integer;
  5406. {* |<#listview>
  5407. Adds new line to the end of ListView control. Only content of item itself
  5408. is set (aText, ImgIdx). To change other column text and attributes of
  5409. item added, use appropriate properties / methods ().
  5410. |<br>
  5411. Returns an index of added item.
  5412. |<br>
  5413. There is no Unicode version defined, use LVItemAddW instead. }
  5414. function LVItemAdd( const aText: String ): Integer;
  5415. {* |<#listview>
  5416. Adds an item to the end of list view. Returns an index of the item added. }
  5417. {$IFNDEF _FPC}
  5418. {$IFNDEF _D2}
  5419. function LVItemAddW( const aText: WideString ): Integer;
  5420. {* |<#listview>
  5421. Adds an item to the end of list view. Returns an index of the item added. }
  5422. {$ENDIF _D2}
  5423. {$ENDIF _FPC}
  5424. function LVInsert( Idx: Integer; const aText: String; ImgIdx: Integer;
  5425. State: TListViewItemState; StateImgIdx, OverlayImgIdx: Integer; Data: DWORD ): Integer;
  5426. {* |<#listview>
  5427. Inserts new line before line with index Idx in ListView control. Only
  5428. content of item itself is set (aText, ImgIdx). To change other column
  5429. text and attributes of item added, use appropriate properties / methods ().
  5430. if ImgIdx = I_IMAGECALLBACK, event handler OnGetLVItemImgIdx is responsible
  5431. for returning image index for an item ( /// not implemented yet /// )
  5432. Pass StateImgIdx and OverlayImgIdx = 0 (ignored in that case) or 1..15 to
  5433. use correspondent icon from ImageListState image list.
  5434. |<br> Returns an index of item inserted.
  5435. |<br> There is no unicode version of this method, use LVItemInsertW. }
  5436. function LVItemInsert( Idx: Integer; const aText: String ): Integer;
  5437. {* |<#listview>
  5438. Inserts an item to Idx position. }
  5439. {$IFNDEF _FPC}
  5440. {$IFNDEF _D2}
  5441. function LVItemInsertW( Idx: Integer; const aText: WideString ): Integer;
  5442. {* |<#listview>
  5443. Inserts an item to Idx position. }
  5444. {$ENDIF _D2}
  5445. {$ENDIF _FPC}
  5446. procedure LVDelete( Idx: Integer );
  5447. {* |<#listview>
  5448. Deletes item of ListView with subitems (full row - in lvsDetail view style. }
  5449. procedure LVSetItem( Idx, Col: Integer; const aText: String; ImgIdx: Integer;
  5450. State: TListViewItemState; StateImgIdx, OverlayImgIdx: Integer; Data: DWORD );
  5451. {* |<#listview>
  5452. Use this method to set item data and item columns data for ListView control.
  5453. It is possible to pass I_SKIP as ImgIdx, StateImgIdx, OverlayImgIdx values to
  5454. skip setting this fields. But all other are set always. Like in LVInsert /
  5455. LVAdd, ImgIdx can be I_IMAGECALLBACK to determine that image will be
  5456. retrieved in OnGetItemImgIdx event handler when needed.
  5457. |<br>
  5458. If this method is called to set data for column > 0, parameters ImgIdx and
  5459. Data are ignored anyway.
  5460. |<br> There is no unicode version of this method, use other methods
  5461. to set up listed properties separately using correspondent W-functions. }
  5462. property LVItemState[ Idx: Integer ]: TListViewItemState read LVGetItemState write LVSetItemState;
  5463. {* |<#listview>
  5464. Access to list view item states set [lvisBlend, lvisHighlight, lvisFocus,
  5465. lvisSelect]. When assign new value to the property, it is possible to use
  5466. special index value -1 to change state for all items for a list view
  5467. (but only when lvoMultiselect style is applied to the list view, otherwise
  5468. index -1 is referring to the last item of the list view). }
  5469. property LVItemIndent[ Idx: Integer ]: Integer read LVGetItemIndent write LVSetItemIndent;
  5470. {* Item indentation. Indentation is calculated as this value multiplied to
  5471. image list ImgWidth value (Image list must be applied to list view).
  5472. Note: indentation supported only if IE3.0 or higher installed. }
  5473. property LVItemStateImgIdx[ Idx: Integer ]: Integer read LVGetSttImgIdx write LVSetSttImgIdx;
  5474. {* |<#listview>
  5475. Access to state image of the item. Use index -1 to assign the same state
  5476. image index to all items of the list view at once (fast).
  5477. Option lvoCheckBoxes just means, that control itself creates special inner
  5478. image list for two state images. Later it is possible to examine checked
  5479. state for items or set checked state programmatically by changing
  5480. LVItemStateImgIdx[ ] property. Value 1 corresponds to unchecked state,
  5481. 2 to checked. Value 0 allows to remove checkbox at all. So, to check all
  5482. added items by default (e.g.), do following:
  5483. ! ListView1.LVItemStateImgIdx[ -1 ] := 2;
  5484. |<br>Use 1-based index of the image
  5485. in image list ImageListState. Value 0 reserved to use as "no state image".
  5486. Values 1..15 can be used only - this is the Windows restriction on
  5487. state images. }
  5488. property LVItemOverlayImgIdx[ Idx: Integer ]: Integer read LVGetOvlImgIdx write LVSetOvlImgIdx;
  5489. {* |<#listview>
  5490. Access to overlay image of the item. Use index -1 to assign the same
  5491. overlay image to all items of the list view at once (fast). }
  5492. property LVItemData[ Idx: Integer ]: DWORD read LVGetItemData write LVSetItemData;
  5493. {* |<#listview>
  5494. Access to user defined data, assiciated with the item of the list view. }
  5495. procedure LVSelectAll;
  5496. {* |<#listview>
  5497. Call this method to select all the items of the list view control. }
  5498. property LVSelCount: Integer read GetSelLength write SetSelLength;
  5499. {* |<#listview>
  5500. Returns number of items selected in listview. }
  5501. property LVItemImageIndex[ Idx: Integer ]: Integer read LVGetItemImgIdx write LVSetItemImgIdx;
  5502. {* |<#listview>
  5503. Image index of items in listview. When an item is created (using LVItemAdd
  5504. or LVItemInsert), image index 0 is set by default (not -1 like in VCL!). }
  5505. property LVItems[ Idx, Col: Integer ]: String read LVGetItemText write LVSetItemText;
  5506. {* |<#listview>
  5507. Access to List View item text. }
  5508. {$IFNDEF _FPC}
  5509. {$IFNDEF _D2}
  5510. property LVItemsW[ Idx, Col: Integer ]: WideString read LVGetItemTextW write LVSetItemTextW;
  5511. {* |<#listview>
  5512. Access to List View item text. }
  5513. {$ENDIF _D2}
  5514. {$ENDIF _FPC}
  5515. function LVItemRect( Idx: Integer; Part: TGetLVItemPart ): TRect;
  5516. {* |<#listview>
  5517. Returns rectangle occupied by given item part(s) in ListView window.
  5518. Empty rectangle is returned, if the item is not viewing currently. }
  5519. function LVSubItemRect( Idx, ColIdx: Integer ): TRect;
  5520. {* |<#listview>
  5521. Returns rectangle occupied by given item's subitem in ListView window,
  5522. in lvsDetail or lvsDetailNoHeader style. Empty rectangle (0,0,0,0) is
  5523. returned if the item is not viewing currently. Left or/and right bounds
  5524. of the rectangle returned can be outbound item rectangle if only a part
  5525. of the subitem is visible or the subitem is not visible in the item,
  5526. which is visible itself. }
  5527. property LVItemPos[ Idx: Integer ]: TPoint read LVGetItemPos write LVSetItemPos;
  5528. {* |<#listview>
  5529. Position of List View item (can be changed in icon or small icon view). }
  5530. function LVItemAtPos( X, Y: Integer ): Integer;
  5531. {* |<#listview>
  5532. Return index of item at the given position. }
  5533. function LVItemAtPosEx( X, Y: Integer; var Where: TWherePosLVItem ): Integer;
  5534. {* |<#listview>
  5535. Retrieves index of item and sets in Where, what part of item is under
  5536. given coordinates. If there are no items at the specified position,
  5537. -1 is returned. }
  5538. procedure LVMakeVisible( Item: Integer; PartiallyOK: Boolean );
  5539. {* |<#listview>
  5540. Makes listview item visible. Ignred when Item passed < 0. }
  5541. procedure LVEditItemLabel( Idx: Integer );
  5542. {* |<#listview>
  5543. Begins in-place editing of item label (first column text). }
  5544. procedure LVSort;
  5545. {* |<#listview>
  5546. Initiates sorting of list view items. This sorting procedure is available only
  5547. for Win2K, WinNT4 with IE5, Win98 or Win95 with IE5. See also LVSortData. }
  5548. procedure LVSortData;
  5549. {* |<#listview>
  5550. Initiates sorting of list view items. This sorting procedure is always available
  5551. in Windows95/98, NT/2000. But OnCompareLVItems procedure receives not indexes of
  5552. items compared but its Data field associated instead. }
  5553. procedure LVSortColumn( Idx: Integer );
  5554. {* |<#listview>
  5555. This is a method to simplify sort by column. Just call it in your OnColumnClick
  5556. event passing column index and enjoy with your list view sorted automatically
  5557. when column header is clicked. Requieres Windows2000 or Winows98, not supported
  5558. under WinNT 4.0 and below and under Windows95.
  5559. |<br>
  5560. Either lvoSortAscending or lvoSortDescending option must be set in
  5561. LVOptions, otherwise no sorting is performed. }
  5562. function LVIndexOf( const S: String ): Integer;
  5563. {* Returns first list view item index with caption matching S.
  5564. The same as LVSearchFor( S, -1, FALSE ). }
  5565. {$IFNDEF _FPC}
  5566. {$IFNDEF _D2}
  5567. function LVIndexOfW( const S: WideString ): Integer;
  5568. {* Returns first list view item index with caption matching S.
  5569. The same as LVSearchForW( S, -1, FALSE ). }
  5570. {$ENDIF _D2}
  5571. {$ENDIF _FPC}
  5572. function LVSearchFor( const S: String; StartAfter: Integer; Partial: Boolean ): Integer;
  5573. {* Searches an item with Caption equal to S (or starting from S, if Partial = TRUE).
  5574. Searching is started after an item specified by StartAfter parameter. }
  5575. {$IFNDEF _FPC}
  5576. {$IFNDEF _D2}
  5577. function LVSearchForW( const S: WideString; StartAfter: Integer; Partial: Boolean ): Integer;
  5578. {* Searches an item with Caption equal to S (or starting from S, if Partial = TRUE).
  5579. Searching is started after an item specified by StartAfter parameter. }
  5580. {$ENDIF _D2}
  5581. {$ENDIF _FPC}
  5582. //======== List view page:
  5583. property LVTopItem: Integer index LVM_GETTOPINDEX read GetIntVal; //LVGetTopItem;
  5584. {* |<#listview>
  5585. Returns index of topmost visible item of ListView in lvsList view style. }
  5586. property LVPerPage: Integer index LVM_GETCOUNTPERPAGE read GetIntVal; //LVGetPerPage;
  5587. {* |<#listview>
  5588. Returns the number of fully-visible items if successful. If the current
  5589. view is icon or small icon view, the return value is the total number
  5590. of items in the list view control. }
  5591. //======== List View specific events:
  5592. property OnEndEditLVItem: TOnEditLVItem read fOnEditLVITem write SetOnEditLVItem;
  5593. {* |<#listview>
  5594. Called when edit of an item label in ListView control finished. Return
  5595. True to accept new label text, or false - to not accept it (item label
  5596. will not be changed). If handler not set to an event, all changes are
  5597. accepted. }
  5598. property OnDeleteLVItem: TOnDeleteLVItem read fOnDeleteLVItem write SetOnDeleteLVItem;
  5599. {* |<#listview>
  5600. Called for every deleted list view item. }
  5601. property OnDeleteAllLVItems: TOnEvent read fOnDeleteAllLVItems write SetOnDeleteAllLVItems;
  5602. {* |<#listview>
  5603. Called when all the items of the list view control are to be deleted. If after
  5604. returning from this event handler event OnDeleteLVItem is yet assigned,
  5605. an event OnDeleteLVItem will be called for every deleted item. }
  5606. property OnLVData: TOnLVData read fOnLVData write SetOnLVData;
  5607. {* |<#listview>
  5608. Called to provide virtual list view with actual data. To use list view as
  5609. virtaul list view, define also lvsOwnerData style and set Count property
  5610. to actual row count of the list view. This manner of working with list view
  5611. control can greatly improve performance of an application when working with
  5612. huge data sets represented in listview control. }
  5613. {$IFNDEF _FPC}
  5614. {$IFNDEF _D2}
  5615. property OnLVDataW: TOnLVDataW read fOnLVDataW write SetOnLVDataW;
  5616. {* |<#listview>
  5617. The same as OnLVData, but for unicode version of the list view allows
  5618. to return WideString text in the event handler. Though for unicode list
  5619. view it is still possible to use ordinary event OnLVData, it is
  5620. very recommended to use this event istead. }
  5621. {$ENDIF _D2}
  5622. {$ENDIF _FPC}
  5623. property OnCompareLVItems: TOnCompareLVItems read fOnCompareLVItems write fOnCompareLVItems;
  5624. {* |<#listview>
  5625. Event to compare two list view items during sort operation (initiated by
  5626. LVSort method call). Do not send any messages to the list view control
  5627. while it is sorting - results can be unpredictable! }
  5628. property OnColumnClick: TOnLVColumnClick read fOnColumnClick write SetOnColumnClick;
  5629. {* |<#listview>
  5630. This event handler is called when column of the list view control is clicked.
  5631. You can use this event to initiate sorting of list view items by this column. }
  5632. property OnLVStateChange: TOnLVStateChange read FOnLVStateChange write SetOnLVStateChange;
  5633. {* |<#listview>
  5634. This event occure when an item or items range in list view control are
  5635. changing its state (e.g. selected or unselected). }
  5636. property OnLVDelete: TOnLVDelete read FOnLVDelete write SetOnLVDelete;
  5637. {* |<#listview>
  5638. This event is called when an item is deleted in the listview.
  5639. Do not add, delete, or rearrange items in the list view while processing
  5640. this notification. }
  5641. property OnDrawItem: TOnDrawItem read fOnDrawItem write SetOnDrawItem;
  5642. {* |<#listview>
  5643. |<#listbox>
  5644. |<#combo>
  5645. This event can be used to implement custom drawing for list view, list box, dropped
  5646. list of a combobox. For a list view, custom drawing using this event is possible
  5647. only in lvsDetail and lvsDetailNoHeader styles, and OnDrawItem is called to draw
  5648. entire row at once only. See also OnLVCustomDraw event. }
  5649. property OnLVCustomDraw: TOnLVCustomDraw read FOnLVCustomDraw write SetOnLVCustomDraw;
  5650. {* |<#listview>
  5651. Custom draw event for listview. For every item to be drawn, this event
  5652. can be called several times during a single drawing cycle - depending on
  5653. a result, returned by an event handler. Stage can have one of following
  5654. values:
  5655. |<pre>
  5656. CDDS_PREERASE
  5657. CDDS_POSTERASE
  5658. CDDS_ITEMPREERASE
  5659. CDDS_PREPAINT
  5660. CDDS_ITEMPREPAINT
  5661. CDDS_ITEM
  5662. CDDS_SUBITEM + CDDS_ITEMPREPAINT
  5663. CDDS_SUBITEM + CDDS_ITEMPOSTPAINT
  5664. CDDS_ITEMPOSTPAINT
  5665. CDDS_POSTPAINT
  5666. </pre>
  5667. When called, see on Stage to get know, on what stage the event is
  5668. activated. And depend on the stage and on what you want to paint,
  5669. return a value as a result, which instructs the system, if to use
  5670. default drawing on this (and follows) stage(s) for the item, and if
  5671. to notify further about different stages of drawing the item during
  5672. this drawing cycle. Possible values to return are:
  5673. |<pre>
  5674. CDRF_DODEFAULT - perform default drawing. Do not notify further for this
  5675. item (subitem) (or for entire listview, if called with
  5676. flag CDDS_ITEM reset - ?);
  5677. CDRF_NOTIFYITEMDRAW - return this value, when the event is called the
  5678. first time in a cycle of drawing, with ItemIdx = -1 and
  5679. flag CDDS_ITEM reset in Stage parameter;
  5680. CDRF_NOTIFYPOSTERASE - usually can be used to provide default erasing,
  5681. if you want to perform drawing immediately after that;
  5682. CDRF_NOTIFYPOSTPAINT - return this value to provide calling the event
  5683. after performing default drawing. Useful when you wish
  5684. redraw only a part of the (sub)item;
  5685. CDRF_SKIPDEFAULT - return this value to inform the system that all
  5686. drawing is done and system should not peform any more
  5687. drawing for the (sub)item during this drawing cycle.
  5688. CDRF_NEWFONT - informs the system, that font is changed and default
  5689. drawing should be performed with changed font;
  5690. |</pre>
  5691. If you want to get notifications for each subitem, do not use option
  5692. lvoOwnerDrawFixed, because such style prevents system from notifying
  5693. the application for each subitem to be drawn in the listview and only
  5694. notifications will be sent about entire items.
  5695. |<br>
  5696. See also NM_CUSTOMDRAW in API Help.
  5697. }
  5698. procedure Set_LVItemHeight(Value: Integer);
  5699. function SetLVItemHeight(Value: Integer): PControl;
  5700. property LVItemHeight: Integer read fLVItemHeight write Set_LVItemHeight;
  5701. //======== TreeView specific properties and methods:
  5702. function TVInsert( nParent, nAfter: THandle; const Txt: String ): THandle;
  5703. {* |<#treeview>
  5704. Inserts item to a tree view. If nParent is 0 or TVI_ROOT, the item is
  5705. inserted at the root of tree view. It is possible to pass following special
  5706. values as nAfter parameter:
  5707. |<pre>
  5708. TVI_FIRST Inserts the item at the beginning of the list.
  5709. TVI_LAST Inserts the item at the end of the list.
  5710. TVI_SORT Inserts the item into the list in alphabetical order.
  5711. |</pre> }
  5712. {$IFNDEF _FPC}
  5713. {$IFNDEF _D2}
  5714. function TVInsertW( nParent, nAfter: THandle; const Txt: WideString ): THandle;
  5715. {* |<#treeview>
  5716. Inserts item to a tree view. If nParent is 0 or TVI_ROOT, the item is
  5717. inserted at the root of tree view. It is possible to pass following special
  5718. values as nAfter parameter:
  5719. |<pre>
  5720. TVI_FIRST Inserts the item at the beginning of the list.
  5721. TVI_LAST Inserts the item at the end of the list.
  5722. TVI_SORT Inserts the item into the list in alphabetical order.
  5723. |</pre><br>
  5724. This version of the method is Unicode. The tree view control should be
  5725. set up as unicode control calling Perform( TVM_SETUNICODEFORMAT, 1, 0 ),
  5726. and conditional symbol UNICODE_CTRLS must be defined to provide event
  5727. handling for such kind of tree view (and other Unicode) controls. }
  5728. {$ENDIF _D2}
  5729. {$ENDIF _FPC}
  5730. procedure TVDelete( Item: THandle );
  5731. {* |<#treeview>
  5732. Removes an item from the tree view. If value TVI_ROOT is passed, all items
  5733. are removed. }
  5734. property TVSelected: THandle index TVGN_CARET read TVGetItemIdx write TVSetItemIdx;
  5735. {* |<#treeview>
  5736. Returns or sets currently selected item handle in tree view. }
  5737. property TVDropHilighted: THandle index TVGN_DROPHILITE read TVGetItemIdx write TVSetItemIdx;
  5738. {* |<#treeview>
  5739. Returns or sets item, which is currently highlighted as a drop target. }
  5740. property TVDropHilited: THandle index TVGN_DROPHILITE read TVGetItemIdx write TVSetItemIdx;
  5741. {* The same as TVDropHilighted. }
  5742. property TVFirstVisible: THandle index TVGN_FIRSTVISIBLE read TVGetItemIdx write TVSetItemIdx;
  5743. {* |<#treeview>
  5744. Returns or sets given item to top of tree view. }
  5745. property TVIndent: Integer index TVM_GETINDENT read GetIntVal write SetIntVal;
  5746. {* |<#treeview>
  5747. The amount, in pixels, that child items are indented relative to their
  5748. parent items. }
  5749. property TVVisibleCount: Integer index TVM_GETVISIBLECOUNT read GetIntVal;
  5750. {* |<#treeview>
  5751. Returns number of fully (not partially) visible items in tree view. }
  5752. property TVRoot: THandle index TVGN_ROOT read TVGetItemIdx;
  5753. {* |<#treeview>
  5754. Returns handle of root item in tree view (or 0, if tree is empty). }
  5755. property TVItemChild[ Item: THandle ]: THandle index TVGN_CHILD read TVGetItemNext;
  5756. {* |<#treeview>
  5757. Returns first child item for given one. }
  5758. property TVItemHasChildren[ Item: THandle ]: Boolean read TV_GetItemHasChildren write TV_SetItemHasChildren;
  5759. {* |<#treeview>
  5760. TRUE, if an Item has children. Set this value to true if you want to
  5761. force [+] sign appearing left from the node, even if there are no
  5762. subnodes added to the node yet. }
  5763. property TVItemChildCount[ Item: THandle ]: Integer read TV_GetItemChildCount;
  5764. {* |<#treeview>
  5765. Returns number of node child items in tree view.
  5766. }
  5767. property TVItemNext[ Item: THandle ]: THandle index TVGN_NEXT read TVGetItemNext;
  5768. {* |<#treeview>
  5769. Returns next sibling item handle for given one (or 0, if passed item is
  5770. the last child for its parent node). }
  5771. property TVItemPrevious[ Item: THandle ]: THandle index TVGN_PREVIOUS read TVGetItemNext;
  5772. {* |<#treeview>
  5773. Returns previous sibling item (or 0, if the is no such item). }
  5774. property TVItemNextVisible[ Item: THandle ]: THandle index TVGN_NEXTVISIBLE read TVGetItemNext;
  5775. {* |<#treeview>
  5776. Returns next visible item (passed item must be visible too, to determine,
  5777. if it is really visible, use property TVItemRect or TVItemVisible. }
  5778. property TVItemPreviousVisible[ Item: THandle ]: THandle index TVGN_PREVIOUSVISIBLE read TVGetItemNext;
  5779. {* |<#treeview>
  5780. Returns previous visible item. }
  5781. property TVItemParent[ Item: THandle ]: THandle index TVGN_PARENT read TVGetItemNext;
  5782. {* |<#treeview>
  5783. Returns parent item for given one (or 0 for root item). }
  5784. property TVItemText[ Item: THandle ]: String read TVGetItemText write TVSetItemText;
  5785. {* |<#treeview>
  5786. Text of tree view item. }
  5787. {$IFNDEF _FPC}
  5788. {$IFNDEF _D2}
  5789. property TVItemTextW[ Item: THandle ]: WideString read TVGetItemTextW write TVSetItemTextW;
  5790. {* |<#treeview>
  5791. Text of tree view item. }
  5792. {$ENDIF _D2}
  5793. {$ENDIF _FPC}
  5794. function TVItemPath( Item: THandle; Delimiter: Char ): String;
  5795. {* |<#treeview>
  5796. Returns full path from the root item to given item. Path is calculated
  5797. as a concatenation of all parent nodes text strings, separated by
  5798. given delimiter character.
  5799. |<br>Please note, that returned path has no trailing delimiter, this
  5800. character is only separating different parts of the path.
  5801. |<br>If Item is not specified ( =0 ), path is returned
  5802. for Selected item. }
  5803. {$IFNDEF _FPC}
  5804. {$IFNDEF _D2}
  5805. function TVItemPathW( Item: THandle; Delimiter: WideChar ): WideString;
  5806. {* |<#treeview>
  5807. Returns full path from the root item to given item. Path is calculated
  5808. as a concatenation of all parent nodes text strings, separated by
  5809. given delimiter character. If Item is not specified ( =0 ), path is returned
  5810. for Selected item. }
  5811. {$ENDIF _D2}
  5812. {$ENDIF _FPC}
  5813. property TVItemRect[ Item: THandle; TextOnly: Boolean ]: TRect read TVGetItemRect;
  5814. {* |<#treeview>
  5815. Returns rectangle, occupied by an item in tree view. }
  5816. property TVItemVisible[ Item: THandle ]: Boolean read TVGetItemVisible write TVSetITemVisible;
  5817. {* |<#treeview>
  5818. Returs True, if item is visible in tree view. It is also possible to
  5819. assign True to this property to ensure that a tree view item is visible
  5820. (if False is assigned, this does nothing). }
  5821. function TVItemAtPos( x, y: Integer; var Where: DWORD ): THandle;
  5822. {* |<#treeview>
  5823. Returns handle of item found at specified position (relative to upper left
  5824. corener of client area of the tree view). If no item found, 0 is returned.
  5825. Variable Where receives additional flags combination, describing more
  5826. detailed, on which part of item or tree view given point is located,
  5827. such as:
  5828. |<pre>
  5829. TVHT_ABOVE Above the client area
  5830. TVHT_BELOW Below the client area
  5831. TVHT_NOWHERE In the client area, but below the last item
  5832. TVHT_ONITEM On the bitmap or label associated with an item
  5833. TVHT_ONITEMBUTTON On the button associated with an item
  5834. TVHT_ONITEMICON On the bitmap associated with an item
  5835. TVHT_ONITEMINDENT In the indentation associated with an item
  5836. TVHT_ONITEMLABEL On the label (string) associated with an item
  5837. TVHT_ONITEMRIGHT In the area to the right of an item
  5838. TVHT_ONITEMSTATEICON On the state icon for a tree-view item that is in a user-defined state
  5839. TVHT_TOLEFT To the right of the client area
  5840. TVHT_TORIGHT To the left of the client area
  5841. |</pre> }
  5842. property TVRightClickSelect: Boolean read fTVRightClickSelect write SetTVRightClickSelect;
  5843. {* |<#treeview>
  5844. Set this property to True to allow change selection to an item, clicked with right mouse button. }
  5845. property TVEditing: Boolean read fEditing;
  5846. {* |<#treeview>
  5847. Returns True, if tree view control is editing its item label. }
  5848. property TVItemBold[ Item: THandle ]: Boolean index TVIS_BOLD read TVGetItemStateFlg write TVSetItemStateFlg;
  5849. {* |<#treeview>
  5850. True, if item is bold. }
  5851. property TVItemCut[ Item: THandle ]: Boolean index TVIS_CUT read TVGetITemStateFlg write TVSetItemStateFlg;
  5852. {* |<#treeview>
  5853. True, if item is selected as part of "cut and paste" operation. }
  5854. property TVItemDropHighlighted[ Item: THandle ]: Boolean index TVIS_DROPHILITED read TVGetITemStateFlg write TVSetItemStateFlg;
  5855. {* |<#treeview>
  5856. True, if item is selected as drop target. }
  5857. property TVItemDropHilited[ Item: THandle ]: Boolean index TVIS_DROPHILITED read TVGetITemStateFlg write TVSetItemStateFlg;
  5858. {* The same as TVItemDropHighlighted. }
  5859. property TVItemExpanded[ Item: THandle ]: Boolean index TVIS_EXPANDED read TVGetITemStateFlg; // write TVSetItemStateFlg;
  5860. {* |<#treeview>
  5861. True, if item's list of child items is currently expanded. To change
  5862. expanded state, use method TVExpand. }
  5863. property TVItemExpandedOnce[ Item: THandle ]: Boolean index TVIS_EXPANDEDONCE read TVGetITemStateFlg; // write TVSetItemStateFlg;
  5864. {* |<#treeview>
  5865. True, if item's list of child items has been expanded at least once. }
  5866. property TVItemSelected[ Item: THandle ]: Boolean index TVIS_SELECTED read TVGetITemStateFlg write TVSetItemStateFlg;
  5867. {* |<#treeview>
  5868. True, if item is selected. }
  5869. procedure TVExpand( Item: THandle; Flags: DWORD );
  5870. {* |<#treeview>
  5871. Call it to expand/collapse item's child nodes. Possible values for Flags
  5872. parameter are:
  5873. <pre>
  5874. TVE_COLLAPSE Collapses the list.
  5875. TVE_COLLAPSERESET Collapses the list and removes the child items. Note
  5876. that TVE_COLLAPSE must also be specified.
  5877. TVE_EXPAND Expands the list.
  5878. TVE_TOGGLE Collapses the list if it is currently expanded or
  5879. expands it if it is currently collapsed.
  5880. </pre>
  5881. }
  5882. procedure TVSort( N: THandle );
  5883. {* |<#treeview>
  5884. By Alex Mokrov. Sorts treeview. If N = 0, entire treeview is sorted.
  5885. Otherwise, children of the given node only.
  5886. }
  5887. property TVItemImage[ Item: THandle ]: Integer index TVIF_IMAGE read TVGetItemImage write TVSetItemImage;
  5888. {* |<#treeview>
  5889. Image index for an item of tree view. To tell that there are no image
  5890. set, use index -2 (value -1 is reserved for callback image). }
  5891. property TVItemSelImg[ Item: THandle ]: Integer index TVIF_SELECTEDIMAGE read TVGetItemImage write TVSetItemImage;
  5892. {* |<#treeview>
  5893. Image index for an item of tree view in selected state. Use value -2 to
  5894. provide no image, -1 used for callback image. }
  5895. property TVItemOverlay[ Item: THandle ]: Integer index TVIS_OVERLAYMASK or $80000
  5896. read TVGetItemImage write TVSetItemImage;
  5897. {* |<#treeview>
  5898. Overlay image index for an item in tree view. }
  5899. property TVItemStateImg[ Item: THandle ]: Integer index TVIS_STATEIMAGEMASK or $C0000
  5900. read TVGetItemImage write TVSetItemImage;
  5901. {* |<#treeview>
  5902. State image index for an item in tree view. Use 1-based index of the image
  5903. in image list ImageListState. Value 0 reserved to use as "no state image".
  5904. Values 1..15 can be used only - this is the Windows restriction on
  5905. state images. }
  5906. property TVItemData[ Item: THandle ]: Pointer read TVGetItemData write TVSetItemData;
  5907. {* |<#treeview>
  5908. Stores any program-defined pointer with the item. }
  5909. procedure TVEditItem( Item: THandle );
  5910. {* |<#treeview>
  5911. Begins editing given item label in tree view. }
  5912. procedure TVStopEdit( Cancel: Boolean );
  5913. {* |<#treeview>
  5914. Ends editing item label, started by user or explicitly by TVEditItem method. }
  5915. property OnTVBeginDrag: TOnTVBeginDrag read fOnTVBeginDrag write fOnTVBeginDrag;
  5916. {* |<#treeview>
  5917. Is called for tree view, when its item is to be dragging. }
  5918. property OnTVBeginEdit: TOnTVBeginEdit read fOnTVBeginEdit write fOnTVBeginEdit;
  5919. {* |<#treeview>
  5920. Is called for tree view, when its item label is to be editing. }
  5921. property OnTVEndEdit: TOnTVEndEdit read fOnTVEndEdit write fOnTVEndEdit;
  5922. {* |<#treeview>
  5923. Is called when item label is edited. It is possible to cancel
  5924. edit, returning False as a result. }
  5925. property OnTVExpanding: TOnTVExpanding read fOnTVExpanding write fOnTVExpanding;
  5926. {* |<#treeview>
  5927. Is called just before expanding/collapsing item. It is possible to
  5928. return False to prevent expanding item. }
  5929. property OnTVExpanded: TOnTVExpanded read fOnTVExpanded write fOnTVExpanded;
  5930. {* |<#treeview>
  5931. Is called after expanding/collapsing item children. }
  5932. property OnTVDelete: TOnTVDelete read fOnTVDelete write SetOnTVDelete;
  5933. {* |<#treeview>
  5934. Is called just before deleting item. You may use this event to free
  5935. resources, associated with an item (see TVItemData property). }
  5936. //----------------- by Sergey Shisminzev:
  5937. property OnTVSelChanging: TOnTVSelChanging read fOnTVSelChanging write fOnTVSelChanging;
  5938. {* |<#treeview>
  5939. Is called before changing the selection. The handler can return FALSE
  5940. to prevent changing the selection. }
  5941. //--------------------------------------
  5942. //======== Toolbar specific methods:
  5943. procedure TBAddBitmap( Bitmap: HBitmap );
  5944. {* |<#toolbar>
  5945. Adds bitmaps to a toolbar. You can pass special values as Bitmap to
  5946. add one of predefined system button images bitmaps:
  5947. |<br> THandle(-1) to add standard small icons,
  5948. |<br> THandle(-2) to add standard large icons,
  5949. |<br> THandle(-5) to add standard small view icons,
  5950. |<br> THandle(-6) to add standard large view icons,
  5951. |<br> THandle(-9) to add standard small view icons,
  5952. |<br> THandle(-10) to add standard large view icons,
  5953. (in that case use following values as indexes to the standard and view
  5954. bitmaps:
  5955. |<br>
  5956. STD_COPY, STD_CUT, STD_DELETE, STD_FILENEW, STD_FILEOPEN, STD_FILESAVE,
  5957. STD_FIND, STD_HELP, STD_PASTE, STD_PRINT, STD_PRINTPRE, STD_PROPERTIES,
  5958. STD_REDO, STD_REPLACE, STD_UNDO,
  5959. |<br>
  5960. VIEW_LARGEICONS, VIEW_SMALLICONS,
  5961. VIEW_LIST, VIEW_DETAILS, VIEW_SORTNAME, VIEW_SORTSIZE, VIEW_SORTDATE,
  5962. VIEW_SORTTYPE (use it as parameters BtnImgIdxArray in TBAddButtons or
  5963. TBInsertButtons methods, and in assigning value to TBButtonImage[ ]
  5964. property).
  5965. Added bitmaps have indeces starting from previous count of images
  5966. (as these are appended to existing - if any).
  5967. |<br>
  5968. Note, that if You add your own (custom) bitmap, it is not transparent.
  5969. Do not assume that clSilver is always equal to clBtnFace. Use API
  5970. function CreateMappedBitmap to load bitmap from resource and map
  5971. desired colors as you wish (e.g., convert clTeal to clBtnFace). Or,
  5972. call defined in KOL function LoadMappedBitmap to do the same more easy.
  5973. Unfortunately, resource identifier for bitmap to pass it to LoadMappedBitmap
  5974. or to CreateMappedBitmap seems must be integer, so it is necessary to
  5975. create rc-file manually and compile using Borland Resource Compiler to
  5976. figure it out. }
  5977. function TBAddButtons( const Buttons: array of PChar; const BtnImgIdxArray: array
  5978. of Integer ): Integer;
  5979. {* |<#toolbar>
  5980. Adds buttons to toolbar. Last string in Buttons array *must* be empty
  5981. ('' or nil), so to add buttons without text, pass ' ' string (one space
  5982. char). It is not necessary to provide image indexes for all
  5983. buttons (it is sufficient to assign index for first button only).
  5984. But in place, correspondent to separator button (defined by string '-'),
  5985. any integer must be passed to assign follow image indexes correctly.
  5986. See example.
  5987. |*Toolbar adding buttons sample.
  5988. Code below shows how to call TBAddButtons method to add two buttons with
  5989. a separator between these buttons. idxNew and idxOld are integer
  5990. expressions assigning image indexes to buttons 'New' and 'Old'. This
  5991. indexes are zero-based and refer to bitmap images, added earlier (either
  5992. in creating toolbar by call of NewToolbar or later in call of TBAddBitmap).
  5993. !
  5994. ! TBAddButtons( [ '&New', '-', '&Old', '' ], [ idxNew, 0, idxOld ] );
  5995. !
  5996. |*
  5997. To add check buttons, use prefix '+' or '-' in button definition
  5998. string. If next character is '!', such buttons are grouped to a
  5999. radio-group. Also, it is possible to use '^' prefix (must be first) to
  6000. define button with small drop-down section (use also OnTBDropDown event
  6001. to respond to clicking drop down section of such buttons).
  6002. |<br>
  6003. This function returns command id for first added button (other
  6004. id's can be calculated incrementing the result by one for each
  6005. button, except separators, which have no command id).
  6006. |<br>
  6007. Note: for static toolbar (single in application and created
  6008. once) ids are started from value 100. }
  6009. function TBInsertButtons( BeforeIdx: Integer; Buttons: array of PChar;
  6010. BtnImgIdxArray: array of Integer ): Integer;
  6011. {* |<#toolbar>
  6012. Inserts buttons before button with given index on toolbar. Returns
  6013. command identifier for first button inserted (other can be calculated
  6014. incrementing returned value needed times. See also TBAddButtons. }
  6015. procedure TBDeleteButton( BtnID: Integer );
  6016. {* |<#toolbar>
  6017. Deletes single button given by its command id. To delete separator,
  6018. use TBDeleteBtnByIdx instead. }
  6019. procedure TBDeleteBtnByIdx( Idx: Integer );
  6020. {* |<#toolbar>
  6021. Deletes single button given by its index in toolbar (not by command ID). }
  6022. procedure TBAssignEvents( BtnID: Integer; Events: array of TOnToolbarButtonClick );
  6023. {* |<#toolbar>
  6024. Allows to assign separate OnClick events for every toolbar button.
  6025. BtnID should be toolbar button ID or index of the first button to
  6026. assign event. If it is an ID, events are assigned to buttons in
  6027. creation order. Otherwise, events are assigned in placement order.
  6028. Anyway, separator buttons are not skipped, so pass at least nil for such
  6029. button as an event.
  6030. |<br>
  6031. Please note, that though not all buttons should exist before
  6032. assigning events to it, therefore at least the first button
  6033. (specified by BtnID) must be already added before calling TBAssignEvents. }
  6034. procedure TBResetImgIdx( BtnID, BtnCount: Integer );
  6035. {* |<#toolbar>
  6036. Resets image index for BtnCount buttons starting from BtnID. }
  6037. property CurItem: Integer read fCurItem;
  6038. {* |<#toolbar>
  6039. For toolbar, in OnClick event this property can be used to determine
  6040. which button was clicked (100-based button id in toolbar). It is also
  6041. possible to use CurIndex property (zero-based) for this purpose as
  6042. well, but do not assume, that CurItem always equal to CurIndex+100.
  6043. At least, it is possible to call TBItem2Index function to convert
  6044. button ID to its index in toolbar.
  6045. |<br>
  6046. In case, when button (or toolbar itself) is clicked using right
  6047. mouse button, CurItem and CurIndex are always set to -1. To further
  6048. determine which button was clicked, get mouse coordinates on screen,
  6049. apply Screen2Client method of toolbar control to it and then use
  6050. TBButtonAtPos function to determine which button was under cursor.
  6051. }
  6052. property TBButtonCount: Integer read GetItemsCount; //TBGetButtonCount;
  6053. {* |<#toolbar>
  6054. Returns count of buttons on toolbar. The same as Count. }
  6055. property TBBtnImgWidth: Integer read fTBBtnImgWidth write fTBBtnImgWidth;
  6056. {* |<#toolbar>
  6057. Custom toolbar buttons width. Set it before assigning buttons bitmap.
  6058. Changing this property after assigning the bitmap has no effect. }
  6059. function TBItem2Index( BtnID: Integer ): Integer;
  6060. {* |<#toolbar>
  6061. Converts button command id to button index for tool bar. }
  6062. function TBIndex2Item( Idx: Integer ): Integer;
  6063. {* |<#toolbar>
  6064. Converts toolbar button index to its command ID. }
  6065. procedure TBConvertIdxArray2ID( const IdxVars: array of PDWORD );
  6066. {* |<#toolbar>
  6067. Converts toolbar button indexes to its command IDs for an array
  6068. of indexes (each item in the array passed is a pointer to
  6069. Integer, containing button index when the procedure is callled,
  6070. then all these indexes are relaced with a correspondent button ID).}
  6071. property TBButtonEnabled[ BtnID: Integer ]: Boolean index TB_ENABLEBUTTON
  6072. read TBGetBtnStt write TBSetBtnStt;
  6073. {* |<#toolbar>
  6074. Obvious. }
  6075. property TBButtonVisible[ BtnID: Integer ]: Boolean read TBGetButtonVisible
  6076. write TBSetButtonVisible;
  6077. {* |<#toolbar>
  6078. Allows to hide/show some of toolbar buttons. }
  6079. property TBButtonChecked[ BtnID: Integer ]: Boolean index TB_CHECKBUTTON
  6080. read TBGetBtnStt write TBSetBtnStt;
  6081. {* |<#toolbar>
  6082. Allows to determine 'checked' state of a button (e.g., radio-button),
  6083. and to check it programmatically. }
  6084. property TBButtonMarked[ BtnID: Integer ]: Boolean index TB_MARKBUTTON
  6085. read TBGetBtnStt write TBSetBtnStt;
  6086. {* |<#toolbar>
  6087. Returns True if toolbar button is marked (highlighted). Allows to
  6088. highlight buttons assigning True to this value. }
  6089. property TBButtonPressed[ BtnID: Integer ]: Boolean index TB_PRESSBUTTON
  6090. read TBGetBtnStt write TBSetBtnStt;
  6091. {* |<#toolbar>
  6092. Allows to detrmine if toolbar button (given by its command ID) pressed,
  6093. and press/unpress it programmatically. }
  6094. property TBButtonText[ BtnID: Integer ]: String read TBGetButtonText write TBSetButtonText;
  6095. {* |<#toolbar>
  6096. Obtains toolbar button text and allows to change it. Be sure that text
  6097. is not empty for all buttons, if You want for it to be shown (if at least
  6098. one button has empty text, no text labels will be shown at all). At
  6099. least set it to ' ' for buttons, which You do not want to show labels,
  6100. if You want from other ones to have it. }
  6101. property TBButtonImage[ BtnID: Integer ]: Integer read TBGetBtnImgIdx write TBSetBtnImgIdx;
  6102. {* |<#toolbar>
  6103. Allows to access/change button image. Do not read this property for
  6104. separator buttons, returning value is not proper. If you do not know,
  6105. is the button a separator, using function below. }
  6106. function TBButtonSeparator( BtnID: Integer ): Boolean;
  6107. {* |<#toolbar>
  6108. Returns TRUE, if a toolbar button is separator. }
  6109. property TBButtonRect[ BtnID: Integer ]: TRect read TBGetButtonRect;
  6110. {* |<#toolbar>
  6111. Obtains rectangle occupied by toolbar button in toolbar window.
  6112. (It is not possible to obtain rectangle for buttons, currently
  6113. not visible). }
  6114. property TBButtonWidth[ BtnID: Integer ]: Integer read TBGetBtnWidth write TBSetBtnWidth;
  6115. {* |<#toolbar>
  6116. Allows to obtain / change toolbar button width. }
  6117. property TBButtonsMinWidth: Integer index 0
  6118. {$IFDEF F_P} read TBGetBtMinMaxWidth
  6119. {$ELSE DELPHI} read FTBBtMinWidth
  6120. {$ENDIF F_P/DELPHI} write TBSetBtMinMaxWidth;
  6121. {* |<#toolbar>
  6122. Allows to set minimal width for all toolbar buttons. }
  6123. property TBButtonsMaxWidth: Integer index 1
  6124. {$IFDEF F_P} read TBGetBtMinMaxWidth
  6125. {$ELSE DELPHI} read FTBBtMaxWidth
  6126. {$ENDIF F_P/DELPHI} write TBSetBtMinMaxWidth;
  6127. {* |<#toolbar>
  6128. Allows to set maximal width for all toolbar buttons. }
  6129. function TBButtonAtPos( X, Y: Integer ): Integer;
  6130. {* |<#toolbar>
  6131. Returns command ID of button at the given position on toolbar,
  6132. or -1, if there are no button at the position. Value 0 is returned
  6133. for separators. }
  6134. function TBBtnIdxAtPos( X, Y: Integer ): Integer;
  6135. {* |<#toolbar>
  6136. Returns index of button at the given position on toolbar.
  6137. This also can be index of separator button. -1 is returned if
  6138. there are no buttons found at the position. }
  6139. function TBMoveBtn( FromIdx, ToIdx: Integer ): Boolean;
  6140. {* |<#toolbar>
  6141. By TR"]F. Moves button from one position to another. }
  6142. property TBRows: Integer read TBGetRows write TBSetRows;
  6143. {* |<#toolbar>
  6144. Returns number of rows for toolbar and allows to try to set
  6145. desired number of rows (but system can set another number of
  6146. rows in some cases). This property has no effect if tboWrapable
  6147. style not present in Options when toolbar is created. }
  6148. procedure TBSetTooltips( BtnID1st: Integer; Tooltips: array of PChar );
  6149. {* |<#toolbar>
  6150. Allows to assign tooltips to several buttons. Until this procedure
  6151. is not called, tooltips list is not created and no code is added
  6152. to executable. This method of tooltips maintainance for toolbar buttons
  6153. is useful both for static and dynamic toolbars (meaning "dynamic" -
  6154. toolbars with buttons, deleted and inserted at run-time). }
  6155. property OnTBDropDown: TOnEvent read fOnDropDown write fOnDropDown;
  6156. {* |<#toolbar>
  6157. This event is called for drop down buttons, when user click drop part
  6158. of drop down button. To determine for which button event is called,
  6159. look at CurItem or CurIndex property. It is also possible to use
  6160. common (with combobox) property OnDropDown. }
  6161. property OnTBClick: TOnEvent read fOnClick write fOnClick;
  6162. {* |<#toolbar>
  6163. The same as OnClick. }
  6164. //================== RichEdit specific: ==================
  6165. property MaxTextSize: DWORD read GetMaxTextSize write SetMaxTextSize;
  6166. {* |<#richedit>
  6167. This property valid also for simple edit control, not only for RichEdit.
  6168. But for usual edit control, maximum text size available is 32K. For
  6169. RichEdit, limit is 4Gb. By default, RichEdit is limited to
  6170. 32767 bytes (to set maximum size available to 2Gb, assign MaxInt value
  6171. to a property). Also, to get current text size of RichEdit, use property
  6172. TextSize or RE_TextSize[ ]. }
  6173. property TextSize: Integer read GetTextSize;
  6174. {* |<#richedit>
  6175. Common for edit and rich edit controls property, which returns size of
  6176. text in edit control. Also, for any other control (or form, or applet
  6177. window) returns size (in characters) of Caption or Text (what is, the
  6178. same property actually). }
  6179. property RE_TextSize[ Units: TRichTextSize ]: Integer read REGetTextSize;
  6180. {* |<#richedit>
  6181. For RichEdit control, it returns text size, measured in desired units
  6182. (rtsChars - characters, including OLE objects, counted as a single
  6183. character; rtsBytes - presize length of text image (if it would be stored
  6184. in file or stream). Please note, that for RichEdit1.0, only size in
  6185. characters can be obtained. }
  6186. function RE_TextSizePrecise: Integer;
  6187. {* |<#richedit>
  6188. By Savva. Returns length of rich edit text. }
  6189. property RE_CharFmtArea: TRichFmtArea read fRECharArea write fRECharArea;
  6190. {* |<#richedit>
  6191. By default, this property is raSelection. Changing it, You determine in
  6192. for which area characters format is applyed, when changing
  6193. character formatting properties below (not paragraph formatting).
  6194. |&A=<a href=#RE_CharFmtArea target=main>%0</a>
  6195. }
  6196. property RE_CharFormat: TCharFormat read REGetCharformat write RESetCharFormat;
  6197. {* |<#richedit>
  6198. In differ to follow properties, which allow to control certain formatting
  6199. attributes, this property provides low level access for formatting current
  6200. character area (see RE_CharFmtArea). It returns TCharFormat structure,
  6201. filled in with formatting attributes, and by assigning another value to
  6202. this property You can change desired attributes as You wish. Even if
  6203. RichEdit1.0 is used, TCharFormat2 is returned (but extended fields are
  6204. ignored for RichEdit1.0). }
  6205. property RE_Font: PGraphicTool read REGetFont write RESetFont;
  6206. {* |<#richedit>
  6207. Font of the first character in current selection (when retrieve).
  6208. When set (or subproperties of RE_Font are set), all font attributes are
  6209. applied to entire <A area>. To apply only needed attributes, use another
  6210. properties: RE_FmtBold, RE_FmtItalic, RE_FmtStrikeout, RE_FmtUnderline,
  6211. RE_FmtName, etc.
  6212. |<br>
  6213. Note, that font size is measured in twips, which is about 1/10 of pixel. }
  6214. property RE_FmtBold: Boolean index CFM_BOLD read REGetFontEffects write RESetFontEffect;
  6215. {* |<#richedit>
  6216. Formatting flag. When retrieve, returns True, if fsBold style RE_Font.FontStyle
  6217. is valid for a first character in the selection. When set, changes fsBold
  6218. style (True - set, False - reset) for all characters in <A area>. }
  6219. property RE_FmtBoldValid: Boolean index CFM_BOLD read REGetFontMask;
  6220. {* }
  6221. property RE_FmtItalic: Boolean index CFM_ITALIC read REGetFontEffects write RESetFontEffect;
  6222. {* |<#richedit>
  6223. Formatting flag. Like RE_FmtBold, when retrieving, shows, is fsItalic
  6224. style valid for the first character of the selection, and when set, changes
  6225. only fsItalic style for an <A area>. }
  6226. property RE_FmtItalicValid: Boolean index CFM_ITALIC read REGetFontMask;
  6227. {* }
  6228. property RE_FmtStrikeout: Boolean index CFM_STRIKEOUT read REGetFontEffects write RESetFontEffect;
  6229. {* |<#richedit>
  6230. Formatting flag. Like RE_FmtBold, when retrieving, shows, is fsStrikeout
  6231. style valid for the first selected character, and when set, changes only
  6232. fsStrikeout style for an <A area>. }
  6233. property RE_FmtStrikeoutValid: Boolean index CFM_STRIKEOUT read REGetFontMask;
  6234. {* }
  6235. property RE_FmtUnderline: Boolean index CFM_UNDERLINE read REGetFontEffects write RESetFontEffect;
  6236. {* |<#richedit>
  6237. Formatting flag. Like RE_FmtBold, when retrieving, shows, is fsUnderline
  6238. style valid for the first selected character, and when set, changes
  6239. fsUnderline style for an <A area>. }
  6240. property RE_FmtUnderlineValid: Boolean index CFM_UNDERLINE read REGetFontMask;
  6241. {* }
  6242. property RE_FmtUnderlineStyle: TRichUnderline
  6243. read REGetUnderlineEx write RESetUnderlineEx;
  6244. {* |<#richedit>
  6245. Extended underline style. To check, if this property is valid for
  6246. entire selection, examine RE_FmtUnderlineValid value. }
  6247. property RE_FmtProtected: Boolean index CFM_PROTECTED read REGetFontEffects write RESetFontEffect;
  6248. {* |<#richedit>
  6249. Formatting flag. When retrieving, shows, is the first character of the selection
  6250. is protected from changing it by user (True) or not (False). To get know,
  6251. if retrived value is valid for entire selection, check the property
  6252. RE_FmtProtectedValid. When set, makes all characters in <A area> protected (
  6253. True) or not (False). }
  6254. property RE_FmtProtectedValid: Boolean index CFM_PROTECTED read REGetFontMask;
  6255. {* |<#richedit>
  6256. True, if property RE_FmtProtected is valid for entire selection, when
  6257. retrieving it. }
  6258. property RE_FmtHidden: Boolean index CFM_HIDDEN read REGetFontEffects write RESetFontEffect;
  6259. {* |<#richedit>
  6260. For RichEdit3.0, makes text hidden (not displayed). }
  6261. property RE_FmtHiddenValid: Boolean index CFM_HIDDEN read REGetFontMask;
  6262. {* |<#richedit>
  6263. Returns True, if RE_FmtHidden style is valid for entire selection. }
  6264. property RE_FmtLink: Boolean index $20 {CFM_LINK} read REGetFontEffects write RESetFontEffect;
  6265. {* |<#richedit>
  6266. Returns True, if the first selected character is a part of link (URL). }
  6267. // by Sergey Shisminzev
  6268. property RE_FmtLinkValid: Boolean index $20 {CFM_LINK} read REGetFontMask;
  6269. {* }
  6270. property RE_FmtFontSize: Integer index (12 shl 16) or CFM_SIZE read REGetFontAttr write RESetFontAttr;
  6271. {* |<#richedit>
  6272. Formatting value: font size, in twips (1/1440 of an inch, or 1/20 of a
  6273. printer's point, or about 1/10 of pixel). When retrieving, returns
  6274. RE_Font.FontHeight.
  6275. When set, changes font size for entire <A area> (but does not change
  6276. other font attributes). }
  6277. property RE_FmtFontSizeValid: Boolean read REGetFontSizeValid;
  6278. {* |<#richedit>
  6279. Returns True, if property RE_FmtFontSize is valid for entire selection,
  6280. when retrieving it. }
  6281. //property RE_FmtBackColor: Integer index (62 shl 16) or CFM_BACKCOLOR read REGetFontAttr write RESetFontAttr1;
  6282. {* |<#richedit>
  6283. Background color for an <A area>. }
  6284. //property RE_FmtBackColorValid: Boolean index CFM_BACKCOLOR read REGetFontEffect;
  6285. {* |<#richedit>
  6286. True, if RE_FmtBackColor valid for entire <A area>. }
  6287. property RE_FmtAutoBackColor: Boolean index CFM_BACKCOLOR read REGetFontEffects write RESetFontEffect;
  6288. {* |<#richedit>
  6289. True, when automatic back color is used. }
  6290. property RE_FmtAutoBackColorValid: Boolean index CFM_BACKCOLOR read REGetFontMask;
  6291. {* }
  6292. property RE_FmtFontColor: Integer index (20 shl 16) or CFM_COLOR read REGetFontAttr write RESetFontAttr1;
  6293. {* |<#richedit>
  6294. Formatting value (font color). When retrieving, returns RE_Font.Color.
  6295. When set, changes font color for entire <A area> (but does not change
  6296. other font attributes). }
  6297. property RE_FmtFontColorValid: Boolean index CFM_COLOR read REGetFontMask;
  6298. {* |<#richedit>
  6299. Returns True, if property RE_FmtFontColor valid for entire selection,
  6300. when retrieving it. }
  6301. property RE_FmtAutoColor: Boolean index CFM_COLOR read REGetFontEffects write RESetFontEffect;
  6302. {* |<#richedit>
  6303. True, when automatic text color is used (in such case, RE_FmtFontColor
  6304. assignment is ignored for current area). }
  6305. property RE_FmtAutoColorValid: Boolean index CFM_COLOR read REGetFontMask;
  6306. {* }
  6307. property RE_FmtBackColor: Integer index (64 shl 16) or CFM_BACKCOLOR read REGetFontAttr write RESetFontAttr1;
  6308. {* |<#richedit>
  6309. Formatting value (back color). Only available for Rich Edit 2.0 and higher.
  6310. When set, changes background color for entire <A area> (but does not change
  6311. other font attributes). }
  6312. property RE_FmtBackColorValid: Boolean index CFM_BACKCOLOR read REGetFontMask;
  6313. {* }
  6314. property RE_FmtFontOffset: Integer index (16 shl 16) or CFM_OFFSET read REGetFontAttr write RESetFontAttr;
  6315. {* |<#richedit>
  6316. Formatting value (font vertical offset from baseline, positive values
  6317. correspond to subscript). When retrieving, returns offset for first
  6318. character in the selection. When set, changes font offset for entire
  6319. <A area>. To get know, is retrieved value valid for entire selction,
  6320. check RE_FmtFontOffsetValid property. }
  6321. property RE_FmtFontOffsetValid: Boolean index CFM_OFFSET read REGetFontMask;
  6322. {* |<#richedit>
  6323. Returns True, if property RE_FmtFontOffset is valid for entire selection,
  6324. when retrieving it. }
  6325. property RE_FmtFontCharset: Integer index (25 shl 16) or CFM_CHARSET read REGetFontAttr write RESetFontAttr;
  6326. {* |<#richedit>
  6327. Returns charset for first character in current selection, when retrieved
  6328. (and to get know, if this value is valid for entire selection, check
  6329. property RE_FmtFontCharsetValid). When set, changes charset for all
  6330. characters in <A area>, but does not alter other formatting attributes. }
  6331. property RE_FmtFontCharsetValid: Boolean index CFM_CHARSET read REGetFontMask;
  6332. {* |<#richedit>
  6333. Returns True, only if rerieved property RE_FmtFontCharset is valid for
  6334. entire selection. }
  6335. property RE_FmtFontName: String read REGetFontName write RESetFontName;
  6336. {* |<#richedit>
  6337. Returns font face name for first character in the selection, when retrieved,
  6338. and sets font name for entire <A area>, wnen assigned to (without
  6339. changing of other formatting attributes). To get know, if retrived
  6340. font name valid for entire selection, examine property RE_FmtFontNameValid. }
  6341. property RE_FmtFontNameValid: Boolean index CFM_FACE read REGetFontMask;
  6342. {* |<#richedit>
  6343. Returns True, only if the font name is the same for entire selection,
  6344. thus is, if rerieved property value RE_FmtFontName is valid for entire
  6345. selection. }
  6346. property RE_ParaFmt: TParaFormat read REGetParaFmt write RESetParaFmt;
  6347. {* |<#richedit>
  6348. Allows to retrieve or set paragraph formatting attributes for currently
  6349. selected paragraph(s) in RichEdit control. See also following properties,
  6350. which allow to do the same for certain paragraph format attributes
  6351. separately. }
  6352. property RE_TextAlign: TRichTextAlign read REGetTextAlign write RESetTextAlign;
  6353. {* |<#richedit>
  6354. Returns text alignment for current selection and allows to change it
  6355. (without changing other formatting attributes). }
  6356. property RE_TextAlignValid: Boolean index PFM_ALIGNMENT read REGetParaAttrValid;
  6357. {* |<#richedit>
  6358. Returns True, if property RE_TextAlign is valid for entire selection. If
  6359. False, it is concerning only start of selection. }
  6360. property RE_Numbering: Boolean read REGetNumbering write RESetNumbering;
  6361. {* |<#richedit>
  6362. Returns True, if selected text is numbered (or has style of list with
  6363. bullets). To get / change numbering style, see properties
  6364. RE_NumStyle and RE_NumBrackets. }
  6365. property RE_NumStyle: TRichNumbering read REGetNumStyle write RESetNumStyle;
  6366. {* |<#richedit>
  6367. Advanced numbering style, such as rnArabic etc. If You use it, do not
  6368. change RE_Numbering property simultaneously - this can cause changing
  6369. style to rnBullets only. }
  6370. property RE_NumStart: Integer read REGetNumStart write RESetNumStart;
  6371. {* |<#richedit>
  6372. Starting number for advanced numbering style. If this property is not
  6373. set, numbering is starting by default from 0. For rnLRoman and rnURoman
  6374. this cause, that first item has no number to be shown (ancient Roman
  6375. people did not invent '0'). }
  6376. property RE_NumBrackets: TRichNumBrackets read REGetNumBrackets write RESetNumBrackets;
  6377. {* |<#richedit>
  6378. Brackets style for advanced numbering. rnbPlain is default
  6379. brackets style, and every time, when RE_NumStyle is changed,
  6380. RE_NumBrackets is reset to rnbPlain. }
  6381. property RE_NumTab: Integer read REGetNumTab write RESetNumTab;
  6382. {* |<#richedit>
  6383. Tab between start of number and start of paragraph text. If too small too
  6384. view number, number is not displayed. (Default value seems to be sufficient
  6385. though). }
  6386. property RE_NumberingValid: Boolean index PFM_NUMBERING read REGetParaAttrValid;
  6387. {* |<#richedit>
  6388. Returns True, if RE_Numbering, RE_NumStyle, RE_NumBrackets, RE_NumTab,
  6389. RE_NumStart properties are valid for entire selection. }
  6390. property RE_Level: Integer read REGetLevel;
  6391. {* |<#richedit>
  6392. Outline level (for numbering paragraphs?). Read only. }
  6393. property RE_SpaceBefore: Integer index 0 or PFM_SPACEBEFORE read REGetSpacing write RESetSpacing;
  6394. {* |<#richedit>
  6395. Spacing before paragraph. }
  6396. property RE_SpaceBeforeValid: Boolean index PFM_SPACEBEFORE read REGetParaAttrValid;
  6397. {* |<#richedit>
  6398. True, if RE_SpaceBefore value is valid for all selected paragraph (if
  6399. False, this value is valid only for first paragraph. }
  6400. property RE_SpaceAfter: Integer index 4 or PFM_SPACEAFTER read REGetSpacing write RESetSpacing;
  6401. {* |<#richedit>
  6402. Spacing after paragraph. }
  6403. property RE_SpaceAfterValid: Boolean index PFM_SPACEAFTER read REGetParaAttrValid;
  6404. {* |<#richedit>
  6405. True, only if RE_SpaceAfter value is valid for all selected paragraphs. }
  6406. property RE_LineSpacing: Integer index 8 or PFM_LINESPACING read REGetSpacing write RESetSpacing;
  6407. {* |<#richedit>
  6408. Linespacing in paragraph (this value is based on RE_SpacingRule property). }
  6409. property RE_SpacingRule: Integer read REGetSpacingRule write RESetSpacingRule;
  6410. {* |<#richedit>
  6411. Linespacing rule. Do not know what is it. }
  6412. property RE_LineSpacingValid: Boolean index PFM_LINESPACING read REGetParaAttrValid;
  6413. {* |<#richedit>
  6414. True, only if RE_LineSpacing and RE_SpacingRule values are valid for
  6415. entire selection. }
  6416. property RE_Indent: Integer index (20 shl 16) or PFM_OFFSET read REGetParaAttr write RESetParaAttr;
  6417. {* |<#richedit>
  6418. Returns left indentation for paragraph in current selection and allows
  6419. to change it (without changing other formatting attributes). }
  6420. property RE_IndentValid: Boolean index PFM_OFFSET read REGetParaAttrValid;
  6421. {* |<#richedit>
  6422. Returns True, if RE_Indent property is valid for entire selection. }
  6423. property RE_StartIndent: Integer index (12 shl 16) or PFM_OFFSETINDENT read REGetParaAttr write RESetParaAttr;
  6424. {* |<#richedit>
  6425. Returns left indentation for first line in paragraph for current
  6426. selection, and allows to change it (without changing other formatting
  6427. attributes). }
  6428. property RE_StartIndentValid: Boolean read REGetStartIndentValid;
  6429. {* |<#richedit>
  6430. Returns True, if property RE_StartIndent is valid for entire selection. }
  6431. property RE_RightIndent: Integer index (16 shl 16) or PFM_RIGHTINDENT read REGetParaAttr write RESetParaAttr;
  6432. {* |<#richedit>
  6433. Returns right indent for paragraph in current selection, and allow to
  6434. change it (without changing other formatting attributes). }
  6435. property RE_RightIndentValid: Boolean index PFM_RIGHTINDENT read REGetParaAttrValid;
  6436. {* |<#richedit>
  6437. Returns True, if property RE_RightIndent is valid for entire selection only. }
  6438. property RE_TabCount: Integer read REGetTabCount write RESetTabCount;
  6439. {* |<#richedit>
  6440. Number of tab stops in current selection. This value can not be set greater
  6441. then MAX_TAB_COUNT (32). }
  6442. property RE_Tabs[ Idx: Integer ]: Integer read REGetTabs write RESetTabs;
  6443. {* |<#richedit>
  6444. Tab stops for RichEdit control. }
  6445. property RE_TabsValid: Boolean index PFM_TABSTOPS read REGetParaAttrValid;
  6446. {* |<#richedit>
  6447. Returns True, if properties RE_Tabs[ ] and RE_TabCount are valid for
  6448. entire selection. }
  6449. // following does not work now :
  6450. property RE_BorderWidth[ Side: TBorderEdge ]: Integer index 2 read REGetBorder write RESetBorder;
  6451. { * |<#richedit>
  6452. Border width. }
  6453. property RE_BorderSpace[ Side: TBorderEdge ]: Integer index 0 read REGetBorder write RESetBorder;
  6454. { * |<#richedit>
  6455. Border space. }
  6456. property RE_BorderStyle[ Side: TBorderEdge ]: Integer index 4 read REGetBorder write RESetBorder;
  6457. { * |<#richedit>
  6458. Border style. }
  6459. property RE_BorderValid: Boolean index PFM_BORDER read REGetParaAttrValid;
  6460. { * |<#richedit>
  6461. Returns True, if border style, space and width are the same for all
  6462. paragraphs in selection. }
  6463. property RE_Table: Boolean index $C000 read REGetParaEffect write RESetParaEffect;
  6464. { * |<#richedit>
  6465. True, if current paragraph is a part of table (row, cell or cell end).
  6466. seems working as read only property. }
  6467. // end of experiment section
  6468. function RE_FmtStandard: PControl;
  6469. {* |<#richedit>
  6470. "Transparent" method (returns @Self as a result), which (when called)
  6471. provides "standard" keyboard interface for formatting Rich text (just
  6472. call this method, for example:
  6473. ! RichEd1 := NewRichEdit( Panel1, [ ] ).SetAlign( caClient ).RE_FmtStandard;
  6474. Following keys will be maintained additionally:
  6475. |<pre>
  6476. CTRL+I - switch "Italic",
  6477. CTRL+B - switch "Bold",
  6478. CTRL+U - switch "Underline",
  6479. CTRL+SHIFT+U - swith underline type
  6480. and turn underline on (note, that some of underline styles
  6481. can not be shown properly in RichEdit v2.0 and lower,
  6482. though RichEdit2.0 stores data successfully).
  6483. CTRL+O - switch "StrikeOut",
  6484. CTRL+'gray+' - increase font size,
  6485. CTRL+'gray-' - decrease font size,
  6486. CTRL+SHIFT+'gray+' - superscript,
  6487. CTRL+SHIFT+'gray-' - subscript.
  6488. CTRL+SHIFT+Z - ReDo
  6489. |</pre>
  6490. And, though following standard formatting keys are provided by RichEdit
  6491. control itself in Windows2000, some of these are not functioning
  6492. automatically in earlier Windows versions, even for RichEdit2.0. So,
  6493. functionality of some of these (marked with (*) ) are added here too:
  6494. |<pre>
  6495. CTRL+L - align paragraph left, (*)
  6496. CTRL+R - align paragraph right, (*)
  6497. CTRL+E - align paragraph center, (*)
  6498. CTRL+A - select all, (*)
  6499. double-click on word - select word,
  6500. CTRL+Right - to next word,
  6501. CTRL+Left - to previous word,
  6502. CTRL+Home - to the beginning of text,
  6503. CTRL+End - to the end of text.
  6504. CTRL+Z - UnDo
  6505. |</pre>
  6506. If You originally assign some (plain) text to Text property, switching "underline"
  6507. can also change other font attributes, e.g., "bold" - if fsBold style is
  6508. in default Font. To prevent such behavior, select entire text first (see
  6509. SelectAll) and make assignment to RE_Font property, e.g.:
  6510. ! RichEd1.SelectAll;
  6511. ! RichEd1.RE_Font := RichEd1.RE_Font;
  6512. ! RichEd1.SelLength := 0;
  6513. |<br>
  6514. And, some other notices about formatting. Please remember, that only True
  6515. Type fonts can be succefully scaled and transformed to get desired effects
  6516. (e.g., bold). By default, RichEdit uses System font face name, which can
  6517. even have problems with fsBold style. Please remember also, that assigning
  6518. RE_Font to RE_Font just initializying formatting attributes, making all
  6519. those valid in entire text, but does not change font attributes. To use
  6520. True Type font, directly assign face name You wish, e.g.:
  6521. ! RichEd1.SelectAll;
  6522. ! RichEd1.RE_Font := RichEd1.RE_Font;
  6523. ! RichEd1.RE_Font.FontName := 'Arial';
  6524. ! RichEd1.SelLength := 0;
  6525. }
  6526. property RE_AutoKeyboard: Boolean index 1 read REGetLangOptions write RESetLangOptions;
  6527. {* |<#richedit>
  6528. True if autokeyboard on (lovely "feature" of automatic switching keyboard
  6529. language when caret is over another language text). For older RichEdit,
  6530. is 'on' always, for newest - 'off' by default. }
  6531. property RE_OverwriteMode: Boolean read REGetOverwite write RESetOverwrite;
  6532. {* |<#richedit>
  6533. This property allows to control insert/overwrite mode. First, to examine, if
  6534. insert or overwrite mode is current (but it is necessary either to
  6535. access this property, at least once, immediately after creating RichEdit
  6536. control, or to assign event OnRE_InsOvrMode_Change to your handler).
  6537. Second, to set desired mode programmatically - by assigning value to
  6538. this property (You also have to initialize monitoring procedure by either
  6539. reading RE_OverwriteMode property or assigning handler to event
  6540. OnRE_InsOvrMode_Change immediately following RichEdit control creation). }
  6541. property OnRE_InsOvrMode_Change: TOnEvent read fOnREInsModeChg write fOnREInsModeChg;
  6542. {* |<#richedit>
  6543. This event is called, whenever key INSERT is pressed in control (and for
  6544. RichEdit, this means, that insert mode is changed). }
  6545. property RE_DisableOverwriteChange: Boolean read fReOvrDisable write RESetOvrDisable;
  6546. {* |<#richedit>
  6547. It is possible to disable switching between "insert" and "overwrite" mode
  6548. by user (therefore, event OnRE_InsOvrMode_Change continue works, but it
  6549. just called when key INSERT is pressed, though RE_OverwriteMode property
  6550. is not actually changed if switching is disabled). }
  6551. function RE_LoadFromStream( Stream: PStream; Length: Integer;
  6552. Format: TRETextFormat; SelectionOnly: Boolean ): Boolean;
  6553. {* |<#richedit>
  6554. Use this method rather then assignment to RE_Text property, if
  6555. source is stored in file or stream (to minimize resources during
  6556. loading of RichEdit content). Data is loading starting from current
  6557. position in stream and no more then Length bytes are loaded (use -1
  6558. value to load to the end of stream). Loaded data replaces entire
  6559. content of RichEdit control, or selection only, depending on SelectionOnly
  6560. flag.
  6561. |<br>&nbsp;&nbsp;&nbsp;
  6562. If You want to provide progress (e.g. in form of progress bar), assign
  6563. OnProgress event to your handler - and to examine current position of
  6564. loading, read TSream.Position property of soiurce stream). }
  6565. function RE_SaveToStream( Stream: PStream; Format: TRETextFormat; SelectionOnly: Boolean ): Boolean;
  6566. {* |<#richedit>
  6567. Use this method rather then RE_TextProperty to store data to file
  6568. or stream (to minimize resources during saving of RichEdit content).
  6569. Data is saving starting from current position in a stream (until
  6570. end of RichEdit data). If SelectionOnly flag is True, only selected
  6571. part of RichEdit text is saved.
  6572. |<br>&nbsp;&nbsp;&nbsp;
  6573. Like for RE_LoadFromStream, it is possible to assign your method to
  6574. OnProgress event (but to calculate progress of save-to-stream operation,
  6575. compare current stream position with RE_Size[ rsBytes ] property
  6576. value). }
  6577. property OnProgress: TOnEvent read fOnProgress write fOnProgress;
  6578. {* |<#richedit>
  6579. This event is called during RE_SaveToStream, RE_LoadFromStream (and also
  6580. during RE_SaveToFile, RE_LoadFromFile and while accessing or changing
  6581. RE_Text property). To calculate relative progress, it is possible to
  6582. examine current position in stream/file with its total size while reading,
  6583. or with rich edit text size, while writing (property RE_TextSize[ rsBytes ]).
  6584. }
  6585. function RE_LoadFromFile( const Filename: String; Format: TRETextFormat;
  6586. SelectionOnly: Boolean ): Boolean;
  6587. {* |<#richedit>
  6588. Use this method rather then other assignments to RE_Text property,
  6589. if a source for RichEdit is the file. See also RE_LoadFromStream. }
  6590. function RE_SaveToFile( const Filename: String; Format: TRETextFormat;
  6591. SelectionOnly: Boolean ): Boolean;
  6592. {* |<#richedit>
  6593. Use this method rather then other similar, if You want to store
  6594. entire content of RichEdit or selection only of RichEdit to a file. }
  6595. property RE_Text[ Format: TRETextFormat; SelectionOnly: Boolean ]: String read REReadText write REWriteText;
  6596. {* |<#richedit>
  6597. This property allows to get / replace content of RichEdit control
  6598. (entire text or selection only). Using different formats, it is
  6599. possible to exclude or replace undesired formatting information
  6600. (see TRETextFormat specification). To get or replace entire text
  6601. in reText mode (plain text only), it is possible to use habitual
  6602. for edit controls Text property.
  6603. |<br>&nbsp;&nbsp;&nbsp;
  6604. Note: it is possible to append text to the end of RichEdit control
  6605. using method Add, but only if property RE_Text is accessed at least
  6606. once:
  6607. ! RichEdit1.RE_Text[ reText, True ];
  6608. (This line can be written immediatelly after creating RichEdit control). }
  6609. procedure RE_Append( const S: String; ACanUndo: Boolean );
  6610. {* }
  6611. procedure RE_InsertRTF( const S: String );
  6612. {* }
  6613. property RE_Error: Integer read fREError;
  6614. {* |<#richedit>
  6615. Contains error code, if access to RE_Text failed. }
  6616. procedure RE_HideSelection( aHide: Boolean );
  6617. {* |<#richedit>
  6618. Allows to hide / show selection in RichEdit. }
  6619. function RE_SearchText( const Value: String; MatchCase, WholeWord, ScanForward: Boolean;
  6620. SearchFrom, SearchTo: Integer ): Integer;
  6621. {* |<#richedit>
  6622. Searches given string starting from SearchFrom position up to SearchTo
  6623. position (to the end of text, if SearchTo is -1). Returns zero-based
  6624. character position of the next match, or -1 if there are no more matches.
  6625. To search in bacward direction, set ScanForward to False, and pass
  6626. SearchFrom > SearchTo (or even SearchFrom = -1 and SearchTo = 0). }
  6627. property RE_AutoURLDetect: Boolean read REGetAutoURLDetect write RESetAutoURLDetect;
  6628. {* |<#richedit>
  6629. If set to True, automatically detects URLs (and highlights it with
  6630. blue color, applying fsItalic and fsUnderline font styles (while
  6631. typing and loading). Default value is False. Note: if event OnRE_URLClick
  6632. or event OnRE_OverURL are set, property RE_AutoURLDetect is set to True
  6633. automatically. }
  6634. property RE_URL: String read fREUrl;
  6635. {* |<#richedit>
  6636. Detected URL (valid in OnRE_OverURL and OnRE_URLClick event handlers). }
  6637. property OnRE_OverURL: TOnEvent index 0
  6638. {$IFDEF F_P} read REGetOnURL
  6639. {$ELSE DELPHI} read fOnREOverURL
  6640. {$ENDIF F_P/DELPHI} write RESetOnURL;
  6641. {* |<#richedit>
  6642. Is called when mouse is moving over URL. This can be used to set
  6643. cursor, for example, depending on type of URL (to determine URL type
  6644. read property RE_URL). }
  6645. property OnRE_URLClick: TOnEvent index 8
  6646. {$IFDEF F_P} read REGetOnURL
  6647. {$ELSE DELPHI} read fOnREURLClick
  6648. {$ENDIF F_P/DELPHI} write RESetOnURL;
  6649. {* |<#richedit>
  6650. Is called when click on URL detected. }
  6651. //property RE_SelectionBar: Boolean read REGetSelectionBar write RESetSelectionBar;
  6652. //{* ??? - don't know that is this... }
  6653. function RE_NoOLEDragDrop: PControl;
  6654. {* |<#richedit>
  6655. Just prevents drop OLE objects to the rich edit control. Seems not
  6656. working for some cases. }
  6657. //function RE_Wyswig: PControl;
  6658. function RE_Bottomless: PControl;
  6659. // not finished
  6660. property RE_Transparent: Boolean read REGetTransparent write RESetTransparent;
  6661. {* |<#richedit>
  6662. Use this property to make richedit control transparent, instead of
  6663. Ed_Transparent or Transparent. But do not place such transparent
  6664. richedit control directly on form - it can be draw incorrectly when
  6665. form is activated and rich editr control is not current active control.
  6666. Use at least panel as a parent instead.
  6667. }
  6668. //========== both for Edit and RichEdit: =====================
  6669. function CanUndo: Boolean;
  6670. {* |<#richedit>
  6671. |<#edit>
  6672. |<#memo>
  6673. Returns True, if the edit (or RichEdit) control can correctly process
  6674. the EM_UNDO message. }
  6675. procedure EmptyUndoBuffer;
  6676. {* |<#richedit>
  6677. |<#edit>
  6678. |<#memo>
  6679. Reset the undo flag of an edit control, preventing undoing all previous
  6680. changes. }
  6681. function Undo: Boolean;
  6682. {* |<#richedit>
  6683. |<#edit>
  6684. |<#memo>
  6685. For a single-line edit control, the return value is always TRUE. For a
  6686. multiline edit control and RichEdit control, the return value is TRUE if
  6687. the undo operation is successful, or FALSE if the undo operation fails. }
  6688. function RE_Redo: Boolean;
  6689. {* |<#richedit>
  6690. Only for RichEdit control: Returns True if successful. }
  6691. //----------------------------------------------------------------------
  6692. // DateTimePicker
  6693. property OnDTPUserString: TDTParseInputEvent read FOnDTPUserString
  6694. write FOnDTPUserString;
  6695. {* Special event to parse input from the application. Option dtpoParseInput
  6696. must be set when control is created. }
  6697. property DateTime: TDateTime read GetDateTime write SetDateTime;
  6698. {* DateTime for DateTimePicker control only. }
  6699. property Date: TDateTime read GetDate write SetDate;
  6700. {* Date only for DateTimePicker control only. }
  6701. property Time: TDateTime read GetTime write SetTime;
  6702. {* Time only for DateTimePicker control only. }
  6703. property DateTimeRange: TDateTimeRange read GetDateTimeRange
  6704. write SetDateTimeRange;
  6705. {* DateTimePicker range. If first date in the agrument assigned is NAN,
  6706. minimum system allowed value is used as the left bound, and if the second is
  6707. NAN, maximum system allowed is used as the right one. }
  6708. property DateTimePickerColors[ Index: TDateTimePickerColor ]: TColor
  6709. read GetDateTimePickerColor write SetDateTimePickerColor;
  6710. property DateTimeFormat: String write SetDateTimeFormat;
  6711. //----------------------------------------------------------------------
  6712. //----------------------------------------------------------------------
  6713. // ScrollBar
  6714. property SBMin: Longint read fSBMinMax.X write SetSBMin;
  6715. property SBMax: Longint read fSBMinMax.Y write SetSBMax;
  6716. property SBMinMax: TPoint read fSBMinMax write SetSBMinMax;
  6717. property SBPosition: Integer read fSBPosition write SetSBPosition;
  6718. property SBPageSize: Integer read fSBPageSize write SetSBPageSize;
  6719. property OnSBBeforeScroll: TOnSBBeforeScroll read FOnSBBeforeScroll write FOnSBBeforeScroll;
  6720. property OnSBScroll: TOnSBScroll read FOnSBScroll write FOnSBScroll;
  6721. function SBSetScrollInfo(const SI: TScrollInfo): Integer;
  6722. function SBGetScrollInfo(var SI: TScrollInfo): Boolean;
  6723. function GetSBMinMax: TPoint;
  6724. function GetSBPageSize: Integer;
  6725. function GetSBPosition: Integer;
  6726. //----------------------------------------------------------------------
  6727. // "Through", or "transparent" methods to simplify initial
  6728. // adjustment of controls and make non-visual designing of
  6729. // forms more easy. All these functions return @Self as a
  6730. // result, so, it is possible to use such methods immediately
  6731. // in constructing statement, concatenating it with dots, e.g.:
  6732. //
  6733. // NewButton( MyForm, 'Click here' ).PlaceUnder.ResizeParentBottom;
  6734. //
  6735. function PlaceRight: PControl;
  6736. {* Places control right (to previously created on the same parent). }
  6737. function PlaceDown: PControl;
  6738. {* Places control below (to previously created on the same parent).
  6739. Left position is not changed (thus is, kept equal to Parent.Margin). }
  6740. function PlaceUnder: PControl;
  6741. {* Places control below (to previously created one, aligning its
  6742. Left position to Left position of previous control). }
  6743. function SetSize( W, H: Integer ): PControl;
  6744. {* Changes size of a control. If W or H less or equal to 0,
  6745. correspondent size is not changed. }
  6746. function Size( W, H: Integer ): PControl;
  6747. {* Like SetSize, but provides automatic resizing of parent control
  6748. (recursively). Especially useful for aligned controls. }
  6749. function SetClientSize( W, H: Integer ): PControl;
  6750. {* Like SetSize, but works setting W = ClientWidth, H = ClientHeight.
  6751. Use this method for forms, which can not be resized (dialogs). }
  6752. function AutoSize( AutoSzOn: Boolean ): PControl;
  6753. function MakeWordWrap: PControl;
  6754. {* Determines if to autosize control (like label, button, etc.) }
  6755. function IsAutoSize: Boolean;
  6756. {* TRUE, if a control is autosizing. }
  6757. function AlignLeft( P: PControl ): PControl;
  6758. {* assigns Left := P.Left }
  6759. function AlignTop( P: PControl ): PControl;
  6760. {* assigns Top := P.Top }
  6761. function ResizeParent: PControl;
  6762. {* Resizes parent, calling ResizeParentRight and ResizeParentBottom. }
  6763. function ResizeParentRight: PControl;
  6764. {* Resizes parent right edge (Margin of parent is added to right
  6765. coordinate of a control). If called second time (for the same
  6766. parent), resizes only for increasing of right edge of parent. }
  6767. function ResizeParentBottom: PControl;
  6768. {* Resizes parent bottom edge (Margin of parent is added to
  6769. bottom coordinate of a control). }
  6770. function CenterOnParent: PControl;
  6771. {* Centers control on parent, or if applied to a form, centers
  6772. form on screen. }
  6773. function Shift( dX, dY : Integer ): PControl;
  6774. {* Moves control respectively to current position (Left := Left + dX,
  6775. Top := Top + dY). }
  6776. function SetPosition( X, Y: Integer ): PControl;
  6777. {* Moves control directly to the specified position. }
  6778. function Tabulate: PControl;
  6779. {* Call it once for form/applet to provide tabulation between controls on
  6780. form/on all forms using TAB / SHIFT+TAB and arrow keys. }
  6781. function TabulateEx: PControl;
  6782. {* Call it once for form/applet to provide tabulation between controls on
  6783. form/on all forms using TAB / SHIFT+TAB and arrow keys. Arrow keys are
  6784. used more smart, allowing go to nearest control in certain direction. }
  6785. function SetAlign( AAlign: TControlAlign ): PControl;
  6786. {* Assigns passed value to property Align, aligning control on parent,
  6787. and returns @Self (so it is "transparent" function, which can be
  6788. used to adjust control at the creation, e.g.:
  6789. ! MyLabel := NewLabel( MyForm, 'Label1' ).SetAlign( caBottom );
  6790. See also property Align. }
  6791. function PreventResizeFlicks: PControl;
  6792. {* If called, prevents resizing flicks for child controls, aligned to
  6793. right and bottom (but with a lot of code added to executable - about 3,5K).
  6794. There is sensible to set DoubleBuffered to True also to eliminate the
  6795. most of flicks.
  6796. |<br>&nbsp;&nbsp;&nbsp;
  6797. This method been applied to a form, prevents, resizing flicks for
  6798. form and all controls on the form. If it is called for applet window,
  6799. all forms are affected. And if You want, You can apply it for certain
  6800. control only - in such case only given control and its children will
  6801. be resizing without flicks (e.g., using splitter control). }
  6802. property Checked: Boolean read GetChecked write Set_Checked;
  6803. {* |<#checkbox>
  6804. |<#radiobox>
  6805. For checkbox and radiobox - if it is checked. Do not assign
  6806. value for radiobox - use SetRadioChecked instead. }
  6807. function SetChecked(const Value: Boolean): PControl;
  6808. {* |<#checkbox>
  6809. Use it to check/uncheck check box control or push button.
  6810. Do not apply it to check radio buttons - use SetRadioChecked
  6811. method below. }
  6812. function SetRadioChecked : PControl;
  6813. {* |<#radiobox>
  6814. Use it to check radio button item correctly (unchecking all
  6815. alternative ones). Actually, method Click is called, and control
  6816. itself is returned. }
  6817. function SetRadioCheckedOld: PControl;
  6818. {* |<#radiobox>
  6819. Old version of SetRadioChecked (implemented using recommended API
  6820. call. It does not work properly, if control is not visible
  6821. (together with its form). }
  6822. property Check3: TTriStateCheck read GetCheck3 write SetCheck3;
  6823. {* |<#checkbox>
  6824. State of checkbox with BS_AUTO3STATE style. }
  6825. procedure Click;
  6826. {* |<#button>
  6827. |<#checkbox>
  6828. |<#radiobox>
  6829. Emulates click on control programmatically, sending WM_COMMAND
  6830. message with BN_CLICKED code. This method is sensible only for
  6831. buttons, checkboxes and radioboxes. }
  6832. function Perform( msgcode: DWORD; wParam, lParam: Integer): Integer; stdcall;
  6833. {* Sends message to control's window (created if needed). }
  6834. function Postmsg( msgcode: DWORD; wParam, lParam: Integer): Boolean; stdcall;
  6835. {* Sends message to control's window (created if needed). }
  6836. procedure AttachProc( Proc: TWindowFunc );
  6837. {* It is possible to attach dynamically any message handler to window
  6838. procedure using this method. Last attached procedure is called first.
  6839. If procedure returns True, further processing of a message is stopped.
  6840. Attached procedure can be detached using DetachProc (but do not
  6841. attach/detach procedures during handling of attached procedure -
  6842. this can hang application). }
  6843. procedure AttachProcEx( Proc: TWindowFunc; ExecuteAfterAppletTerminated: Boolean );
  6844. {* The same as AttachProc, but a handler is executed even after terminating
  6845. the main message loop processing (i.e. after assigning true to
  6846. AppletTerminated global variable. }
  6847. function IsProcAttached( Proc: TWindowFunc ): Boolean;
  6848. {* Returns True, if given procedure is already in chain of attached
  6849. ones for given control window proc. }
  6850. procedure DetachProc( Proc: TWindowFunc );
  6851. {* Detaches procedure attached earlier using AttachProc. }
  6852. property OnDropFiles: TOnDropFiles read FOnDropFiles write SetOnDropFiles;
  6853. {* Assign this event to your handler, if You want to accept drag and drop
  6854. files from other applications such as explorer onto your control. When
  6855. this event is assigned to a control or form, this has effect also for
  6856. all its child controls too. }
  6857. property CustomData: Pointer read fCustomData write fCustomData;
  6858. {* Can be used to exend the object when new type of control added. Memory,
  6859. pointed by this pointer, released automatically in the destructor. }
  6860. property CustomObj: PObj read fCustomObj write fCustomObj;
  6861. {* Can be used to exend the object when new type of control added. Object,
  6862. pointed by this pointer, released automatically in the destructor. }
  6863. procedure SetAutoPopupMenu( PopupMenu: PObj );
  6864. {* To assign a popup menu to the control, call SetAutoPopupMenu method of
  6865. the control with popup menu object as a parameter. }
  6866. function SupportMnemonics: PControl;
  6867. {* This method provides supporting mnemonic keys in menus, buttons, checkboxes,
  6868. toolbar buttons. }
  6869. property OnScroll: TOnScroll read FOnScroll write SetOnScroll;
  6870. {* }
  6871. protected
  6872. {$IFDEF USE_DROPDOWNCOUNT}
  6873. fDropDownCount: Cardinal;
  6874. {$ENDIF}
  6875. fGraphCtlMouseEvent: TOnGraphCtlMouse;
  6876. public
  6877. {$IFDEF USE_DROPDOWNCOUNT}
  6878. property DropDownCount: Cardinal read fDropDownCount write fDropDownCount;
  6879. {$ENDIF}
  6880. protected
  6881. fPushedBtn: PControl;
  6882. fFocused: Boolean;
  6883. fEditOptions: TEditOptions;
  6884. fEditCtl: PControl;
  6885. fSetFocus: procedure of object;
  6886. fSaveCursor: HCursor;
  6887. fLeave: TOnEvent;
  6888. fKeyboardProcess: TOnMessage;
  6889. fHot: Boolean;
  6890. fHotCtl: PControl;
  6891. fMouseLeaveProc: TOnEvent;
  6892. fIsGroupBox: Boolean;
  6893. fErasingBkgnd: Boolean;
  6894. fButtonIcon: HIcon;
  6895. procedure GraphicLabelPaint( DC: HDC );
  6896. procedure GraphicCheckBoxPaint( DC: HDC );
  6897. procedure GraphicCheckBoxMouse( var Msg: TMsg );
  6898. procedure GraphicRadioBoxPaint( DC: HDC );
  6899. procedure GraphicButtonPaint( DC: HDC );
  6900. procedure GraphicButtonMouse( var Msg: TMsg );
  6901. procedure GraphButtonSetFocus;
  6902. function GraphButtonKeyboardProcess( var Msg: TMsg; var Rslt: Integer ): Boolean;
  6903. procedure LeaveGraphButton( Sender: PObj );
  6904. procedure GraphicEditPaint( DC: HDC );
  6905. procedure GraphicEditMouse( var Msg: TMsg );
  6906. function EditGraphEdit: PControl;
  6907. procedure DestroyGraphEdit( Sender: PObj );
  6908. procedure LeaveGraphEdit( Sender: PObj );
  6909. procedure ChangeGraphEdit( Sender: PObj );
  6910. procedure GraphEditboxSetFocus;
  6911. procedure GraphCtlDrawFocusRect( DC: HDC; const R: TRect );
  6912. {$IFDEF GRAPHCTL_HOTTRACK}
  6913. procedure MouseLeaveFromParentOfGraphCtl( Sender: PObj );
  6914. {$ENDIF GRAPHCTL_HOTTRACK}
  6915. procedure GroupBoxPaint( DC: HDC );
  6916. {$IFDEF KEY_PREVIEW}
  6917. protected
  6918. fKeyPreview: Boolean;
  6919. public
  6920. property KeyPreview: Boolean read fKeyPreview write fKeyPreview;
  6921. {$ENDIF KEY_PREVIEW}
  6922. public
  6923. {$IFDEF USE_CONSTRUCTORS}
  6924. //------------------------------------------------------------
  6925. // constructors here:
  6926. constructor CreateWindowed( AParent: PControl; AClassName: PChar; ACtl3D: Boolean );
  6927. constructor CreateApplet( const ACaption: String );
  6928. constructor CreateForm( AParent: PControl; const ACaption: String );
  6929. constructor CreateControl( AParent: PControl; AClassName: PChar; AStyle: DWORD;
  6930. ACtl3D: Boolean; Actions: PCommandActions );
  6931. constructor CreateButton( AParent: PControl; const ACaption: String );
  6932. constructor CreateBitBtn( AParent: PControl; const ACaption: String;
  6933. AOptions: TBitBtnOptions; ALayout: TGlyphLayout; AGlyphBitmap: HBitmap;
  6934. AGlyphCount: Integer);
  6935. constructor CreateLabel( AParent: PControl; const ACaption: String );
  6936. constructor CreateWordWrapLabel( AParent: PControl; const ACaption: String );
  6937. constructor CreateLabelEffect( AParent: PControl; ACaption: String; AShadowDeep: Integer );
  6938. constructor CreatePaintBox( AParent: PControl );
  6939. constructor CreateGradientPanel( AParent: PControl; AColor1, AColor2: TColor );
  6940. constructor CreateGradientPanelEx( AParent: PControl; AColor1, AColor2: TColor;
  6941. AStyle: TGradientStyle; ALayout: TGradientLayout );
  6942. constructor CreateGroupbox( AParent: PControl; const ACaption: String );
  6943. constructor CreateCheckbox( AParent: PControl; const ACaption: String );
  6944. constructor CreateRadiobox( AParent: PControl; const ACaption: String );
  6945. constructor CreateEditbox( AParent: PControl; AOptions: TEditOptions );
  6946. constructor CreatePanel( AParent: PControl; AStyle: TEdgeStyle );
  6947. constructor CreateSplitter( AParent: PControl; AMinSizePrev, AMinSizeNext: Integer;
  6948. EdgeStyle: TEdgeStyle );
  6949. constructor CreateListbox( AParent: PControl; AOptions: TListOptions );
  6950. constructor CreateCombobox( AParent: PControl; AOptions: TComboOptions );
  6951. constructor CreateCommonControl( AParent: PControl; AClassName: PChar; AStyle: DWORD;
  6952. ACtl3D: Boolean; Actions: PCommandActions );
  6953. constructor CreateRichEdit( AParent: PControl; AOptions: TEditOptions );
  6954. constructor CreateRichEdit1( AParent: PControl; AOptions: TEditOptions );
  6955. constructor CreateProgressbar( AParent: PControl );
  6956. constructor CreateProgressbarEx( AParent: PControl; AOptions: TProgressbarOptions );
  6957. constructor CreateListView( AParent: PControl; AStyle: TListViewStyle; AOptions: TListViewOptions;
  6958. AImageListSmall, AImageListNormal, AImageListState: PImageList );
  6959. constructor CreateTreeView( AParent: PControl; AOptions: TTreeViewOptions;
  6960. AImgListNormal, AImgListState: PImageList );
  6961. constructor CreateTabControl( AParent: PControl; ATabs: array of String;
  6962. AOptions: TTabControlOptions; AImgList: PImageList; AImgList1stIdx: Integer );
  6963. constructor CreateToolbar( AParent: PControl; AAlign: TControlAlign; AOptions: TToolbarOptions;
  6964. ABitmap: HBitmap; AButtons: array of PChar;
  6965. ABtnImgIdxArray: array of Integer );
  6966. {$ENDIF USE_CONSTRUCTORS}
  6967. {$IFDEF USE_CUSTOMEXTENSIONS}
  6968. {$I CUSTOM_TCONTROL_EXTENSION.inc}
  6969. {$ENDIF}
  6970. // If an option USE_CUSTOMEXTENSIONS is enabled (at the beginning of this
  6971. // unit), You can freely extend TControl definition by your own fields,
  6972. // methods and properties. This provides You with capability to extend
  6973. // TControl implementing another kinds of visual controls without deriving
  6974. // new descendant objects from TControl. This way is provided to avoid too
  6975. // large grow of executable size. You also can derive your own controls
  6976. // from TControl using standard OOP capabilities. In such case an option
  6977. // USE_CONSTRUCTORS should be turned on (see it at the start of this unit).
  6978. // If You choose this "flat" model of extending the TControl with your
  6979. // own properties, fieds, methods, events, etc. You should provide three
  6980. // inc-files: CUSTOM_TCONTROL_EXTENSION.inc, containing such definitions
  6981. // for TControl, CUSTOM_KOL_EXTENSION.inc, containing needed global
  6982. // declarations, and CUSTOM_CODE_EXTENSION.inc, the implementation of those
  6983. // two.
  6984. // Because KOL is always grow and constantly is extending by me, I also can
  6985. // add my own complements for TControl. To avoid naming conflicts, I suggest
  6986. // to use the same naming rule for all of You. Name your fields, properies, etc.
  6987. // using a form idx_SomeName, where idx is a prefix, containing several
  6988. // (at least one) letters and digits. E.g. ZK65_OnSomething.
  6989. end;
  6990. //[END OF TControl DEFINITION]
  6991. {$IFDEF USE_MHTOOLTIP}
  6992. {$DEFINE interface}
  6993. {$I KOLMHToolTip}
  6994. {$UNDEF interface}
  6995. {$ENDIF}
  6996. //[Paint Background PROCEDURE]
  6997. type
  6998. TOnPaintBkgnd = procedure( Sender: PControl; DC: HDC; Rect: PRect );
  6999. {* Global event definition. Used to define Global_OnPaintBackground
  7000. event placeholder. }
  7001. procedure DefaultPaintBackground( Sender: PControl; DC: HDC; Rect: PRect );
  7002. var
  7003. Global_OnPaintBkgnd: TOnPaintBkgnd = DefaultPaintBackground;
  7004. {* Global event. It is assigned in XBackgounds.pas add-on to replace
  7005. PaintBackground method for all TVisual objects, allowing great
  7006. visualization effect: transparent controls over [animated] bitmap
  7007. background. Idea:
  7008. | <a href=mailto:"bw@sunv.com">Wei&nbsp;Bao</a>. Implementation:
  7009. | <a href=mailto:"bonanzas@xcl.cjb.net">Kladov&nbsp;Vladimir</a>. }
  7010. procedure DummyPaintProc( Sender: PControl; DC: HDC );
  7011. //[GetShiftState DECLARATION]
  7012. function GetShiftState: DWORD;
  7013. //[WndProcXXX DECLARATIONS]
  7014. function WndProcMouse( Self_: PControl; var Msg: TMsg; var Rslt: Integer ): Boolean;
  7015. function WndProcKeybd( Self_: PControl; var Msg: TMsg; var Rslt: Integer ): Boolean;
  7016. function WndProcDummy( Self_: PControl; var Msg: TMsg; var Rslt: Integer ): Boolean;
  7017. function WndProcBufferedDraw( Self_: PControl; var Msg: TMsg; var Rslt: Integer ): Boolean;
  7018. {$IFDEF ALL_BUTTONS_RESPOND_TO_ENTER}
  7019. function WndProcBtnReturnClick( Self_: PControl; var Msg: TMsg; var Rslt: Integer ): Boolean;
  7020. {$ENDIF}
  7021. function AutoMinimizeApplet(Self_: PControl; var Msg: TMsg; var Rslt: Integer): Boolean;
  7022. {* By Sergey Shishmintzev.
  7023. Attach this handler to your modal dialog form handle to provide automatic
  7024. minimization of all other forms in the application together with the dialog. }
  7025. //[InitCommonXXXX DECLARATIONS]
  7026. procedure InitCommonControlSizeNotify( Ctrl: PControl );
  7027. procedure InitCommonControlCommonNotify( Ctrl: PControl );
  7028. //[Buffered Draw DECLARATIONS]
  7029. var
  7030. Global_OnBufferedDraw: function( Self_: PControl; var Msg: TMsg; var Rslt: Integer ): Boolean
  7031. = WndProcDummy;
  7032. Global_DblBufCreateWnd: procedure( Sender: PObj ) = DummyObjProc;
  7033. Global_Invalidate: procedure( Sender: PObj ) = DummyObjProc;
  7034. {* Is called in TControl.Invalidate to extend it in case when DoubleBuffered
  7035. painting used. }
  7036. Global_TranspDrawBkgnd: procedure( DC: HDC; Sender: PControl );
  7037. //Global_OnCreateWindow: procedure( Sender: PObj ) = DummyObjProc;
  7038. //{* Is called when TControl object is created. }
  7039. //Global_OnDestroyWindow: procedure( Sender: PObj ) = DummyObjProc;
  7040. //{* Is called before destroying TControl object (after accepting it,
  7041. // if event OnClose is defined). }
  7042. Global_OnBeginPaint: procedure( Sender: PControl; DC: HDC ) = DummyPaintProc;
  7043. {* Is called before painting a window. }
  7044. Global_OnEndPaint: procedure( Sender: PControl; DC: HDC ) = DummyPaintProc;
  7045. {* Is called after painting a window. }
  7046. HelpFilePath: PChar;
  7047. {* Path to application help file. If not assigned, application path with
  7048. extension replaced to '.hlp' used. To use '.chm' file (HtmlHelp),
  7049. call AssignHtmlHelp with a path to a html help file (or a name). }
  7050. //[Html Help DECLARATIONS]
  7051. procedure AssignHtmlHelp( const HtmlHelpPath: String );
  7052. procedure HtmlHelpCommand( Wnd: HWnd; const HelpFilePath: String; Cmd, Data: Integer );
  7053. {* Use this wrapper procedure to call HtmlHelp API function. }
  7054. //+++++++++++ HTML HELP DEFINITIONS SECTION:
  7055. // this section is from
  7056. // HTML Help API Interface Unit
  7057. // Copyright (c) 1999 The Helpware Group
  7058. // provided for KOL by Alexey Babenko
  7059. const
  7060. HH_DISPLAY_TOPIC = $0000; {**}
  7061. HH_HELP_FINDER = $0000; // WinHelp equivalent
  7062. HH_DISPLAY_TOC = $0001; // not currently implemented
  7063. HH_DISPLAY_INDEX = $0002; // not currently implemented
  7064. HH_DISPLAY_SEARCH = $0003; // not currently implemented
  7065. HH_SET_WIN_TYPE = $0004;
  7066. HH_GET_WIN_TYPE = $0005;
  7067. HH_GET_WIN_HANDLE = $0006;
  7068. HH_ENUM_INFO_TYPE = $0007; // Get Info type name, call repeatedly to enumerate, -1 at end
  7069. HH_SET_INFO_TYPE = $0008; // Add Info type to filter.
  7070. HH_SYNC = $0009;
  7071. HH_RESERVED1 = $000A;
  7072. HH_RESERVED2 = $000B;
  7073. HH_RESERVED3 = $000C;
  7074. HH_KEYWORD_LOOKUP = $000D;
  7075. HH_DISPLAY_TEXT_POPUP = $000E; // display string resource id or text in a popup window
  7076. HH_HELP_CONTEXT = $000F; {**}// display mapped numeric value in dwData
  7077. HH_TP_HELP_CONTEXTMENU = $0010; // text popup help, same as WinHelp HELP_CONTEXTMENU
  7078. HH_TP_HELP_WM_HELP = $0011; // text popup help, same as WinHelp HELP_WM_HELP
  7079. HH_CLOSE_ALL = $0012; // close all windows opened directly or indirectly by the caller
  7080. HH_ALINK_LOOKUP = $0013; // ALink version of HH_KEYWORD_LOOKUP
  7081. HH_GET_LAST_ERROR = $0014; // not currently implemented // See HHERROR.h
  7082. HH_ENUM_CATEGORY = $0015; // Get category name, call repeatedly to enumerate, -1 at end
  7083. HH_ENUM_CATEGORY_IT = $0016; // Get category info type members, call repeatedly to enumerate, -1 at end
  7084. HH_RESET_IT_FILTER = $0017; // Clear the info type filter of all info types.
  7085. HH_SET_INCLUSIVE_FILTER = $0018; // set inclusive filtering method for untyped topics to be included in display
  7086. HH_SET_EXCLUSIVE_FILTER = $0019; // set exclusive filtering method for untyped topics to be excluded from display
  7087. HH_INITIALIZE = $001C; // Initializes the help system.
  7088. HH_UNINITIALIZE = $001D; // Uninitializes the help system.
  7089. HH_PRETRANSLATEMESSAGE = $00fd; // Pumps messages. (NULL, NULL, MSG*).
  7090. HH_SET_GLOBAL_PROPERTY = $00fc; // Set a global property. (NULL, NULL, HH_GPROP)
  7091. { window properties }
  7092. const
  7093. HHWIN_PROP_TAB_AUTOHIDESHOW = $00000001; // (1 << 0) Automatically hide/show tri-pane window
  7094. HHWIN_PROP_ONTOP = $00000002; // (1 << 1) Top-most window
  7095. HHWIN_PROP_NOTITLEBAR = $00000004; // (1 << 2) no title bar
  7096. HHWIN_PROP_NODEF_STYLES = $00000008; // (1 << 3) no default window styles (only HH_WINTYPE.dwStyles)
  7097. HHWIN_PROP_NODEF_EXSTYLES = $00000010; // (1 << 4) no default extended window styles (only HH_WINTYPE.dwExStyles)
  7098. HHWIN_PROP_TRI_PANE = $00000020; // (1 << 5) use a tri-pane window
  7099. HHWIN_PROP_NOTB_TEXT = $00000040; // (1 << 6) no text on toolbar buttons
  7100. HHWIN_PROP_POST_QUIT = $00000080; // (1 << 7) post WM_QUIT message when window closes
  7101. HHWIN_PROP_AUTO_SYNC = $00000100; // (1 << 8) automatically ssync contents and index
  7102. HHWIN_PROP_TRACKING = $00000200; // (1 << 9) send tracking notification messages
  7103. HHWIN_PROP_TAB_SEARCH = $00000400; // (1 << 10) include search tab in navigation pane
  7104. HHWIN_PROP_TAB_HISTORY = $00000800; // (1 << 11) include history tab in navigation pane
  7105. HHWIN_PROP_TAB_FAVORITES = $00001000; // (1 << 12) include favorites tab in navigation pane
  7106. HHWIN_PROP_CHANGE_TITLE = $00002000; // (1 << 13) Put current HTML title in title bar
  7107. HHWIN_PROP_NAV_ONLY_WIN = $00004000; // (1 << 14) Only display the navigation window
  7108. HHWIN_PROP_NO_TOOLBAR = $00008000; // (1 << 15) Don't display a toolbar
  7109. HHWIN_PROP_MENU = $00010000; // (1 << 16) Menu
  7110. HHWIN_PROP_TAB_ADVSEARCH = $00020000; // (1 << 17) Advanced FTS UI.
  7111. HHWIN_PROP_USER_POS = $00040000; // (1 << 18) After initial creation, user controls window size/position
  7112. HHWIN_PROP_TAB_CUSTOM1 = $00080000; // (1 << 19) Use custom tab #1
  7113. HHWIN_PROP_TAB_CUSTOM2 = $00100000; // (1 << 20) Use custom tab #2
  7114. HHWIN_PROP_TAB_CUSTOM3 = $00200000; // (1 << 21) Use custom tab #3
  7115. HHWIN_PROP_TAB_CUSTOM4 = $00400000; // (1 << 22) Use custom tab #4
  7116. HHWIN_PROP_TAB_CUSTOM5 = $00800000; // (1 << 23) Use custom tab #5
  7117. HHWIN_PROP_TAB_CUSTOM6 = $01000000; // (1 << 24) Use custom tab #6
  7118. HHWIN_PROP_TAB_CUSTOM7 = $02000000; // (1 << 25) Use custom tab #7
  7119. HHWIN_PROP_TAB_CUSTOM8 = $04000000; // (1 << 26) Use custom tab #8
  7120. HHWIN_PROP_TAB_CUSTOM9 = $08000000; // (1 << 27) Use custom tab #9
  7121. HHWIN_TB_MARGIN = $10000000; // (1 << 28) the window type has a margin
  7122. { window parameters }
  7123. const
  7124. HHWIN_PARAM_PROPERTIES = $00000002; // (1 << 1) valid fsWinProperties
  7125. HHWIN_PARAM_STYLES = $00000004; // (1 << 2) valid dwStyles
  7126. HHWIN_PARAM_EXSTYLES = $00000008; // (1 << 3) valid dwExStyles
  7127. HHWIN_PARAM_RECT = $00000010; // (1 << 4) valid rcWindowPos
  7128. HHWIN_PARAM_NAV_WIDTH = $00000020; // (1 << 5) valid iNavWidth
  7129. HHWIN_PARAM_SHOWSTATE = $00000040; // (1 << 6) valid nShowState
  7130. HHWIN_PARAM_INFOTYPES = $00000080; // (1 << 7) valid apInfoTypes
  7131. HHWIN_PARAM_TB_FLAGS = $00000100; // (1 << 8) valid fsToolBarFlags
  7132. HHWIN_PARAM_EXPANSION = $00000200; // (1 << 9) valid fNotExpanded
  7133. HHWIN_PARAM_TABPOS = $00000400; // (1 << 10) valid tabpos
  7134. HHWIN_PARAM_TABORDER = $00000800; // (1 << 11) valid taborder
  7135. HHWIN_PARAM_HISTORY_COUNT = $00001000; // (1 << 12) valid cHistory
  7136. HHWIN_PARAM_CUR_TAB = $00002000; // (1 << 13) valid curNavType
  7137. { button constants }
  7138. const
  7139. HHWIN_BUTTON_EXPAND = $00000002; // (1 << 1) Expand/contract button
  7140. HHWIN_BUTTON_BACK = $00000004; // (1 << 2) Back button
  7141. HHWIN_BUTTON_FORWARD = $00000008; // (1 << 3) Forward button
  7142. HHWIN_BUTTON_STOP = $00000010; // (1 << 4) Stop button
  7143. HHWIN_BUTTON_REFRESH = $00000020; // (1 << 5) Refresh button
  7144. HHWIN_BUTTON_HOME = $00000040; // (1 << 6) Home button
  7145. HHWIN_BUTTON_BROWSE_FWD = $00000080; // (1 << 7) not implemented
  7146. HHWIN_BUTTON_BROWSE_BCK = $00000100; // (1 << 8) not implemented
  7147. HHWIN_BUTTON_NOTES = $00000200; // (1 << 9) not implemented
  7148. HHWIN_BUTTON_CONTENTS = $00000400; // (1 << 10) not implemented
  7149. HHWIN_BUTTON_SYNC = $00000800; // (1 << 11) Sync button
  7150. HHWIN_BUTTON_OPTIONS = $00001000; // (1 << 12) Options button
  7151. HHWIN_BUTTON_PRINT = $00002000; // (1 << 13) Print button
  7152. HHWIN_BUTTON_INDEX = $00004000; // (1 << 14) not implemented
  7153. HHWIN_BUTTON_SEARCH = $00008000; // (1 << 15) not implemented
  7154. HHWIN_BUTTON_HISTORY = $00010000; // (1 << 16) not implemented
  7155. HHWIN_BUTTON_FAVORITES = $00020000; // (1 << 17) not implemented
  7156. HHWIN_BUTTON_JUMP1 = $00040000; // (1 << 18)
  7157. HHWIN_BUTTON_JUMP2 = $00080000; // (1 << 19)
  7158. HHWIN_BUTTON_ZOOM = $00100000; // (1 << 20)
  7159. HHWIN_BUTTON_TOC_NEXT = $00200000; // (1 << 21)
  7160. HHWIN_BUTTON_TOC_PREV = $00400000; // (1 << 22)
  7161. HHWIN_DEF_BUTTONS = (HHWIN_BUTTON_EXPAND
  7162. OR HHWIN_BUTTON_BACK
  7163. OR HHWIN_BUTTON_OPTIONS
  7164. OR HHWIN_BUTTON_PRINT);
  7165. { Button IDs }
  7166. const
  7167. IDTB_EXPAND = 200;
  7168. IDTB_CONTRACT = 201;
  7169. IDTB_STOP = 202;
  7170. IDTB_REFRESH = 203;
  7171. IDTB_BACK = 204;
  7172. IDTB_HOME = 205;
  7173. IDTB_SYNC = 206;
  7174. IDTB_PRINT = 207;
  7175. IDTB_OPTIONS = 208;
  7176. IDTB_FORWARD = 209;
  7177. IDTB_NOTES = 210; // not implemented
  7178. IDTB_BROWSE_FWD = 211;
  7179. IDTB_BROWSE_BACK = 212;
  7180. IDTB_CONTENTS = 213; // not implemented
  7181. IDTB_INDEX = 214; // not implemented
  7182. IDTB_SEARCH = 215; // not implemented
  7183. IDTB_HISTORY = 216; // not implemented
  7184. IDTB_FAVORITES = 217; // not implemented
  7185. IDTB_JUMP1 = 218;
  7186. IDTB_JUMP2 = 219;
  7187. IDTB_CUSTOMIZE = 221;
  7188. IDTB_ZOOM = 222;
  7189. IDTB_TOC_NEXT = 223;
  7190. IDTB_TOC_PREV = 224;
  7191. { Notification codes }
  7192. const
  7193. HHN_FIRST = (0-860);
  7194. HHN_LAST = (0-879);
  7195. HHN_NAVCOMPLETE = (HHN_FIRST-0);
  7196. HHN_TRACK = (HHN_FIRST-1);
  7197. HHN_WINDOW_CREATE = (HHN_FIRST-2);
  7198. type
  7199. {*** Used by command HH_GET_LAST_ERROR
  7200. NOTE: Not part of the htmlhelp.h but documented in HH Workshop help
  7201. You must call SysFreeString(xx.description) to free BSTR
  7202. }
  7203. tagHH_LAST_ERROR = packed record
  7204. cbStruct: Integer; // sizeof this structure
  7205. hr: Integer; // Specifies the last error code.
  7206. description: PWideChar; // (BSTR) Specifies a Unicode string containing a description of the error.
  7207. end;
  7208. HH_LAST_ERROR = tagHH_LAST_ERROR;
  7209. THHLastError = tagHH_LAST_ERROR;
  7210. type
  7211. {*** Notify event info for HHN_NAVCOMPLETE, HHN_WINDOW_CREATE }
  7212. PHHNNotify = ^THHNNotify;
  7213. tagHHN_NOTIFY = packed record
  7214. hdr: TNMHdr;
  7215. pszUrl: PChar; //PCSTR: Multi-byte, null-terminated string
  7216. end;
  7217. HHN_NOTIFY = tagHHN_NOTIFY;
  7218. THHNNotify = tagHHN_NOTIFY;
  7219. {** Use by command HH_DISPLAY_TEXT_POPUP}
  7220. PHHPopup = ^THHPopup;
  7221. tagHH_POPUP = packed record
  7222. cbStruct: Integer; // sizeof this structure
  7223. hinst: HINST; // instance handle for string resource
  7224. idString: cardinal; // string resource id, or text id if pszFile is specified in HtmlHelp call
  7225. pszText: PChar; // used if idString is zero
  7226. pt: TPOINT; // top center of popup window
  7227. clrForeground: COLORREF; // use -1 for default
  7228. clrBackground: COLORREF; // use -1 for default
  7229. rcMargins: TRect; // amount of space between edges of window and text, -1 for each member to ignore
  7230. pszFont: PChar; // facename, point size, char set, BOLD ITALIC UNDERLINE
  7231. end;
  7232. HH_POPUP = tagHH_POPUP;
  7233. THHPopup = tagHH_POPUP;
  7234. {** Use by commands - HH_ALINK_LOOKUP, HH_KEYWORD_LOOKUP}
  7235. PHHAKLink = ^THHAKLink;
  7236. tagHH_AKLINK = packed record
  7237. cbStruct: integer; // sizeof this structure
  7238. fReserved: BOOL; // must be FALSE (really!)
  7239. pszKeywords: PChar; // semi-colon separated keywords
  7240. pszUrl: PChar; // URL to jump to if no keywords found (may be NULL)
  7241. pszMsgText: PChar; // Message text to display in MessageBox if pszUrl is NULL and no keyword match
  7242. pszMsgTitle: PChar; // Message text to display in MessageBox if pszUrl is NULL and no keyword match
  7243. pszWindow: PChar; // Window to display URL in
  7244. fIndexOnFail: BOOL; // Displays index if keyword lookup fails.
  7245. end;
  7246. HH_AKLINK = tagHH_AKLINK;
  7247. THHAKLink = tagHH_AKLINK;
  7248. const
  7249. HHWIN_NAVTYPE_TOC = 0;
  7250. HHWIN_NAVTYPE_INDEX = 1;
  7251. HHWIN_NAVTYPE_SEARCH = 2;
  7252. HHWIN_NAVTYPE_FAVORITES = 3;
  7253. HHWIN_NAVTYPE_HISTORY = 4; // not implemented
  7254. HHWIN_NAVTYPE_AUTHOR = 5;
  7255. HHWIN_NAVTYPE_CUSTOM_FIRST = 11;
  7256. const
  7257. IT_INCLUSIVE = 0;
  7258. IT_EXCLUSIVE = 1;
  7259. IT_HIDDEN = 2;
  7260. type
  7261. PHHEnumIT = ^THHEnumIT;
  7262. tagHH_ENUM_IT = packed record //tagHH_ENUM_IT, HH_ENUM_IT, *PHH_ENUM_IT
  7263. cbStruct: Integer; // size of this structure
  7264. iType: Integer; // the type of the information type ie. Inclusive, Exclusive, or Hidden
  7265. pszCatName: PAnsiChar; // Set to the name of the Category to enumerate the info types in a category; else NULL
  7266. pszITName: PAnsiChar; // volitile pointer to the name of the infotype. Allocated by call. Caller responsible for freeing
  7267. pszITDescription: PAnsiChar; // volitile pointer to the description of the infotype.
  7268. end;
  7269. THHEnumIT = tagHH_ENUM_IT;
  7270. type
  7271. PHHEnumCat = ^THHEnumCat;
  7272. tagHH_ENUM_CAT = packed record //tagHH_ENUM_CAT, HH_ENUM_CAT, *PHH_ENUM_CAT
  7273. cbStruct: Integer; // size of this structure
  7274. pszCatName: PAnsiChar; // volitile pointer to the category name
  7275. pszCatDescription: PAnsiChar; // volitile pointer to the category description
  7276. end;
  7277. THHEnumCat = tagHH_ENUM_CAT;
  7278. type
  7279. PHHSetInfoType = ^THHSetInfoType;
  7280. tagHH_SET_INFOTYPE = packed record //tagHH_SET_INFOTYPE, HH_SET_INFOTYPE, *PHH_SET_INFOTYPE
  7281. cbStruct: Integer; // the size of this structure
  7282. pszCatName: PAnsiChar; // the name of the category, if any, the InfoType is a member of.
  7283. pszInfoTypeName: PAnsiChar; // the name of the info type to add to the filter
  7284. end;
  7285. THHSetInfoType = tagHH_SET_INFOTYPE;
  7286. type
  7287. HH_INFOTYPE = DWORD;
  7288. THHInfoType = HH_INFOTYPE;
  7289. PHHInfoType = ^THHInfoType; //PHH_INFOTYPE
  7290. const
  7291. HHWIN_NAVTAB_TOP = 0;
  7292. HHWIN_NAVTAB_LEFT = 1;
  7293. HHWIN_NAVTAB_BOTTOM = 2;
  7294. const
  7295. HH_MAX_TABS = 19; // maximum number of tabs
  7296. const
  7297. HH_TAB_CONTENTS = 0;
  7298. HH_TAB_INDEX = 1;
  7299. HH_TAB_SEARCH = 2;
  7300. HH_TAB_FAVORITES = 3;
  7301. HH_TAB_HISTORY = 4;
  7302. HH_TAB_AUTHOR = 5;
  7303. HH_TAB_CUSTOM_FIRST = 11;
  7304. HH_TAB_CUSTOM_LAST = HH_MAX_TABS;
  7305. HH_MAX_TABS_CUSTOM = (HH_TAB_CUSTOM_LAST - HH_TAB_CUSTOM_FIRST + 1);
  7306. { HH_DISPLAY_SEARCH Command Related Structures and Constants }
  7307. const
  7308. HH_FTS_DEFAULT_PROXIMITY = (-1);
  7309. type
  7310. {** Used by command HH_DISPLAY_SEARCH}
  7311. PHHFtsQuery = ^THHFtsQuery;
  7312. tagHH_FTS_QUERY = packed record //tagHH_FTS_QUERY, HH_FTS_QUERY
  7313. cbStruct: integer; // Sizeof structure in bytes.
  7314. fUniCodeStrings: BOOL; // TRUE if all strings are unicode.
  7315. pszSearchQuery: PChar; // String containing the search query.
  7316. iProximity: LongInt; // Word proximity.
  7317. fStemmedSearch: Bool; // TRUE for StemmedSearch only.
  7318. fTitleOnly: Bool; // TRUE for Title search only.
  7319. fExecute: Bool; // TRUE to initiate the search.
  7320. pszWindow: PChar; // Window to display in
  7321. end;
  7322. THHFtsQuery = tagHH_FTS_QUERY;
  7323. { HH_WINTYPE Structure }
  7324. type
  7325. {** Used by commands HH_GET_WIN_TYPE, HH_SET_WIN_TYPE}
  7326. PHHWinType = ^THHWinType;
  7327. tagHH_WINTYPE = packed record //tagHH_WINTYPE, HH_WINTYPE, *PHH_WINTYPE;
  7328. cbStruct: Integer; // IN: size of this structure including all Information Types
  7329. fUniCodeStrings: BOOL; // IN/OUT: TRUE if all strings are in UNICODE
  7330. pszType: PChar; // IN/OUT: Name of a type of window
  7331. fsValidMembers: DWORD; // IN: Bit flag of valid members (HHWIN_PARAM_)
  7332. fsWinProperties: DWORD; // IN/OUT: Properties/attributes of the window (HHWIN_)
  7333. pszCaption: PChar; // IN/OUT: Window title
  7334. dwStyles: DWORD; // IN/OUT: Window styles
  7335. dwExStyles: DWORD; // IN/OUT: Extended Window styles
  7336. rcWindowPos: TRect; // IN: Starting position, OUT: current position
  7337. nShowState: Integer; // IN: show state (e.g., SW_SHOW)
  7338. hwndHelp: HWND; // OUT: window handle
  7339. hwndCaller: HWND; // OUT: who called this window
  7340. paInfoTypes: PHHInfoType; // IN: Pointer to an array of Information Types
  7341. { The following members are only valid if HHWIN_PROP_TRI_PANE is set }
  7342. hwndToolBar: HWND; // OUT: toolbar window in tri-pane window
  7343. hwndNavigation: HWND; // OUT: navigation window in tri-pane window
  7344. hwndHTML: HWND; // OUT: window displaying HTML in tri-pane window
  7345. iNavWidth: Integer; // IN/OUT: width of navigation window
  7346. rcHTML: TRect; // OUT: HTML window coordinates
  7347. pszToc: PChar; // IN: Location of the table of contents file
  7348. pszIndex: PChar; // IN: Location of the index file
  7349. pszFile: PChar; // IN: Default location of the html file
  7350. pszHome: PChar; // IN/OUT: html file to display when Home button is clicked
  7351. fsToolBarFlags: DWORD; // IN: flags controling the appearance of the toolbar (HHWIN_BUTTON_)
  7352. fNotExpanded: BOOL; // IN: TRUE/FALSE to contract or expand, OUT: current state
  7353. curNavType: Integer; // IN/OUT: UI to display in the navigational pane
  7354. tabpos: Integer; // IN/OUT: HHWIN_NAVTAB_TOP, HHWIN_NAVTAB_LEFT, or HHWIN_NAVTAB_BOTTOM
  7355. idNotify: Integer; // IN: ID to use for WM_NOTIFY messages
  7356. tabOrder: packed array[0..HH_MAX_TABS] of Byte; // IN/OUT: tab order: Contents, Index, Search, History, Favorites, Reserved 1-5, Custom tabs
  7357. cHistory: Integer; // IN/OUT: number of history items to keep (default is 30)
  7358. pszJump1: PChar; // Text for HHWIN_BUTTON_JUMP1
  7359. pszJump2: PChar; // Text for HHWIN_BUTTON_JUMP2
  7360. pszUrlJump1: PChar; // URL for HHWIN_BUTTON_JUMP1
  7361. pszUrlJump2: PChar; // URL for HHWIN_BUTTON_JUMP2
  7362. rcMinSize: TRect; // Minimum size for window (ignored in version 1)
  7363. cbInfoTypes: Integer; // size of paInfoTypes;
  7364. pszCustomTabs: PChar; // multiple zero-terminated strings
  7365. end;
  7366. HH_WINTYPE = tagHH_WINTYPE;
  7367. THHWinType = tagHH_WINTYPE;
  7368. const
  7369. HHACT_TAB_CONTENTS = 0;
  7370. HHACT_TAB_INDEX = 1;
  7371. HHACT_TAB_SEARCH = 2;
  7372. HHACT_TAB_HISTORY = 3;
  7373. HHACT_TAB_FAVORITES = 4;
  7374. HHACT_EXPAND = 5;
  7375. HHACT_CONTRACT = 6;
  7376. HHACT_BACK = 7;
  7377. HHACT_FORWARD = 8;
  7378. HHACT_STOP = 9;
  7379. HHACT_REFRESH = 10;
  7380. HHACT_HOME = 11;
  7381. HHACT_SYNC = 12;
  7382. HHACT_OPTIONS = 13;
  7383. HHACT_PRINT = 14;
  7384. HHACT_HIGHLIGHT = 15;
  7385. HHACT_CUSTOMIZE = 16;
  7386. HHACT_JUMP1 = 17;
  7387. HHACT_JUMP2 = 18;
  7388. HHACT_ZOOM = 19;
  7389. HHACT_TOC_NEXT = 20;
  7390. HHACT_TOC_PREV = 21;
  7391. HHACT_NOTES = 22;
  7392. HHACT_LAST_ENUM = 23;
  7393. type
  7394. {*** Notify event info for HHN_TRACK }
  7395. PHHNTrack = ^THHNTrack;
  7396. tagHHNTRACK = packed record //tagHHNTRACK, HHNTRACK;
  7397. hdr: TNMHdr;
  7398. pszCurUrl: PChar; // Multi-byte, null-terminated string
  7399. idAction: Integer; // HHACT_ value
  7400. phhWinType: PHHWinType; // Current window type structure
  7401. end;
  7402. HHNTRACK = tagHHNTRACK;
  7403. THHNTrack = tagHHNTRACK;
  7404. ///////////////////////////////////////////////////////////////////////////////
  7405. //
  7406. // Global Control Properties.
  7407. //
  7408. const
  7409. HH_GPROPID_SINGLETHREAD = 1; // VARIANT_BOOL: True for single thread
  7410. HH_GPROPID_TOOLBAR_MARGIN = 2; // long: Provides a left/right margin around the toolbar.
  7411. HH_GPROPID_UI_LANGUAGE = 3; // long: LangId of the UI.
  7412. HH_GPROPID_CURRENT_SUBSET = 4; // BSTR: Current subset.
  7413. HH_GPROPID_CONTENT_LANGUAGE = 5; // long: LandId for desired content.
  7414. type
  7415. tagHH_GPROPID = HH_GPROPID_SINGLETHREAD..HH_GPROPID_CONTENT_LANGUAGE; //tagHH_GPROPID, HH_GPROPID
  7416. HH_GPROPID = tagHH_GPROPID;
  7417. THHGPropID = HH_GPROPID;
  7418. ///////////////////////////////////////////////////////////////////////////////
  7419. //
  7420. // Global Property structure
  7421. //
  7422. {type
  7423. PHHGlobalProperty = ^THHGlobalProperty;
  7424. tagHH_GLOBAL_PROPERTY = record //tagHH_GLOBAL_PROPERTY, HH_GLOBAL_PROPERTY
  7425. id: THHGPropID;
  7426. Dummy: Integer; // Added to enforce 8-byte packing
  7427. var_: VARIANT;
  7428. end;
  7429. HH_GLOBAL_PROPERTY = tagHH_GLOBAL_PROPERTY;
  7430. THHGlobalProperty = tagHH_GLOBAL_PROPERTY;}
  7431. //[END OF HTMLHELP DECLARATIONS]
  7432. //[GetCtlBrush DECLARATIONS]
  7433. function SimpleGetCtlBrushHandle( Sender: PControl ): HBrush; //forward;
  7434. var
  7435. Global_GetCtlBrushHandle: function( Sender: PControl ): HBrush = SimpleGetCtlBrushHandle;
  7436. {* Is called to obtain brush handle. }
  7437. Global_Align: procedure( Sender: PObj ) = DummyObjProc;
  7438. {* Is set to perform aligning of control, and only if property Align
  7439. is changed for TControl, or SetAlign method is called for it. }
  7440. //[WndFunc DECLARATION]
  7441. function WndFunc( W: HWnd; Msg: Cardinal; wParam, lParam: Integer )
  7442. : Integer; stdcall;
  7443. {* Global message handler for window. Redirects all messages to
  7444. destination windows, obtaining target TControl object address from
  7445. window itself, using GetProp API call. }
  7446. //[Applet VARIABLES]
  7447. var AppletRunning: Boolean;
  7448. {* Is set to True while message loop is processing (in Run procedure). }
  7449. AppletTerminated: Boolean;
  7450. {* Is set to True when message loop is terminated. }
  7451. Applet: PControl;
  7452. {* Applet window object. Actually, can be set to main form if program
  7453. not needed in special applet button window (useful to make applet
  7454. button invisible on taskbar, or to have several forms with single
  7455. applet button - crete it in that case using NewApplet). }
  7456. AppButtonUsed: Boolean;
  7457. {* True if special window to represent applet button (may be invisible)
  7458. is used. If no, every form is represented with its own taskbar button
  7459. (always visible). }
  7460. //[Screen DECLARATIONS]
  7461. ScreenCursor: HCursor;
  7462. {* Set this global variable to override any cursor settings of current
  7463. form or control. }
  7464. function ScreenWidth: Integer;
  7465. {* Returns screen width in pixels. }
  7466. function ScreenHeight: Integer;
  7467. {* Returns screen height in pixels. }
  7468. //[Status DECLARATIONS]
  7469. type
  7470. TStatusOption = ( soNoSizeGrip, soTop );
  7471. {* Options available for status bars. }
  7472. TStatusOptions = Set of TStatusOption;
  7473. {* Status bar options. }
  7474. procedure DrawFormattedText( Ctl: PControl; DC: HDC; var R: TRect; Flags: DWORD {EditCtl: Boolean} );
  7475. {* This procedure can be useful to draw control's text in custom-defined controls. }
  7476. {$IFDEF GRAPHCTL_XPSTYLES}
  7477. var DoNotDrawGraphCtlsUsingXPStyles: Boolean;
  7478. procedure DrawFormattedTextXP( Theme: THandle; Ctl: PControl; DC: HDC;
  7479. var R: TRect; CtlType, CtlStates, Flags1, Flags2: Integer );
  7480. {* This procedure can be useful to draw control's text in custom-defined controls. }
  7481. {$ENDIF}
  7482. function _NewGraphCtl( AParent: PControl; ATabStop: Boolean ): PControl;
  7483. {* Creates graphic control basics. }
  7484. function NewGraphLabel( AParent: PControl; const ACaption: String ): PControl;
  7485. {* Creates graphic label, which does not require a window handle. }
  7486. function NewWordWrapGraphLabel( AParent: PControl; const ACaption: String ): PControl;
  7487. {* Creates graphic label, which does not require a window handle. }
  7488. function NewGraphPaintBox( AParent: PControl ): PControl;
  7489. {* Creates graphic paint box (just the same as graphic label, but with empty Caption). }
  7490. function NewGraphCheckBox( AParent: PControl; const ACaption: String ): PControl;
  7491. {* Creates graphic checkbox. }
  7492. function NewGraphRadioBox( AParent: PControl; const ACaption: String ): PControl;
  7493. {* Creates graphic radiobox. }
  7494. function NewGraphButton( AParent: PControl; const ACaption: String ): PControl;
  7495. {* Creates graphic button. }
  7496. function NewGraphEditbox( AParent: PControl; Options: TEditOptions ): PControl;
  7497. {* Creates graphic edit box. To do editing, this box should be replaced with
  7498. real edit box with a handle (actually, it is enough to place an edit box
  7499. on the same Parent having the same BoundsRect). }
  7500. //[Run DECLARATION]
  7501. procedure Run( var AppletWnd: PControl );
  7502. {* |<#appbutton>
  7503. Call this procedure to process messages loop of your program.
  7504. Pass here pointer to applet button object (if You have created it
  7505. - see NewApplet) or your main form object of type PControl (created
  7506. using NewForm).
  7507. |<br><br>
  7508. |<h1 align=center><font color=#FF8040><a name="visual_objects_constructors"></a>
  7509. Visual objects constructing functions
  7510. |</font></h1>
  7511. Following constructing functions for visual controls are available:
  7512. |#control
  7513. }
  7514. procedure TerminateExecution( var AppletWnd: PControl );
  7515. //[Applet FUNCTIONS DECLARATIONS]
  7516. procedure AppletMinimize;
  7517. {* Minimizes the application (Applet should be assigned to have effect). }
  7518. procedure AppletHide;
  7519. {* Minimizes and hides application. }
  7520. procedure AppletRestore;
  7521. {* Restores Applet when minimized. }
  7522. //[Idle handler DECALRATIONS]
  7523. {YS+}
  7524. procedure RegisterIdleHandler( const OnIdle: TOnEvent );
  7525. {* Registers new Idle handler. Idle handler is called each time when
  7526. message queue becomes empty. }
  7527. procedure UnRegisterIdleHandler( const OnIdle: TOnEvent );
  7528. {* Unregisters Idle handler. }
  7529. {YS-}
  7530. //[InitCommonXXXX ANOTHER DECLARATIONS]
  7531. {* ComCtrl32 controls initialization. }
  7532. procedure InitCommonControls; stdcall;
  7533. procedure DoInitCommonControls( dwICC: DWORD );
  7534. {* Calls extended initialization for Common Controls (from ComCtrl32).
  7535. Pass one of following constants:
  7536. |<pre>
  7537. ICC_LISTVIEW_CLASSES = $00000001; // listview, header
  7538. ICC_TREEVIEW_CLASSES = $00000002; // treeview, tooltips
  7539. ICC_BAR_CLASSES = $00000004; // toolbar, statusbar, trackbar, tooltips
  7540. ICC_TAB_CLASSES = $00000008; // tab, tooltips
  7541. ICC_UPDOWN_CLASS = $00000010; // updown
  7542. ICC_PROGRESS_CLASS = $00000020; // progress
  7543. ICC_HOTKEY_CLASS = $00000040; // hotkey
  7544. ICC_ANIMATE_CLASS = $00000080; // animate
  7545. ICC_WIN95_CLASSES = $000000FF;
  7546. ICC_DATE_CLASSES = $00000100; // month picker, date picker, time picker, updown
  7547. ICC_USEREX_CLASSES = $00000200; // comboex
  7548. ICC_COOL_CLASSES = $00000400; // rebar (coolbar) control
  7549. ICC_INTERNET_CLASSES = $00000800;
  7550. ICC_PAGESCROLLER_CLASS = $00001000; // page scroller
  7551. ICC_NATIVEFNTCTL_CLASS = $00002000; // native font control
  7552. |</pre>
  7553. }
  7554. const
  7555. ICC_LISTVIEW_CLASSES = $00000001; // listview, header
  7556. ICC_TREEVIEW_CLASSES = $00000002; // treeview, tooltips
  7557. ICC_BAR_CLASSES = $00000004; // toolbar, statusbar, trackbar, tooltips
  7558. ICC_TAB_CLASSES = $00000008; // tab, tooltips
  7559. ICC_UPDOWN_CLASS = $00000010; // updown
  7560. ICC_PROGRESS_CLASS = $00000020; // progress
  7561. ICC_HOTKEY_CLASS = $00000040; // hotkey
  7562. ICC_ANIMATE_CLASS = $00000080; // animate
  7563. ICC_WIN95_CLASSES = $000000FF;
  7564. ICC_DATE_CLASSES = $00000100; // month picker, date picker, time picker, updown
  7565. ICC_USEREX_CLASSES = $00000200; // comboex
  7566. ICC_COOL_CLASSES = $00000400; // rebar (coolbar) control
  7567. ICC_INTERNET_CLASSES = $00000800;
  7568. ICC_PAGESCROLLER_CLASS = $00001000; // page scroller
  7569. ICC_NATIVEFNTCTL_CLASS = $00002000; // native font control
  7570. //[Ole DECLARATIONS]
  7571. function OleInit: Boolean;
  7572. {* Calls OleInitialize (once - all other calls are simulated by incrementing
  7573. call counter. Every OleInit shoud be complemented with correspondent OleUninit.
  7574. (Though, it is possible to call API function OleUnInitialize once to
  7575. cancel all OleInit calls). }
  7576. procedure OleUnInit;
  7577. {* Decrements counter and calls OleUnInitialize when it is zeroed. }
  7578. var OleInitCount: Integer;
  7579. {-}
  7580. function StringToOleStr(const Source: string): PWideChar;
  7581. {* }
  7582. {+}
  7583. function SysAllocStringLen(psz: PWideChar; len: Integer): PWideChar; stdcall;
  7584. procedure SysFreeString( psz: PWideChar ); stdcall;
  7585. { -- Contructors for visual controls -- }
  7586. //[NewXXXX DECLARATIONS]
  7587. //[_NewWindowed DECLARATION]
  7588. function _NewWindowed( AParent: PControl; ControlClassName: PChar; Ctl3D: Boolean ): PControl;
  7589. //[NewApplet DECLARATION]
  7590. function NewApplet( const Caption: String ): PControl;
  7591. {* |<#control>
  7592. Creates applet button window, which has to be parent of all other forms
  7593. in your project (but this is *not must*). See also comments about NewForm.
  7594. |<br>
  7595. Following methods, properties and events are useful to work with applet
  7596. control:
  7597. |#appbutton }
  7598. //[NewForm DECLARATION]
  7599. function NewForm( AParent: PControl; const Caption: String ): PControl;
  7600. {* |<#control>
  7601. Creates form window object and returns pointer to it. If You use only one form,
  7602. and You are not going to do applet button on task bar invisible, it is not
  7603. necessary to create also special applet button window - just pass
  7604. your (main) form object to Run procedure. In that case, it is a good
  7605. idea to assign pointer to your main form object to Applet variable
  7606. immediately following creating it - because some objects (e.g. TTimer)
  7607. want to have Applet assigned to something.
  7608. |<br>
  7609. |&D=<a href="tcontrol.htm#%1" target=_top> %0 </a>
  7610. Following methods, properties and events are useful to work with forms
  7611. (ones common for all visual objects, such as <D Left>, <D Top>, <D Width>,
  7612. <D Height>, etc. are not listed here - look TControl for it):
  7613. |#form }
  7614. //[_NewControl DECLARATION]
  7615. function _NewControl( AParent: PControl; ControlClassName: PChar;
  7616. Style: DWORD; Ctl3D: Boolean; Actions: PCommandActions ): PControl;
  7617. //[NewButton DECLARATION]
  7618. function NewButton( AParent: PControl; const Caption: String ): PControl;
  7619. {* |<#control>
  7620. Creates button on given parent control or form.
  7621. Please note, that in Windows, buttons can not change its <D Font> color
  7622. and to be <D Transparent>.
  7623. |<br> Following methods, properies and events are (especially) useful with
  7624. a button:
  7625. |#button }
  7626. //[NewBitBtn DECLARATION]
  7627. function NewBitBtn( AParent: PControl; const Caption: String;
  7628. Options: TBitBtnOptions; Layout: TGlyphLayout; GlyphBitmap: HBitmap; GlyphCount: Integer ): PControl;
  7629. {* |<#control>
  7630. Creates image button (actually implemented as owner-drawn). In Options,
  7631. it is possible to determine, whether bitmap or image list used to contain
  7632. one or more (up to 5) images, correspondent to certain BitBtn state.
  7633. |<br>&nbsp;&nbsp;&nbsp;
  7634. For case of imagelist (option bboImageList), it is possible to use a
  7635. number of glyphs from the image list, starting from image index given
  7636. by GlyphCount parameter. Number of used glyphs is passed in that case
  7637. in high word of GlyphCount parameter (if 0, one image is used therefore).
  7638. For bboImageList, BitBtn can be Transparent (and in that case bboNoBorder
  7639. style can be useful to draw custom buttons of non-rectangular shape).
  7640. |<br>&nbsp;&nbsp;&nbsp;
  7641. For case of bitmap BitBtn, image is stretched down (if too big), but can
  7642. not be transparent. It is not necessary for bitmap BitBtn to pass correct
  7643. GlyphCount - it is calculated on base of bitmap size, if 0 is passed.
  7644. |<br>&nbsp;&nbsp;&nbsp;
  7645. And, certainly, BitBtn can be without glyph image (text only). For that
  7646. case, it is therefore is more flexible and power than usual Button (but
  7647. requires more code). E.g., BitBtn can change its <D Font>, <D Color>,
  7648. and to be totally <D Transparent>.
  7649. Moreover, BitBtn can be <D Flat>, bboFixed, <D SpeedButton> and
  7650. have property <D RepeatInterval>.
  7651. |<br>&nbsp;&nbsp;&nbsp;
  7652. Note: if You use bboFixed Style, use OnChange event instead of OnClick,
  7653. because <D Checked> state is changed immediately however OnClick occure
  7654. only when mouse or space key released (and can be not called at all if
  7655. mouse button is released out of BitBtn bounds). Also, bboFixed defines
  7656. only which glyph to show (the border if it is not turned off behaves as
  7657. usual for a button, i.e. it becomes lowered and then raised again at any click).
  7658. Here You can find references to other properties, events and methods
  7659. applicable to BitBtn:
  7660. |#bitbtn }
  7661. //[NewLabel DECLARATION]
  7662. function NewLabel( AParent: PControl; const Caption: String ): PControl;
  7663. {* |<#control>
  7664. Creates static text control (native Windows STATIC control).
  7665. Use property <D Caption> at run time to change label text. Also
  7666. it is possible to adjust label <D Font>, <D Brush> or <D Color>.
  7667. Label can be <D Transparent>. If You want to have rotated text
  7668. label, call NewLabelEffect instead and change its <D Font>.FontOrientation.
  7669. Other references certain for a label:
  7670. |#label }
  7671. //[NewWordWrapLabel DECLARATION]
  7672. function NewWordWrapLabel( AParent: PControl; const Caption: String ): PControl;
  7673. {* |<#control>
  7674. Creates multiline static text control (native Windows STATIC control),
  7675. which can wrap long text onto several lines. See also NewLabel.
  7676. See also:
  7677. |#wwlabel
  7678. |#label }
  7679. //[NewLabelEffect DECLARATION]
  7680. function NewLabelEffect( AParent: PControl; const Caption: String; ShadowDeep: Integer ): PControl;
  7681. {* |<#control>
  7682. Creates 3D-label with capability to rotate its text <D Caption>, which
  7683. is controlled by changing <D Font>.FontOrientation property. If You want
  7684. to get flat effect label (e.g. to rotate it only), pass <D ShadowDeep> = 0.
  7685. Please note, that drawing procedure uses <D Canvas> property, so using of
  7686. LabelEffect leads to increase size of executable.
  7687. See also:
  7688. |#3dlabel
  7689. |#label }
  7690. //[NewPaintbox DECLARATION]
  7691. function NewPaintbox( AParent: PControl ): PControl;
  7692. {* |<#control>
  7693. Creates owner-drawn STATIC control. Set its <D OnPaint> event to
  7694. perform custom painting.
  7695. |#paintbox }
  7696. //[NewImageShow DECLARATION]
  7697. function NewImageShow( AParent: PControl; AImgList: PImageList; ImgIdx: Integer ): PControl;
  7698. {* |<#control>
  7699. Creates an image show control, implemented as a paintbox which is used to
  7700. draw an image from the imagelist. At run-time, use property CurIndex to
  7701. select another image from the imagelist, and a property ImageListNormal to
  7702. use another image list. When the control is created, its size becomes
  7703. equal to dimensions of imagelist (if any). }
  7704. //[NewScrollBar DECLARATION]
  7705. function NewScrollBar( AParent: PControl; BarSide: TScrollerBar ): PControl;
  7706. { * not yet finished... }
  7707. //[NewScrollBox DECLARATION]
  7708. function NewScrollBox( AParent: PControl; EdgeStyle: TEdgeStyle;
  7709. Bars: TScrollerBars ): PControl;
  7710. {* |<#control>
  7711. Creates simple scrolling box, which can be used any way you wish, e.g. to scroll
  7712. certain large image. To provide automatic scrolling of a set of child controls,
  7713. use advanced scroll box, created with NewScrollBoxEx. }
  7714. procedure NotifyScrollBox( Self_, Child: PControl );
  7715. function NewScrollBoxEx( AParent: PControl; EdgeStyle: TEdgeStyle ): PControl;
  7716. {* |<#control>
  7717. Creates extended scrolling box control, which automatically scrolls child
  7718. controls (if any). }
  7719. //[NewGradientPanel DECLARATION]
  7720. function NewGradientPanel( AParent: PControl; Color1, Color2: TColor ): PControl;
  7721. {* |<#control>
  7722. Creates gradient-filled STATIC control. To adjust colors at the
  7723. run time, change <D Color1> and <D Color2> properties (which initially are
  7724. assigned from Color1, Color2 parameters), and call <D Invalidate> method
  7725. to repaint control. }
  7726. function NewGradientPanelEx( AParent: PControl; Color1, Color2: TColor;
  7727. Style: TGradientStyle; Layout: TGradientLayout ): PControl;
  7728. {* |<#control>
  7729. Creates gradient-filled STATIC control. To adjust colors at the
  7730. run time, change <D Color1> and <D Color2> properties (which initially are
  7731. assigned from Color1, Color2 parameters), and call <D Invalidate> method
  7732. to repaint control. Depending on style and first line/point layout, can
  7733. looking different. Idea: Vladimir Stojiljkovic. }
  7734. //[NewPanel DECLARATION]
  7735. function NewPanel( AParent: PControl; EdgeStyle: TEdgeStyle ): PControl;
  7736. {* |<#control>
  7737. Creates panel, which can be parent for other controls (though, any
  7738. control can be used as a parent for other ones, but panel is specially
  7739. designed for such purpose). }
  7740. //[NewMDIxxx DECLARATIONS]
  7741. function NewMDIClient( AParent: PControl; WindowMenu: THandle ): PControl;
  7742. {* |<#control>
  7743. Creates MDI client window, which is a special type of child window,
  7744. containing all MDI child windows, created calling NewMDIChild function.
  7745. On a form, MDI client behaves like a panel, so it can be placed and sized
  7746. (or aligned) like any other controls. To minimize flick during resizing
  7747. main form having another aligned controls, place MDI client window on
  7748. a panel and align it caClient in the panel.
  7749. |<br>Note:
  7750. MDI client must be a single on the form. }
  7751. function NewMDIChild( AParent: PControl; const ACaption: String ): PControl;
  7752. {* |<#control>
  7753. Creates MDI client window. AParent should be a MDI client window,
  7754. created with NewMDIClient function. }
  7755. //[NewSplitter DECLARATIONS]
  7756. function NewSplitter( AParent: PControl; MinSizePrev, MinSizeNext: Integer ): PControl;
  7757. {* |<#control>
  7758. Creates splitter control, which will separate previous one (i.e. last
  7759. created one before splitter on the same parent) from created
  7760. next, allowing to user to adjust size of separated controls by dragging
  7761. the splitter in desired direction. Created splitter becomes vertical
  7762. or horizontal depending on Align style of previous control on the same
  7763. parent (if caLeft/caRight then vertical, if caTop/caBottom then horizontal).
  7764. |<br>&nbsp;&nbsp;&nbsp;
  7765. Please note, what if previous control has no Align equal to caLeft/caRight
  7766. or caTop/caBottom, splitter will not be able to function normally. If
  7767. previous control does not exist, it is yet possible to use splitter as
  7768. a resizeable panel (but set its initial Align value first - otherwise it
  7769. is not set by default. Also, change Cursor property as You wish in that
  7770. case, since it is not set too in case, when previous control does not
  7771. exist).
  7772. |<br>&nbsp;&nbsp;&nbsp;
  7773. Additional parameters determine, which minimal size (width or height -
  7774. correspondently to split direction) is allowed for left (top) control
  7775. and to rest of client area of parent, correspondently. (It is possible
  7776. later to set second control for checking its size with MinSizeNext
  7777. value - using TControl.SecondControl property). If -1 passed,
  7778. correspondent control size is not checked during dragging of splitter.
  7779. Usually 0 is more suitable value (with this value, it is garantee, that
  7780. splitter will be always available even if mouse was released far from the
  7781. edge of form).
  7782. |<br>&nbsp;&nbsp;&nbsp;
  7783. It is possible for user to press Escape any time while dragging splitter
  7784. to abort all adjustments made starting from left mouse button push and
  7785. begin of drag the splitter. But remember please, that such event is
  7786. controlled using timer, and therefore correspondent keyboard events
  7787. are received by currently focused control. Be sure, that pressing Escape
  7788. will not affect to any control on form, which could be focused, otherwise
  7789. filter keyboard messages (by yourself) to prevent undesired handling of
  7790. Escape key by certain controls while splitting. (Use Dragging property
  7791. to check if splitter is dragging by user with mouse).
  7792. |<br>&nbsp;&nbsp;&nbsp;
  7793. See also:
  7794. NewSplitterEx
  7795. |#splitter }
  7796. function NewSplitterEx( AParent: PControl; MinSizePrev, MinSizeNext: Integer;
  7797. EdgeStyle: TEdgeStyle ): PControl;
  7798. {* |<#control>
  7799. Creates splitter control. Difference from NewSplitter is what it is possible
  7800. to determine if a splitter will be beveled or not. See also NewSplitter. }
  7801. //[NewGroupbox DECLARATION]
  7802. function NewGroupbox( AParent: PControl; const Caption: String ): PControl;
  7803. {* |<#control>
  7804. Creates group box control. Note, that to group radio items, group
  7805. box is not necessary - any parent can play role of group for radio items.
  7806. See also NewPanel. }
  7807. //[NewCheckbox DECLARATION]
  7808. function NewCheckbox( AParent: PControl; const Caption: String ): PControl;
  7809. {* |<#control>
  7810. Creates check box control. Special properties, methods, events:
  7811. |#checkbox }
  7812. function NewCheckBox3State( AParent: PControl; const Caption: String ): PControl;
  7813. {* |<#control>
  7814. Creates check box control with 3 states. Special properties, methods,
  7815. events:
  7816. |#checkbox }
  7817. //[NewRadiobox DECLARATION]
  7818. function NewRadiobox( AParent: PControl; const Caption: String ): PControl;
  7819. {* |<#control>
  7820. Creates radio box control. Alternative radio items must have the
  7821. same parent window (regardless of its kind, either groupbox (NewGroupbox),
  7822. panel (NewPanel) or form itself). Following properties, methods and events
  7823. are specially for radiobox controls:
  7824. |#radiobox }
  7825. //[NewEditbox DECLARATION]
  7826. function NewEditbox( AParent: PControl; Options: TEditOptions ): PControl;
  7827. {* |<#control>
  7828. Creates edit box control. To create multiline edit box, similar to
  7829. TMemo in VCL, apply eoMultiline in Options. Following properties, methods,
  7830. events are special for edit controls:
  7831. |#edit }
  7832. //[NewRichEdit DECLARATION]
  7833. function NewRichEdit( AParent: PControl; Options: TEditOptions ): PControl;
  7834. {* |<#control>
  7835. Creates rich text edit control. A rich edit control is a window in which
  7836. the user can enter and edit text. The text can be assigned character and
  7837. paragraph formatting, and can include embedded OLE objects. Rich edit
  7838. controls provide a programming interface for formatting text. However, an
  7839. application must implement any user interface components necessary to make
  7840. formatting operations available to the user.
  7841. |<br>&nbsp;&nbsp;&nbsp;
  7842. Note: eoPassword, eoMultiline options have no effect for RichEdit control.
  7843. Some operations are supersided with special versions of those, created
  7844. especially for RichEdit, but in some cases it is necessary to use
  7845. another properties and methods, specially designed for RichEdit (see
  7846. methods and properties, which names are starting from RE_...).
  7847. |<br>&nbsp;&nbsp;&nbsp;
  7848. Following properties, methods, events are special for edit controls:
  7849. |#richedit
  7850. }
  7851. function NewRichEdit1( AParent: PControl; Options: TEditOptions ): PControl;
  7852. {* |<#control>
  7853. Like NewRichEdit, but to work with older RichEdit control version 1.0
  7854. (window class 'RichEdit' forced to use instead of 'RichEdit20A', even
  7855. if library RICHED20.DLL found and loaded successfully). One more
  7856. difference - OleInit is not called, so the most of OLE capabilities
  7857. of RichEdit could not working. }
  7858. //[NewListbox DECLARATION]
  7859. function NewListbox( AParent: PControl; Options: TListOptions ): PControl;
  7860. {* |<#control>
  7861. Creates list box control. Following properties, methods and events are
  7862. special for Listbox:
  7863. |#listbox }
  7864. //[NewCombobox DECLARATION]
  7865. function NewCombobox( AParent: PControl; Options: TComboOptions ): PControl;
  7866. {* |<#control>
  7867. Creates new combo box control. Note, that it is not possible to align
  7868. combobox caLeft or caRight: this can cause infinit recursion in the
  7869. application.
  7870. |<br>Following properties, methods and events are
  7871. special for Combobox:
  7872. |#combo }
  7873. //[_NewCommonControl DECLARATION]
  7874. function _NewCommonControl( AParent: PControl; ClassName: PChar; Style: DWORD;
  7875. Ctl3D: Boolean; Actions: PCommandActions ): PControl;
  7876. //[NewProgressbar DECLARATION]
  7877. function NewProgressbar( AParent: PControl ): PControl;
  7878. {* |<#control>
  7879. Creates progress bar control. Following properties are special for
  7880. progress bar:
  7881. |#progressbar
  7882. See also NewProgressEx. }
  7883. function NewProgressbarEx( AParent: PControl; Options: TProgressbarOptions ): PControl;
  7884. {* |<#control>
  7885. Can create progress bar with smooth style (progress is not segmented
  7886. onto bricks) or/and vertical progress bar - using additional parameter.
  7887. For list of properties, suitable for progress bars, see NewProgressbar. }
  7888. //[NewListVew DECLARATION]
  7889. function NewListView( AParent: PControl; Style: TListViewStyle; Options: TListViewOptions;
  7890. ImageListSmall, ImageListNormal, ImageListState: PImageList ): PControl;
  7891. {* |<#control>
  7892. Creates list view control. It is very powerful control, which can partially
  7893. compensate absence of grid controls (in lvsDetail view mode). Properties,
  7894. methods and events, special for list view control are:
  7895. |#listview }
  7896. //[NewTreeView DECLARATION]
  7897. function NewTreeView( AParent: PControl; Options: TTreeViewOptions;
  7898. ImgListNormal, ImgListState: PImageList ): PControl;
  7899. {* |<#control>
  7900. Creates tree view control. See tree view methods and properties:
  7901. |#treeview }
  7902. //[NewTabControl DECLARATION]
  7903. function NewTabControl( AParent: PControl; Tabs: array of String; Options: TTabControlOptions;
  7904. ImgList: PImageList; ImgList1stIdx: Integer ): PControl;
  7905. {* |<#control>
  7906. Creates new tab control (like notebook). To place child control on a certain
  7907. page of TabControl, use property Pages[ Idx ], for example:
  7908. ! Label1 := NewLabel( TabControl1.Pages[ 0 ], 'Label1' );
  7909. | &nbsp;&nbsp;&nbsp;
  7910. To determine number of pages at run time, use property <D Count>;
  7911. |<br> to determine which page is currently selected (or to change
  7912. selection), use property <D CurrentIndex>;
  7913. |<br> to feedback to switch between tabs assign your handler to OnSelChange
  7914. event;
  7915. |<br>Note, that by default, tab control is created with a border lowered to
  7916. tab control's parent. To remove it, you can apply WS_EX_TRANSPARENT extended
  7917. style (see TControl.ExStyle property), but painting of some child controls
  7918. can be strange a bit in this case (no border drawing for edit controls was
  7919. found, but not always...). You can also apply style WS_THICKFRAME (TControl.Style
  7920. property) to make the border raised.
  7921. |<br> Other methods and properties, suitable for tab control, are:
  7922. |#tabcontrol }
  7923. //[NewToolbar DECLARATION]
  7924. function NewToolbar( AParent: PControl; Align: TControlAlign; Options: TToolbarOptions;
  7925. Bitmap: HBitmap; Buttons: array of PChar;
  7926. BtnImgIdxArray: array of Integer ) : PControl;
  7927. {* |<#control>
  7928. Creates toolbar control. Bitmap must contain images for all buttons
  7929. excluding separators (defined by string '-' in Buttons array), otherwise
  7930. last buttons will no have images at all. Image width for every button
  7931. is assumed to be equal to Bitmap height (if last of "squares" has
  7932. insufficient width, it will not be used). To define fixed buttons, use
  7933. characters '+' or '-' as a prefix for button string (even empty). To
  7934. create groups of (radio-)buttons, use also '!' follow '+' or '-'. (These rules
  7935. are similar used in menu creation). To define drop down button, use (as
  7936. first) prefix '^'. (Do not forget to set <D OnTBDropDown> event for this
  7937. case). If You want to assign images to buttons not in the same order
  7938. how these are placed in Bitmap (or You use system bitmap), define for every
  7939. button (in BtnImgIdxArray array) indexes for every button (excluding
  7940. separator buttons). Otherwise, it is possible to define index only for first
  7941. button (e.g., [0]). It is also possible to change TBImages[ ] property
  7942. for such purpose, or do the same in method TBSetBtnImgIdx).
  7943. |<br>
  7944. Following properties, methods and event are specially designed to work with
  7945. toolbar control:
  7946. |#toolbar
  7947. |<br>&nbsp;&nbsp;&nbsp;
  7948. If your project uses Align property to align controls, this can conflict with
  7949. toolbar native aligning. To solve such problem, place toolbar to parent panel,
  7950. which has its own Align property assigned to desired value.
  7951. |<br>
  7952. To create toolbar with buttons, drawn from top to bottom, instead from left
  7953. to right, combine caLeft / caRight in Align parameter and style tboWrapable
  7954. when create toolbar. To adjust width of vertically aligned toolbar, it is
  7955. possible to call ResizeParentLeft for it. E.g.:
  7956. ! P0 := NewPanel( W, esRaised ) .SetSize( 30, 0 ) .SetAlign( caLeft );
  7957. ! // ^^^^^^^^^^^^^^^^^ //////
  7958. !TB := NewToolbar( P0, caLeft, [ tboNoDivider, tboWrapable ], DWORD(-1),
  7959. ! // ////// ///////////
  7960. ! [ ' ', ' ', ' ', '-', ' ', ' ' ],
  7961. ! [ STD_FILEOPEN ] ).ResizeParentRight;
  7962. !//Note, that caLeft is *must*, and tboWrapable style too. SetSize for
  7963. !//parent panel is not necessary, but only if ResizeParentRight is called
  7964. !//than for Toolbar.
  7965. |<br><br>
  7966. One more note: if You create toolbar without text labels (passing ' ' for
  7967. each button You add), include also option tboTextRight to fix incorrect
  7968. sizing of buttons under Windows9x.
  7969. }
  7970. //[NewDateTimePicker DECLARATION]
  7971. function NewDateTimePicker( AParent: PControl; Options: TDateTimePickerOptions )
  7972. : PControl;
  7973. {* |<#control>
  7974. Creates date and time picker common control.
  7975. }
  7976. { -- Constructor for Image List objet -- }
  7977. //[NewImageList DECLARATION]
  7978. function NewImageList( AOwner: PControl ): PImageList;
  7979. {* Constructor of TImageList object. Unlike other non-visual objects, image list
  7980. can be parented by TControl object (but this does not *must*), and in that
  7981. case it is destroyed automatically when its parent control is destroyed.
  7982. Every control can have several TImageList objects, linked to a simple list.
  7983. But if any TImageList object is destroyed, all following ones are destroyed
  7984. too (at least, now I implemented it so). }
  7985. //[TIMER]
  7986. type
  7987. {++}(*TTimer = class;*){--}
  7988. PTimer = {-}^{+}TTimer;
  7989. { ----------------------------------------------------------------------
  7990. TTimer object
  7991. ----------------------------------------------------------------------- }
  7992. //[TTimer DEFINITION]
  7993. TTimer = object( TObj )
  7994. {* Easy timer incapsulation object. Uses applet window to
  7995. receive timer events. So, either assign your main form
  7996. to Applet variable or create applet button object (and
  7997. assign it to Applet) before enabling timer. }
  7998. protected
  7999. fHandle : Integer;
  8000. fEnabled: Boolean;
  8001. fInterval: Integer;
  8002. fOnTimer: TOnEvent;
  8003. procedure SetEnabled(const Value: Boolean); virtual;
  8004. procedure SetInterval(const Value: Integer);
  8005. protected
  8006. {++}(*public*){--}
  8007. destructor Destroy; {-}virtual;{+}{++}(*override;*){--}
  8008. {* Destructor. }
  8009. public
  8010. property Handle : Integer read fHandle;
  8011. {* Windows timer object handle. }
  8012. property Enabled : Boolean read fEnabled write SetEnabled;
  8013. {* True, is timer is on. Initially, always False. Before assigning True,
  8014. make sure, that Applet global variable is assigned to applet object
  8015. (NewApplet) or to form (NewForm). }
  8016. property Interval : Integer read fInterval write SetInterval;
  8017. {* Interval in milliseconds (1000 is default and means 1 second). }
  8018. property OnTimer : TOnEvent read fOnTimer write fOnTimer;
  8019. {* Event, which is called when time interval is over. }
  8020. end;
  8021. //[END OF TTimer DEFINITION]
  8022. //[NewTimer DECLARATION]
  8023. function NewTimer( Interval: Integer ): PTimer;
  8024. {* Constructs initially disabled timer with interval 1000 (1 second). }
  8025. //[MULTIMEDIA TIMER]
  8026. type
  8027. {++}(*TMMTimer = class;*){--}
  8028. PMMTimer = {-}^{+}TMMTimer;
  8029. //[TMMTimer DEFINITION]
  8030. TMMTimer = object( TTimer )
  8031. {* Multimedia timer incapsulation object. Does not require Applet or special
  8032. window to handle it. System creates a thread for each high resolution
  8033. timer, so using many such objects can degrade total PC performance. }
  8034. protected
  8035. FResolution: Integer;
  8036. FPeriodic: Boolean;
  8037. procedure SetEnabled(const Value: Boolean); {-}virtual;{+}{++}(*override;*){--}
  8038. public
  8039. destructor Destroy; {-}virtual;{+}{++}(*override;*){--}
  8040. {* }
  8041. property Resolution: Integer read FResolution write FResolution;
  8042. {* Minimum timer resolution. The less the more accuracy (0 is exactly
  8043. Interval milliseconds between timer shots). It is recommended to set
  8044. this property greater to prevent entire system from reducing overhead.
  8045. If you change this value, reset and then set Enabled again to apply
  8046. changes. }
  8047. property Periodic: Boolean read FPeriodic write FPeriodic;
  8048. {* TRUE, if timer is periodic (default). Otherwise, timer is one-shot
  8049. (set it Enabled every time in such case for each shot). If you change
  8050. this property, reset and set Enabled property again to get effect. }
  8051. end;
  8052. //[END OF TMMTimer DEFINITION]
  8053. //[NewMMTimer DECLARATION]
  8054. function NewMMTimer( Interval: Integer ): PMMTimer;
  8055. {* Creates multimedia timer object. Initially, it has Resolution = 0,
  8056. Periodic = TRUE and Enabled = FALSE. Do not forget also to assign your
  8057. event handler to OnTimer to do something on timer shot. }
  8058. { -- TTrayIcon object -- }
  8059. //[TRAYICON]
  8060. type
  8061. TOnTrayIconMouse = procedure( Sender: PObj; Message : Word ) of object;
  8062. {* Event type to be called when Applet receives a message from an icon,
  8063. added to the taskbar tray. }
  8064. {++}(*TTrayIcon = class;*){--}
  8065. PTrayIcon = {-}^{+}TTrayIcon;
  8066. { ----------------------------------------------------------------------
  8067. TTrayIcon - icon in tray area of taskbar
  8068. ----------------------------------------------------------------------- }
  8069. //[TTrayIcon DEFINITION]
  8070. TTrayIcon = object(TObj)
  8071. {* Object to place (and change) a single icon onto taskbar tray. }
  8072. protected
  8073. FIcon: HIcon;
  8074. FActive: Boolean;
  8075. FTooltip: String;
  8076. FOnMouse: TOnTrayIconMouse;
  8077. FControl: PControl;
  8078. fAutoRecreate: Boolean;
  8079. FNoAutoDeactivate: Boolean;
  8080. FWnd: HWnd;
  8081. procedure SetIcon(const Value: HIcon);
  8082. procedure SetActive(const Value: Boolean);
  8083. procedure SetTrayIcon( const Value : DWORD );
  8084. procedure SetTooltip(const Value: String);
  8085. procedure SetAutoRecreate(const Value: Boolean);
  8086. protected
  8087. {++}(*public*){--}
  8088. destructor Destroy; {-}virtual;{+}{++}(*override;*){--}
  8089. {* Destructor. Use Free method instead (as usual). }
  8090. public
  8091. property Icon : HIcon read FIcon write SetIcon;
  8092. {* Icon to be shown on taskbar tray. If not set, value of Active
  8093. property has no effect. It is also possible to assign a value
  8094. to Icon property after assigning True to Active to install
  8095. icon first time or to replace icon with another one (e.g. to
  8096. get animation effect).
  8097. |<br>&nbsp;&nbsp;&nbsp;
  8098. Previously allocated icon (if any) is not deleted using
  8099. DeleteObject. This is normal for icons, loaded from resource
  8100. (e.g., by LoadIcon API call). But if icon was created (e.g.) by
  8101. CreateIconIndirect, your code is responsible for destroying
  8102. of it). }
  8103. property Active : Boolean read FActive write SetActive;
  8104. {* Set it to True to show assigned Icon on taskbar tray. Default
  8105. is False. Has no effect if Icon property is not assigned.
  8106. TrayIcon is deactivated automatically when Applet is finishing
  8107. (but only if Applet window is used as a "parent" for tray
  8108. icon object). }
  8109. property Tooltip : String read FTooltip write SetTooltip;
  8110. {* Tooltip string, showing automatically when mouse is moving
  8111. over installed icon. Though "huge string" type is used, only
  8112. first 63 characters are considered. Also note, that only in
  8113. most recent versions of Windows multiline tooltips are supported. }
  8114. property OnMouse : TOnTrayIconMouse read FOnMouse write FOnMouse;
  8115. {* Is called then mouse message is taking place concerning installed
  8116. icon. Only type of message can be obtained (e.g. WM_MOUSEMOVE,
  8117. WM_LBUTTONDOWN etc.) }
  8118. property AutoRecreate: Boolean read fAutoRecreate write SetAutoRecreate;
  8119. {* If set to TRUE, auto-recreating of tray icon is proveded in case,
  8120. when Explorer is restarted for some (unpredictable) reasons. Otherwise,
  8121. your tray icon is disappeared forever, and if this is the single way
  8122. to communicate with your application, the user nomore can achieve it. }
  8123. property NoAutoDeactivate: Boolean read FNoAutoDeactivate write FNoAutoDeactivate;
  8124. {* If set to true, tray icon is not removed from tray automatically on
  8125. WM_CLOSE message receive by owner control. Set Active := FALSE in
  8126. your code for such case before accepting closing the form. }
  8127. property Wnd: HWnd read FWnd write FWnd;
  8128. {* A window to use as a base window for tray icon messages. Overrides
  8129. parent Control handle is assigned. Note, that if Wnd property used,
  8130. message handling is not done automatically, and you should do this in
  8131. your code, or at least for one tray icon object, call AttachProc2Wnd. }
  8132. procedure AttachProc2Wnd;
  8133. {* Call this method for a tray icon object in case if Wnd used rather then
  8134. control. It is enough to call this method once for each Wnd used, even
  8135. if several other tray icons are also based on the same Wnd. See also
  8136. DetachProc2Wnd method. }
  8137. procedure DetachProc2Wnd;
  8138. {* Call this method to detach window procedure attached via AttachProc2Wnd.
  8139. Do it once for a Wnd, used as a base to handle tray icon messages.
  8140. Caution! If you do not call this method before destroying Wnd, the
  8141. application will not functioning normally. }
  8142. end;
  8143. {* When You create invisible application, which should be represented by
  8144. only the tray icon, prepare a handle for the window, resposible for
  8145. messages handling. Remember, that window handle is created automatically
  8146. only when a window is showing first time. If window's property Visible is
  8147. set to False, You should to call CreateWindow manually.
  8148. <br>
  8149. There is a known bug exist with similar invisible tray-iconized applications.
  8150. When a menu is activated in response to tray mouse event, if there was
  8151. not active window, belonging to the application, the menu is not disappeared
  8152. when mouse is clicked anywhere else. This bug is occure in Windows9x/ME.
  8153. To avoid it, activate first your form window. This last window shoud have
  8154. status visible (but, certainly, there are no needs to place it on visible
  8155. part of screen - change its position, so it will not be visible for user,
  8156. if You wish).
  8157. <br>
  8158. Also, to make your application "invisible" but until special event is occure,
  8159. use Applet separate from the main form, and make for both Visible := False.
  8160. This allows for You to make your form visible any time You wish, and without
  8161. making application button visible if You do not wish.
  8162. }
  8163. {= ,
  8164. , Handle ,
  8165. . , Handle
  8166. , .
  8167. Visible FALSE, CreateWindow .
  8168. <br>
  8169. BUG
  8170. . ,
  8171. . Windows9x/ME.
  8172. , ().
  8173. (, ,
  8174. , ).
  8175. <br>
  8176. , , ,
  8177. , TControl -
  8178. Applet, FALSE Visible.
  8179. }
  8180. //[END OF TTrayIcon DEFINITION]
  8181. //[NewTrayIcon DECLARATION]
  8182. function NewTrayIcon( Wnd: PControl; Icon: HIcon ): PTrayIcon;
  8183. {* Constructor of TTrayIcon object. Pass main form or applet as Wnd
  8184. parameter. }
  8185. //[JUST ONE]
  8186. { -- JustOne -- }
  8187. type
  8188. TOnAnotherInstance = procedure( const CmdLine: String ) of object;
  8189. {* Event type to use in JustOneNotify function. }
  8190. function JustOne( Wnd: PControl; const Identifier : String ) : Boolean;
  8191. {* Returns True, if this is a first instance. For all other instances
  8192. (application is already running), False is returned. }
  8193. function JustOneNotify( Wnd: PControl; const Identifier : String;
  8194. const aOnAnotherInstance: TOnAnotherInstance ) : Boolean;
  8195. {* Returns True, if this is a first instance. For all other instances
  8196. (application is already running), False is returned. If handler
  8197. aOnAnotherInstance passed, it is called (in first instance) every time
  8198. when another instance of an application is started, receiving command
  8199. line used to run it. }
  8200. { -- string (mainly) utility procedures and functions. -- }
  8201. //[Message Box DECLARATIONS]
  8202. function MsgBox( const S: String; Flags: DWORD ): DWORD;
  8203. {* Displays message box with the same title as Applet.Caption. If applet
  8204. is not running, and Applet global variable is not assigned, caption
  8205. 'Error' is displayed (but actually this is not an error - the system
  8206. does so, if nil is passed as a title).
  8207. |<br>&nbsp;&nbsp;&nbsp;
  8208. Returns ID_... result (correspondently to flags passed (MB_OK, MBYESNO,
  8209. etc. -> ID_OK, ID_YES, ID_NO, etc.) }
  8210. procedure MsgOK( const S: String );
  8211. {* Displays message box with the same title as Applet.Caption (or 'Error',
  8212. if Applet is not running). }
  8213. function ShowMsg( const S: String; Flags: DWORD ): DWORD;
  8214. {* Displays message box like MsgBox, but uses Applet.Handle as a parent
  8215. (so the message has no button on a task bar). }
  8216. procedure ShowMessage( const S: String );
  8217. {* Like ShowMsg, but has only styles MB_OK and MB_SETFOREGROUND. }
  8218. procedure ShowMsgModal( const S: String );
  8219. {* This message function can be used out of a message loop (e.g., after
  8220. finishing the application). It is always modal.
  8221. Actually, a form with word-wrap label (decorated as borderless edit
  8222. box with btnFace color) and with OK button is created and shown modal.
  8223. When a dialog is called from outside message loop, caption 'Information'
  8224. is always displayed.
  8225. Dialog form is automatically resized vertically to fit message text
  8226. (but until screen height is achieved) and shown always centered on
  8227. screen. The width is fixed (400 pixels).
  8228. |<br>
  8229. Do not use this function outside the message loop for case, when the
  8230. Applet variable is not used in an application. }
  8231. function ShowQuestion( const S: String; Answers: String ): Integer;
  8232. {* Modal dialog like ShowMsgModal. It is based on KOL form, so it can
  8233. be called also out of message loop, e.g. after finishing the
  8234. application. Also, this function *must* be used in MDI applications
  8235. in place of any dialog functions, based on MessageBox.
  8236. |<br>
  8237. The second parameter should be empty string or several possible
  8238. answers separated by '/', e.g.: 'Yes/No/Cancel'. Result is
  8239. a number answered, starting from 1. For example, if 'Cancel'
  8240. was pressed, 3 will be returned.
  8241. |<br>
  8242. User can also press ESCAPE key, or close modal dialog. In such case
  8243. -1 is returned. }
  8244. function ShowQuestionEx( const S: String; Answers: String; CallBack: TOnEvent ): Integer;
  8245. {* Like ShowQuestion, but with CallBack function, called just before showing
  8246. the dialog. }
  8247. procedure SpeakerBeep( Freq: Word; Duration: DWORD );
  8248. {* On Windows NT, calls Windows.Beep. On Windows 9x, produces beep on speaker
  8249. of desired frequency during given duration time (in milliseconds). }
  8250. {++}(*
  8251. function FormatMessage(dwFlags: DWORD; lpSource: Pointer; dwMessageId: DWORD; dwLanguageId: DWORD;
  8252. lpBuffer: PChar; nSize: DWORD; Arguments: Pointer): DWORD; stdcall;
  8253. *){--}
  8254. function SysErrorMessage(ErrorCode: Integer): string;
  8255. {* Creates and returns a string containing formatted system error message.
  8256. It is possible then to display this message or write it to a log
  8257. file, e.g.:
  8258. ! ShowMsg( SysErrorMessage( GetLastError ) );
  8259. |&R=<a name="%0"></a><font color=#FF8040><h1>%0</h1></font>
  8260. <R 64-bit integer numbers>
  8261. }
  8262. //[I64 TYPE]
  8263. type
  8264. I64 = record
  8265. {* 64 bit integer record. Use it and correspondent functions below in KOL
  8266. projects to avoid dependancy from Delphi version (earlier versions of
  8267. Delphi had no Int64 type). }
  8268. Lo, Hi: DWORD;
  8269. end;
  8270. PI64 = ^I64;
  8271. {* }
  8272. {-}
  8273. {$IFNDEF _D4orHigher}
  8274. Int64 = I64;
  8275. PInt64 = PI64;
  8276. {$ENDIF}
  8277. function MakeInt64( Lo, Hi: DWORD ): I64;
  8278. {* }
  8279. function Int2Int64( X: Integer ): I64;
  8280. {* }
  8281. procedure IncInt64( var I64: I64; Delta: Integer );
  8282. {* I64 := I64 + Delta; }
  8283. procedure DecInt64( var I64: I64; Delta: Integer );
  8284. {* I64 := I64 - Delta; }
  8285. function Add64( const X, Y: I64 ): I64;
  8286. {* Result := X + Y; }
  8287. function Sub64( const X, Y: I64 ): I64;
  8288. {* Result := X - Y; }
  8289. function Neg64( const X: I64 ): I64;
  8290. {* Result := -X; }
  8291. function Mul64i( const X: I64; Mul: Integer ): I64;
  8292. {* Result := X * Mul; }
  8293. function Div64i( const X: I64; D: Integer ): I64;
  8294. {* Result := X div D; }
  8295. function Mod64i( const X: I64; D: Integer ): Integer;
  8296. {* Result := X mod D; }
  8297. function Sgn64( const X: I64 ): Integer;
  8298. {* Result := sign( X ); i.e.:
  8299. |<br>
  8300. if X < 0 then -1
  8301. |<br>
  8302. if X = 0 then 0
  8303. |<br>
  8304. if X > 0 then 1 }
  8305. function Cmp64( const X, Y: I64 ): Integer;
  8306. {* Result := sign( X - Y ); i.e.
  8307. |<br>
  8308. if X < Y then -1
  8309. |<br>
  8310. if X = Y then 0
  8311. |<br>
  8312. if X > Y then 1 }
  8313. function Int64_2Str( X: I64 ): String;
  8314. {* }
  8315. function Str2Int64( const S: String ): I64;
  8316. {* }
  8317. function Int64_2Double( const X: I64 ): Double;
  8318. {* }
  8319. function Double2Int64( D: Double ): I64;
  8320. {*
  8321. <R Floating point numbers>
  8322. }
  8323. const
  8324. NAN = 0.0 / 0.0;
  8325. {+}
  8326. {++}(*const NAN = 1e-100;*){--}
  8327. function IsNan(const AValue: Double): Boolean;
  8328. {* Checks is an argument passed is NAN. }
  8329. function IntPower(Base: Extended; Exponent: Integer): Extended;
  8330. {* Result := Base ^ Exponent; }
  8331. //[String<->Double DECLARATIONS]
  8332. function Str2Double( const S: String ): Double;
  8333. {* }
  8334. function Double2Str( D: Double ): String;
  8335. {* }
  8336. function Extended2Str( E: Extended ): String;
  8337. {* }
  8338. function Double2StrEx( D: Double ): String;
  8339. {* experimental, do not use }
  8340. function TruncD( D: Double ): Double;
  8341. {* Result := trunc( D ) as Double;
  8342. |<hr>
  8343. <R Small bit arrays (max 32 bits in array)>
  8344. See also TBits object.
  8345. }
  8346. //[SMALL BIT ARRAYS DECLARATIONS]
  8347. function GetBits( N: DWORD; first, last: Byte ): DWord;
  8348. {* Retuns bits straing from <first> and to <last> inclusively. }
  8349. function GetBitsL( N: DWORD; from, len: Byte ): DWord;
  8350. {* Retuns len bits starting from index <from>.
  8351. |<hr>
  8352. <R Arithmetics, geometry and other utility functions>
  8353. See also units KolMath.pas, CplxMath.pas and Err.pas.
  8354. }
  8355. //[MulDiv DECLARATION]
  8356. {$IFNDEF FPC}
  8357. function MulDiv( A, B, C: Integer ): Integer;
  8358. {* Returns A * B div C. Small and fast. }
  8359. {$ENDIF}
  8360. //[TMethod TYPE]
  8361. type
  8362. ///////////////////////////////////////////
  8363. {$ifndef _D6orHigher} //
  8364. ///////////////////////////////////////////
  8365. TMethod = packed record
  8366. {* Is defined here because using of VCL classes.pas unit is
  8367. not recommended in XCL. This record type is used often
  8368. to set/access event handlers, referring to a procedure
  8369. of object (usually to set such event to an ordinal
  8370. procedure setting Data field to nil. }
  8371. Code: Pointer; // Pointer to method code.
  8372. {* If used to fake assigning to event handler of type 'procedure
  8373. of object' with ordinal procedure pointer, use symbol '@'
  8374. before method:
  8375. |<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font face="Courier"><b>
  8376. | Method.Code := @MyProcedure;
  8377. |</b></font> }
  8378. Data: Pointer; // Pointer to object, owning the method.
  8379. {* To fake event of type 'procedure of object' with setting it to
  8380. ordinal procedure assign here NIL; }
  8381. end;
  8382. {* When assigning TMethod record to event handler, typecast it with
  8383. desired event type, e.g.:
  8384. |<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font face="Courier"><b>
  8385. | SomeObject.OnSomeEvent := TOnSomeEvent( Method );
  8386. |</b></font><br> }
  8387. ///////////////////////////////////////////
  8388. {$endif} //
  8389. ///////////////////////////////////////////
  8390. PMethod = ^TMethod;
  8391. {* }
  8392. function MakeMethod( Data, Code: Pointer ): TMethod;
  8393. {* Help function to construct TMethod record. Can be useful to
  8394. assign regular type procedure/function as event handler for
  8395. event, defined as object method (do not forget, that in that
  8396. case it must have first dummy parameter to replace @Self,
  8397. passed in EAX to methods of object). }
  8398. //[Rectangles&Points DECLARATIONS]
  8399. function MakeRect( Left, Top, Right, Bottom: Integer ): TRect; stdcall;
  8400. {* Use it instead of VCL Rect function }
  8401. function RectsEqual( const R1, R2: TRect ): Boolean;
  8402. {* Returns True if rectangles R1 and R2 have the same bounds }
  8403. function RectsIntersected( const R1, R2: TRect ): Boolean;
  8404. {* Returns TRUE if rectangles R1 and R2 have at least one common point.
  8405. Note, that right and bottom bounds of rectangles are not their part,
  8406. so, if such points are lying on that bounds, FALSE is returned. }
  8407. function PointInRect( const P: TPoint; const R: TRect ): Boolean;
  8408. {* Returns True if point P is located in rectangle R (including
  8409. left and top bounds but without right and bottom bounds of the
  8410. rectangle). }
  8411. function MakePoint( X, Y: Integer ): TPoint;
  8412. {* Use instead of VCL function Point }
  8413. //[MakeFlags DECLARATION]
  8414. function MakeFlags( FlgSet: PDWORD; FlgArray: array of Integer): Integer;
  8415. {* }
  8416. function MakeDateTimeRange( D1, D2: TDateTime ): TDateTimeRange;
  8417. {* Returns TDateTimeRange from two TDateTime bounds. }
  8418. //[Integer FUNCTIONS DECLARATIONS]
  8419. procedure Swap( var X, Y: Integer );
  8420. {* exchanging values }
  8421. function Min( X, Y: Integer ): Integer;
  8422. {* minimum of two integers }
  8423. function Max( X, Y: Integer ): Integer;
  8424. {* maximum of two integers }
  8425. {$IFDEF REDEFINE_ABS}
  8426. function Abs( X: Integer ): Integer;
  8427. {* absolute value }
  8428. {$ENDIF}
  8429. function Sgn( X: Integer ): Integer;
  8430. {* sign of X: if X < 0, -1 is returned, if > 0, then +1, otherwise 0. }
  8431. function iSqrt( X: Integer ): Integer;
  8432. {* square root
  8433. |<hr>
  8434. <R String to number and number to string conversions>
  8435. }
  8436. //[Integer<->String DECLARATIONS]
  8437. function Int2Hex( Value : DWord; Digits : Integer ) : String;
  8438. {* Converts integer Value into string with hex number. Digits parameter
  8439. determines minimal number of digits (will be completed by adding
  8440. necessary number of leading zeroes). }
  8441. function Int2Str( Value : Integer ) : String;
  8442. {* Obvious. }
  8443. function UInt2Str( Value: DWORD ): String;
  8444. {* The same as Int2Str, but for unsigned integer value. }
  8445. function Int2StrEx( Value, MinWidth: Integer ): String;
  8446. {* Like Int2Str, but resulting string filled with leading spaces to provide
  8447. at least MinWidth characters. }
  8448. function Int2Rome( Value: Integer ): String;
  8449. {* Represents number 1..8999 to Rome numer. }
  8450. function Int2Ths( I : Integer ) : String;
  8451. {* Converts integer into string, separating every three digits from each
  8452. other by character ThsSeparator. (Convert to thousands). You }
  8453. function Int2Digs( Value, Digits : Integer ) : String;
  8454. {* Converts integer to string, inserting necessary number of leading zeroes
  8455. to provide desired length of string, given by Digits parameter. If
  8456. resulting string is greater then Digits, string is not truncated anyway. }
  8457. function Num2Bytes( Value : Double ) : String;
  8458. {* Converts double float to string, considering it as a bytes count.
  8459. If Value is sufficiently large, number is represented in kilobytes (with
  8460. following letter K), or in megabytes (M), gigabytes (G) or terabytes (T).
  8461. Resulting string number is truncated to two decimals (.XX) or to one (.X),
  8462. if the second is 0. }
  8463. function S2Int( S: PChar ): Integer;
  8464. {* Converts null-terminated string to Integer. Scanning stopped when any
  8465. non-digit character found. Even empty string or string not containing
  8466. valid integer number silently converted to 0. }
  8467. function Str2Int(const Value : String) : Integer;
  8468. {* Converts string to integer. First character, which can not be
  8469. recognized as a part of number, regards as a separator. Even
  8470. empty string or string without number silently converted to 0. }
  8471. function Hex2Int( const Value : String) : Integer;
  8472. {* Converts hexadecimal number to integer. Scanning is stopped
  8473. when first non-hexadicimal character is found. Leading dollar ('$')
  8474. character is skept (if present). Minus ('-') is not concerning as
  8475. a sign of number and also stops scanning.}
  8476. function cHex2Int( const Value : String) : Integer;
  8477. {* As Hex2Int, but also checks for leading '0x' and skips it. }
  8478. function Octal2Int( const Value: String ) : Integer;
  8479. {* Converts octal number to integer. Scanning is stopped on first
  8480. non-octal digit (any char except 0..7). There are no checking if
  8481. there octal numer in the parameter. If the first char is not octal
  8482. digit, 0 is returned. }
  8483. function Binary2Int( const Value: String ) : Integer;
  8484. {* Converts binary number to integer. Like Octal2Int, but only digits
  8485. 0 and 1 are allowed. }
  8486. {$IFNDEF _FPC}
  8487. function Format( const fmt: string; params: array of const ): String;
  8488. {* Uses API call to wvsprintf, so does not understand extra formats,
  8489. such as floating point, date/time, currency conversions. See list of
  8490. available formats in win32.hlp (topic wsprintf).
  8491. |<hr>
  8492. <R Working with null-terminated and ansi strings>
  8493. }
  8494. {$ENDIF _FPC}
  8495. //[String FUNCTIONS DECLARATIONS]
  8496. function StrComp(const Str1, Str2: PChar): Integer;
  8497. {* Compares two strings fast. -1: Str1<Str2; 0: Str1=Str2; +1: Str1>Str2 }
  8498. function StrComp_NoCase(const Str1, Str2: PChar): Integer;
  8499. {* Compares two strings fast without case sensitivity.
  8500. Returns: -1 when Str1<Str2; 0 when Str1=Str2; +1 when Str1>Str2 }
  8501. function StrLComp(const Str1, Str2: PChar; MaxLen: Cardinal): Integer;
  8502. {* Compare two strings (fast). Terminating 0 is not considered, so if
  8503. strings are equal, comparing is continued up to MaxLen bytes.
  8504. Since this, pass minimum of lengths as MaxLen. }
  8505. function StrLComp_NoCase(const Str1, Str2: PChar; MaxLen: Cardinal): Integer;
  8506. {* Compare two strings fast without case sensitivity.
  8507. Terminating 0 is not considered, so if strings are equal,
  8508. comparing is continued up to MaxLen bytes.
  8509. Since this, pass minimum of lengths as MaxLen. }
  8510. function StrCopy( Dest, Source: PChar ): PChar;
  8511. {* Copy source string to destination (fast). Pointer to Dest is returned. }
  8512. function StrCat( Dest, Source: PChar ): PChar;
  8513. {* Append source string to destination (fast). Pointer to Dest is returned. }
  8514. function StrLen(const Str: PChar): Cardinal;
  8515. {* StrLen returns the number of characters in Str, not counting the null
  8516. terminator. }
  8517. function StrScanLen(Str: PChar; Chr: Char; Len: Integer): PChar;
  8518. {* Fast scans string Str of length Len searching character Chr.
  8519. Pointer to a character next to found or to Str[Len] (if no one found)
  8520. is returned. }
  8521. function StrScan(Str: PChar; Chr: Char): PChar;
  8522. {* Fast search of given character in a string. Pointer to found character
  8523. (or nil) is returned. }
  8524. function StrRScan(const Str: PChar; Chr: Char): PChar;
  8525. {* StrRScan returns a pointer to the last occurrence of Chr in Str. If Chr
  8526. does not occur in Str, StrRScan returns NIL. The null terminator is
  8527. considered to be part of the string. }
  8528. function StrIsStartingFrom( Str, Pattern: PChar ): Boolean;
  8529. {* Returns True, if string Str is starting from Pattern, i.e. if
  8530. Copy( Str, 1, StrLen( Pattern ) ) = Pattern. Str must not be nil! }
  8531. function StrIsStartingFromNoCase( Str, Pattern: PChar ): Boolean;
  8532. {* Like StrIsStartingFrom above, but without case sensitivity. }
  8533. function TrimLeft(const S: string): string;
  8534. {* Removes spaces, tabulations and control characters from the starting
  8535. of string S. }
  8536. function TrimRight(const S: string): string;
  8537. {* Removes spaces, tabulates and other control characters from the
  8538. end of string S. }
  8539. function Trim( const S : string): string;
  8540. {* Makes TrimLeft and TrimRight for given string. }
  8541. function RemoveSpaces( const S: String ): String;
  8542. {* Removes all characters less or equal to ' ' in S and returns it. }
  8543. procedure Str2LowerCase( S: PChar );
  8544. {* Converts null-terminated string to lowercase (inplace). }
  8545. function LowerCase(const S: string): string;
  8546. {* Obvious. }
  8547. function UpperCase(const S: string): string;
  8548. {* Obvious. }
  8549. function AnsiUpperCase(const S: string): string;
  8550. {* Obvious. }
  8551. function AnsiLowerCase(const S: string): string;
  8552. {* Obvious. }
  8553. {$IFNDEF _D2}
  8554. {$IFNDEF _FPC}
  8555. function WAnsiUpperCase(const S: WideString): WideString;
  8556. {* Obvious. }
  8557. function WAnsiLowerCase(const S: WideString): WideString;
  8558. {* Obvious. }
  8559. {$ENDIF _FPC}
  8560. {$ENDIF _D2}
  8561. function AnsiCompareStr(const S1, S2: string): Integer;
  8562. {* AnsiCompareStr compares S1 to S2, with case-sensitivity. The compare
  8563. operation is controlled by the current Windows locale. The return value
  8564. is the same as for CompareStr. }
  8565. function _AnsiCompareStr(S1, S2: PChar): Integer;
  8566. {* The same, but for PChar ANSI strings }
  8567. function AnsiCompareStrNoCase(const S1, S2: string): Integer;
  8568. {* AnsiCompareStr compares S1 to S2, with case-sensitivity. The compare
  8569. operation is controlled by the current Windows locale. The return value
  8570. is the same as for CompareStr. }
  8571. function _AnsiCompareStrNoCase(S1, S2: PChar): Integer;
  8572. {* The same, but for PChar ANSI strings }
  8573. function AnsiCompareText( const S1, S2: String ): Integer;
  8574. {* }
  8575. {$IFNDEF _FPC}
  8576. function LStrFromPWCharLen(Source: PWideChar; Length: Integer): String;
  8577. {* from Delphi5 - because D2 does not contain it. }
  8578. function LStrFromPWChar(Source: PWideChar): String;
  8579. {* from Delphi5 - because D2 does not contain it. }
  8580. {$ENDIF _FPC}
  8581. function CopyEnd( const S : String; Idx : Integer ) : String;
  8582. {* Returns copy of source string S starting from Idx up to the end of
  8583. string S. Works correctly for case, when Idx > Length( S ) (returns
  8584. empty string for such case). }
  8585. function CopyTail( const S : String; Len : Integer ) : String;
  8586. {* Returns last Len characters of the source string. If Len > Length( S ),
  8587. entire string S is returned. }
  8588. procedure DeleteTail( var S : String; Len : Integer );
  8589. {* Deletes last Len characters from string. }
  8590. function IndexOfChar( const S : String; Chr : Char ) : Integer;
  8591. {* Returns index of given character (1..Length(S)), or
  8592. -1 if a character not found. }
  8593. function IndexOfCharsMin( const S, Chars : String ) : Integer;
  8594. {* Returns index (in string S) of those character, what is taking place
  8595. in Chars string and located nearest to start of S. If no such
  8596. characters in string S found, -1 is returned. }
  8597. {$IFNDEF _D2}
  8598. {$IFNDEF _FPC}
  8599. function IndexOfWideCharsMin( const S, Chars : WideString ) : Integer;
  8600. {* Returns index (in wide string S) of those wide character, what
  8601. is taking place in Chars wide string and located nearest to start of S.
  8602. If no such characters in string S found, -1 is returned. }
  8603. {$ENDIF _FPC}
  8604. {$ENDIF _D2}
  8605. function IndexOfStr( const S, Sub : String ) : Integer;
  8606. {* Returns index of given substring in source string S. If found,
  8607. 1..Length(S)-Length(Sub), if not found, -1. }
  8608. function Parse( var S : String; const Separators : String ) : String;
  8609. {* Returns first characters of string S, separated from others by
  8610. one of characters, taking place in Separators string, assigning
  8611. a tail of string (after found separator) to source string. If
  8612. no separator characters found, source string S is returned, and
  8613. source string itself becomes empty. }
  8614. {$IFNDEF _FPC}
  8615. {$IFNDEF _D2}
  8616. function WParse( var S : WideString; const Separators : WideString ) : WideString;
  8617. {* Returns first wide characters of wide string S, separated from others
  8618. by one of wide characters, taking place in Separators wide string,
  8619. assigning a tail of wide string (following found separator) to the
  8620. source one. If there are no separator characters found, source wide
  8621. string S is returned, and source wide string itself becomes empty. }
  8622. {$ENDIF _D2}
  8623. {$ENDIF _FPC}
  8624. function ParsePascalString( var S : String; const Separators : String ) : String;
  8625. {* Returns first characters of string S, separated from others by
  8626. one of characters, taking place in Separators string, assigning
  8627. a tail of string (after the found separator) to source string. If
  8628. there are no separator characters found, the source string S is returned,
  8629. and the source string itself becomes empty. Additionally: if the first (after
  8630. a blank space) is the quote "'" or '#', pascal string is assumung first
  8631. and is converted to usual string (without quotas) before analizing
  8632. of other separators. }
  8633. function String2PascalStrExpr( const S : String ) : String;
  8634. {* Converts string to Pascal-like string expression (concatenation of
  8635. strings with quotas and characters with leading '#'). }
  8636. function StrEq( const S1, S2 : String ) : Boolean;
  8637. {* Returns True, if LowerCase(S1) = LowerCase(S2). I.e., if strings
  8638. are equal to each other without caring of characters case sensitivity
  8639. (ASCII only). }
  8640. function AnsiEq( const S1, S2 : String ) : Boolean;
  8641. {* Returns True, if AnsiLowerCase(S1) = AnsiLowerCase(S2). I.e., if ANSI
  8642. stringsare equal to each other without caring of characters case
  8643. sensitivity. }
  8644. {$IFNDEF _D2}
  8645. {$IFNDEF _FPC}
  8646. function WAnsiEq( const S1, S2 : WideString ) : Boolean;
  8647. {* Returns True, if AnsiLowerCase(S1) = AnsiLowerCase(S2). I.e., if ANSI
  8648. stringsare equal to each other without caring of characters case
  8649. sensitivity. }
  8650. {$ENDIF _FPC}
  8651. {$ENDIF _D2}
  8652. function StrIn( const S : String; const A : array of String ) : Boolean;
  8653. {* Returns True, if S is "equal" to one of strings, taking place
  8654. in A array. To check equality, StrEq function is used, i.e.
  8655. comaprison is taking place without case sensitivity. }
  8656. {$IFNDEF _FPC}
  8657. {$IFNDEF _D2}
  8658. function WStrIn( const S : WideString; const A : array of WideString ) : Boolean;
  8659. {* Returns True, if S is "equal" to one of strings, taking place
  8660. in A array. To check equality, WAnsiEq function is used, i.e.
  8661. comaprison is taking place without case sensitivity. }
  8662. {$ENDIF _D2}
  8663. {$ENDIF _FPC}
  8664. function StrIs( const S : String; const A : array of String; var Idx: Integer ) : Boolean;
  8665. {* Returns True, if S is "equal" to one of strings, taking place
  8666. in A array, and in such Case Idx also is assigned to an index of A element
  8667. equal to S. To check equality, StrEq function is used, i.e.
  8668. comaprison is taking place without case sensitivity. }
  8669. function IntIn( Value: Integer; const List: array of Integer ): Boolean;
  8670. {* Returns TRUE, if Value is found in a List. }
  8671. function _StrSatisfy( S, Mask : PChar ) : Boolean;
  8672. {* }
  8673. function _2StrSatisfy( S, Mask: PChar ): Boolean;
  8674. {* }
  8675. function StrSatisfy( const S, Mask : String ) : Boolean;
  8676. {* Returns True, if S is satisfying to a given Mask (which can contain
  8677. wildcard symbols '*' and '?' interpeted correspondently as 'any
  8678. set of characters' and 'single any character'. If there are no
  8679. such wildcard symbols in a Mask, result is True only if S is maching
  8680. to Mask string.) }
  8681. function StrReplace( var S: String; const From, ReplTo: String ): Boolean;
  8682. {* Replaces first occurance of From to ReplTo in S, returns True,
  8683. if pattern From was found and replaced. }
  8684. {$IFNDEF _FPC}
  8685. {$IFNDEF _D2}
  8686. function WStrReplace( var S: WideString; const From, ReplTo: WideString ): Boolean;
  8687. {* Replaces first occurance of From to ReplTo in S, returns True,
  8688. if pattern From was found and replaced. See also function StrReplace.
  8689. This function is not available in Delphi2 (this version of Delphi
  8690. does not support WideString type). }
  8691. {$ENDIF _D2}
  8692. {$ENDIF _FPC}
  8693. function StrRepeat( const S: String; Count: Integer ): String;
  8694. {* Repeats given string Count times. E.g., StrRepeat( 'A', 5 ) gives 'AAAAA'. }
  8695. {$IFNDEF _FPC}
  8696. {$IFNDEF _D2}
  8697. function WStrRepeat( const S: WideString; Count: Integer ): WideString;
  8698. {* Repeats given wide string Count times. E.g., StrRepeat( 'A', 5 ) gives 'AAAAA'. }
  8699. {$ENDIF _D2}
  8700. {$ENDIF _FPC}
  8701. procedure NormalizeUnixText( var S: String );
  8702. {* In the string S, replaces all occurances of character #10 (without leading #13)
  8703. to the character #13. }
  8704. function StrPCopy(Dest: PChar; const Source: string): PChar;
  8705. {* Copyes Pascal-style string into null-terminaed one. }
  8706. function StrLCopy(Dest: PChar; const Source: PChar; MaxLen: Cardinal): PChar;
  8707. {* Copyes first MaxLen characters of Pascal-style string into
  8708. null-terminated one. }
  8709. function DelimiterLast( const Str, Delimiters: String ): Integer;
  8710. {* Returns index of the last of delimiters given by same named parameter
  8711. among characters of Str. If there are no delimiters found, length of
  8712. Str is returned. This function is intended mainly to use in filename
  8713. parsing functions. }
  8714. function __DelimiterLast( Str, Delimiters: PChar ): PChar;
  8715. {* Returns address of the last of delimiters given by Delimiters parameter
  8716. among characters of Str. If there are no delimeters found, position of
  8717. the null terminator in Str is returned. This function is intended
  8718. mainly to use in filename parsing functions. }
  8719. function SkipSpaces( P: PChar ): PChar;
  8720. {* Skips all characters #1..' ' in a string.
  8721. }
  8722. {$IFDEF F_P}
  8723. function DummyStrFun( const S: String ): String;
  8724. {$ENDIF}
  8725. //[Memory FUNCTIONS DECLARATIONS]
  8726. function CompareMem(P1, P2: Pointer; Length: Integer): Boolean;
  8727. {* Fast compare of two memory blocks. }
  8728. function AllocMem( Size : Integer ) : Pointer;
  8729. {* Allocates global memory and unlocks it. }
  8730. procedure DisposeMem( var Addr : Pointer );
  8731. {* Locks global memory block given by pointer, and frees it.
  8732. Does nothing, if the pointer is nil.
  8733. |<hr>
  8734. <R Text in clipboard operations>
  8735. }
  8736. //[clipboard FUNCTIONS DECLARATIONS]
  8737. function Clipboard2Text: String;
  8738. {* If clipboard contains text, this function returns it for You. }
  8739. {$IFNDEF _FPC}
  8740. {$IFNDEF _D2}
  8741. function Clipboard2WText: WideString;
  8742. {* If clipboard contains text, this function returns it for You (as Unicode string). }
  8743. {$ENDIF _D2}
  8744. {$ENDIF _FPC}
  8745. function Text2Clipboard( const S: String ): Boolean;
  8746. {* Puts given string to a clipboard. }
  8747. {$IFNDEF _FPC}
  8748. {$IFNDEF _D2}
  8749. function WText2Clipboard( const WS: WideString ): Boolean;
  8750. {* Puts given Unicode string to a clipboard.
  8751. |<hr>
  8752. }
  8753. {$ENDIF _D2}
  8754. {$ENDIF _FPC}
  8755. //[Mnemonics FUNCTIONS DECLARATIONS]
  8756. var SearchMnemonics: function ( const S: String ): String
  8757. = {$IFDEF F_P} DummyStrFun {$ELSE} UpperCase {$ENDIF};
  8758. MnemonicsLocale: Integer;
  8759. procedure SupportAnsiMnemonics( LocaleID: Integer );
  8760. {* Provides encoding to work with given locale. Call this global function to
  8761. extend TControl.SupportMnemonics capability (also should be called for a form
  8762. or for Applet variable).
  8763. <R Date and time handling>
  8764. }
  8765. //[TDateTime TYPE DEFINITION]
  8766. type
  8767. //TDateTime = Double; // well, it is already defined so in System.pas
  8768. {* Basic date and time type. Integer part represents year and days (as is,
  8769. i.e. 1-Jan-2000 is representing by value 730141, which is a number of
  8770. days from 1-Jan-0001 to 1-Jan-2000 inclusively). Fractional part is
  8771. representing hours, minutes, seconds and milliseconds of a day
  8772. proportionally (like in VCL TDateTime type, e.g. 0.5 = 12:00, 0.25 = 6:00,
  8773. etc.). }
  8774. PDayTable = ^TDayTable;
  8775. TDayTable = array[1..12] of Word;
  8776. TDateFormat = ( dfShortDate, dfLongDate );
  8777. {* Date formats available to use in formatting date/time to string. }
  8778. TTimeFormatFlag = ( tffNoMinutes, tffNoSeconds, tffNoMarker, tffForce24 );
  8779. {* Additional flags, used for formatting time. }
  8780. TTimeFormatFlags = Set of TTimeFormatFlag;
  8781. {* Set of flags, used for formatting time. }
  8782. const
  8783. MonthDays: array [Boolean] of TDayTable =
  8784. ((31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31),
  8785. (31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31));
  8786. {* The MonthDays array can be used to quickly find the number of
  8787. days in a month: MonthDays[IsLeapYear(Y), M]. }
  8788. SecsPerDay = 24 * 60 * 60;
  8789. {* Seconds per day. }
  8790. MSecsPerDay = SecsPerDay * 1000;
  8791. {* Milliseconds per day. }
  8792. VCLDate0 = 693594;
  8793. {* Value to convert VCL "date 0" to KOL "date 0" and back.
  8794. This value corresponds to 30-Dec-1899, 0:00:00. So,
  8795. to convert VCL date to KOL date, just subtract this
  8796. value from VCL date. And to convert back from KOL date
  8797. to VCL date, add this value to KOL date.}
  8798. {++}(*
  8799. procedure GetLocalTime(var lpSystemTime: TSystemTime); stdcall;
  8800. procedure GetSystemTime(var lpSystemTime: TSystemTime); stdcall;
  8801. *){--}
  8802. //[Date&Time FUNCTIONS DECLARATIONS]
  8803. function Now : TDateTime;
  8804. {* Returns local date and time on running PC. }
  8805. function Date: TDateTime;
  8806. {* Returns todaylocal date. }
  8807. procedure DecodeDateFully( DateTime: TDateTime; var Year, Month, Day, DayOfWeek: WORD );
  8808. {* Decodes date. }
  8809. procedure DecodeDate( DateTime: TDateTime; var Year, Month, Day: WORD );
  8810. {* Decodes date. }
  8811. function EncodeDate( Year, Month, Day: WORD; var DateTime: TDateTime ): Boolean;
  8812. {* Encodes date. }
  8813. function CompareSystemTime(const D1, D2 : TSystemTime) : Integer;
  8814. {* Compares to TSystemTime records. Returns -1, 0, or 1 if, correspondantly,
  8815. D1 < D2, D1 = D2 and D1 > D2. }
  8816. procedure IncDays( var SystemTime : TSystemTime; DaysNum : Integer );
  8817. {* Increases/decreases day in TSystemTime record onto given days count
  8818. (can be negative). }
  8819. procedure IncMonths( var SystemTime : TSystemTime; MonthsNum : Integer );
  8820. {* Increases/decreases month number in TSystemTime record onto given
  8821. months count (can be negative). Correct result is not garantee if
  8822. day number is incorrect for newly obtained month. }
  8823. function IsLeapYear(Year: Word): Boolean;
  8824. {* Returns True, if given year is "leap" (i.e. has 29 days in the February). }
  8825. function DayOfWeek(Date: TDateTime): Integer;
  8826. {* Returns day of week (0..6) for given date. }
  8827. function SystemTime2DateTime(const SystemTime : TSystemTime; var DateTime : TDateTime ) : Boolean;
  8828. {* Converts TSystemTime record to XDateTime variable. }
  8829. function DateTime2SystemTime(const DateTime : TDateTime; var SystemTime : TSystemTime ) : Boolean;
  8830. {* Converts TDateTime variable to TSystemTime record. }
  8831. function DateTime_System2Local( DTSys: TDateTime ): TDateTime;
  8832. {* Converts DTSys representing system time (+0 Grinvich) to local time. }
  8833. function DateTime_Local2System( DTLoc: TDateTime ): TDateTime;
  8834. {* Converts DTLoc representing local time to system time (+0 Grinvich) }
  8835. function CatholicEaster( nYear: Integer ): TDateTime;
  8836. {* Returns date of catholic easter for given year. }
  8837. procedure DivMod(Dividend: Integer; Divisor: Word; var Result, Remainder: Word);
  8838. {* Dividing of integer onto divisor with obtaining both result of division
  8839. and remainder. }
  8840. function SystemDate2Str( const SystemTime : TSystemTime; const LocaleID : DWORD;
  8841. const DfltDateFormat : TDateFormat; const DateFormat : PChar ) : String;
  8842. {* Formats date, stored in TSystemTime record into string, using given locale
  8843. and date/time formatting flags. (E.g.: GetUserDefaultLangID). }
  8844. function SystemTime2Str( const SystemTime : TSystemTime; const LocaleID : DWORD;
  8845. const Flags : TTimeFormatFlags; const TimeFormat : PChar ) : String;
  8846. {* Formats time, stored in TSystemTime record into string, using given locale
  8847. and date/time formatting flags. }
  8848. function Date2StrFmt( const Fmt: String; D: TDateTime ): String;
  8849. {* Represents date as a string correspondently to Fmt formatting string.
  8850. See possible pictures in definition of the function Str2DateTimeFmt
  8851. (the first part). If Fmt string is empty, default system date format
  8852. for short date string used. }
  8853. function Time2StrFmt( const Fmt: String; D: TDateTime ): String;
  8854. {* Represents time as a string correspondently to Fmt formatting string.
  8855. See possible pictures in definition of the function Str2DateTimeFmt
  8856. (the second part). If Fmt string is empty, default system time format
  8857. for short date string used. }
  8858. function DateTime2StrShort( D: TDateTime ): String;
  8859. {* Formats date and time to string in short date format using current user
  8860. locale. }
  8861. function Str2DateTimeFmt( const sFmtStr, sS: String ): TDateTime;
  8862. {* Restores date or/and time from string correspondently to a format string.
  8863. Date and time formatting string can contain following pictures (case
  8864. sensitive):
  8865. |<pre>
  8866. DATE PICTURES
  8867. d Day of the month as digits without leading zeros for single digit days.
  8868. dd Day of the month as digits with leading zeros for single digit days
  8869. ddd Day of the week as a 3-letter abbreviation as specified by a
  8870. LOCALE_SABBREVDAYNAME value.
  8871. dddd Day of the week as specified by a LOCALE_SDAYNAME value.
  8872. M Month as digits without leading zeros for single digit months.
  8873. MM Month as digits with leading zeros for single digit months
  8874. MMM Month as a three letter abbreviation as specified by a LOCALE_SABBREVMONTHNAME value.
  8875. MMMM Month as specified by a LOCALE_SMONTHNAME value.
  8876. y Year represented only be the last digit.
  8877. yy Year represented only be the last two digits.
  8878. yyyy Year represented by the full 4 digits.
  8879. gg Period/era string as specified by the CAL_SERASTRING value. The gg
  8880. format picture in a date string is ignored if there is no associated era
  8881. string. In Enlish locales, usual values are BC or AD.
  8882. TIME PICTURES
  8883. h Hours without leading zeros for single-digit hours (12-hour clock).
  8884. hh Hours with leading zeros for single-digit hours (12-hour clock).
  8885. H Hours without leading zeros for single-digit hours (24-hour clock).
  8886. HH Hours with leading zeros for single-digit hours (24-hour clock).
  8887. m Minutes without leading zeros for single-digit minutes.
  8888. mm Minutes with leading zeros for single-digit minutes.
  8889. s Seconds without leading zeros for single-digit seconds.
  8890. ss Seconds with leading zeros for single-digit seconds.
  8891. t One charactertime marker string (usually P or A, in English locales).
  8892. tt Multicharactertime marker string (usually PM or AM, in English locales).
  8893. |</pre>
  8894. E.g., 'D, yyyy/MM/dd h:mm:ss'.
  8895. See also Str2DateTimeShort function.
  8896. }
  8897. function Str2DateTimeShort( const S: String ): TDateTime;
  8898. {* Restores date and time from string correspondently to current user locale. }
  8899. function Str2DateTimeShortEx( const S: String ): TDateTime;
  8900. {* Like Str2DateTimeShort above, but uses locale defined date and time
  8901. separators to avoid recognizing time as a date in some cases.
  8902. |<hr>
  8903. <R File and directory routines>
  8904. }
  8905. //[OpenFile CONSTANTS]
  8906. const
  8907. ofOpenRead = $80000000;
  8908. {* Use this flag (in combination with others) to open file for "read" only. }
  8909. ofOpenWrite = $40000000;
  8910. {* Use this flag (in combination with others) to open file for "write" only. }
  8911. ofOpenReadWrite = $C0000000;
  8912. {* Use this flag (in combination with others) to open file for "read" and "write". }
  8913. ofShareExclusive = $00;
  8914. {* Use this flag (in combination with others) to open file for exclusive use. }
  8915. ofShareDenyWrite = $01;
  8916. {* Use this flag (in combination with others) to open file in share mode, when
  8917. only attempts to open it in other process for "write" will be impossible.
  8918. I.e., other processes could open this file simultaneously for read only
  8919. access. }
  8920. ofShareDenyRead = $02;
  8921. {* Use this flag (in combination with others) to open file in share mode, when
  8922. only attempts to open it for "read" in other processes will be disabled.
  8923. I.e., other processes could open it for "write" only access. }
  8924. ofShareDenyNone = $03;
  8925. {* Use this flag (in combination with others) to open file in full sharing mode.
  8926. I.e. any process will be able open this file using the same share flag. }
  8927. ofCreateNew = $100;
  8928. {* Default creation disposition. Use this flag for creating new file (usually
  8929. for write access. }
  8930. ofCreateAlways = $200;
  8931. {* Use this flag (in combination with others) to open existing or creating new
  8932. file. If existing file is opened, it is truncated to size 0. }
  8933. ofOpenExisting = $300;
  8934. {* Use this flag (in combination with others) to open existing file only. }
  8935. ofOpenAlways = $400;
  8936. {* Use this flag (in combination with others) to open existing or create new
  8937. (if such file is not yet exists). }
  8938. ofTruncateExisting = $500;
  8939. {* Use this flag (in combination with others) to open existing file and truncate
  8940. it to size 0. }
  8941. ofAttrReadOnly = $10000;
  8942. {* Use this flag to create Read-Only file (?). }
  8943. ofAttrHidden = $20000;
  8944. {* Use this flag to create hidden file. }
  8945. ofAttrSystem = $40000;
  8946. {* Use this flag to create system file. }
  8947. ofAttrTemp = $1000000;
  8948. {* Use this flag to create temp file. }
  8949. ofAttrArchive = $200000;
  8950. {* Use this flag to create archive file. }
  8951. ofAttrCompressed = $8000000;
  8952. {* Use this flag to create compressed file. Has effect only on NTFS, and
  8953. only if ofAttrCompressed is not specified also. }
  8954. ofAttrOffline = $10000000;
  8955. {* Use this flag to create offline file. }
  8956. //[END OF OpenFileConstants]
  8957. //[File FUNCTIONS DECLARATIONS]
  8958. function FileCreate(const FileName: string; OpenFlags: DWord): THandle;
  8959. {* Call this function to open existing or create new file. OpenFlags
  8960. parameter can be a combination of up to three flags (by one from
  8961. each group:
  8962. |<table border=0>
  8963. |&L=<tr><td valign=top>%0</td><td valign=top>
  8964. |&E=</td></tr>
  8965. <L ofOpenRead, ofOpenWrite, ofOpenReadWrite> - 1st group. Here You decide
  8966. wish You open file for read, write or read-and-write operations; <E>
  8967. <L ofShareExclusive, ofShareDenyWrite, ofShareDenyRead, ofShareDenyNone> -2nd
  8968. group - sharing. Here You can mark out sharing mode, which is used to
  8969. open file. <E>
  8970. <L ofCreateNew, ofCreateAlways, ofOpenExisting, ofOpenAlways, ofTruncateExisting>
  8971. - 3rd group - creation disposition. Here You determine, either to create new
  8972. or open existing file and if to truncate existing or not.
  8973. |</table> }
  8974. function FileClose(Handle: THandle): Boolean;
  8975. {* Call it to close opened earlier file. }
  8976. function FileExists( const FileName: String ) : Boolean;
  8977. {* Returns True, if given file exists.
  8978. |<br>Note (by Dod):
  8979. It is not documented in a help for GetFileAttributes, but it seems that
  8980. under NT-based Windows systems, FALSE is always returned for files
  8981. opened for excluseve use like pagefile.sys. }
  8982. function FileRead(Handle: THandle; var Buffer; Count: DWord): DWord;
  8983. {* Reads bytes from current position in file to buffer. Returns number of
  8984. read bytes. }
  8985. function File2Str(Handle: THandle): String;
  8986. {* Reads file from current position to the end and returns result as ansi string. }
  8987. function FileSeek(Handle: THandle; MoveTo: integer; MoveMethod: TMoveMethod): DWord;
  8988. {* Changes current position in file. }
  8989. function FileWrite(Handle: THandle; const Buffer; Count: DWord): DWord;
  8990. {* Writes bytes from buffer to file from current position, extending its
  8991. size if needed. }
  8992. function FileEOF( Handle: THandle ) : Boolean;
  8993. {* Returns True, if EOF is achieved during read operations or last byte is
  8994. overwritten or append made to extend file during last write operation. }
  8995. function FileFullPath( const FileName : String ) : String;
  8996. {* Returns full path name for given file. Validness of source FileName path
  8997. is not checked at all. }
  8998. function FileShortPath( const FileName: String ): String;
  8999. {* Returns short path to the file or directory. }
  9000. function FileIconSystemIdx( const Path: String ): Integer;
  9001. {* Returns index of the index of the system icon correspondent to the file or
  9002. directory in system icon image list. }
  9003. function FileIconSysIdxOffline( const Path: String ): Integer;
  9004. {* The same as FileIconSystemIdx, but an icon is calculated for the file
  9005. as it were offline (it is possible to get an icon for file even if
  9006. it is not existing, on base of its extension only). }
  9007. procedure LogFileOutput( const filepath, str: String );
  9008. {* Debug function. Use it to append given string to the end of the given file. }
  9009. function StrSaveToFile( const Filename, Str: String ): Boolean;
  9010. {* Saves a string to a file without any changes. If file does not exists, it is
  9011. created. If it exists, it is overriden. If operation failed, FALSE is returned. }
  9012. function StrLoadFromFile( const Filename: String ): String;
  9013. {* Reads entire file and returns its content as a string. If operation failed,
  9014. an empty strinng is returned.
  9015. |<br>by Sergey Shishmintzev: it is possible to pass Filename = 'CON' to
  9016. read input from redirected console output. }
  9017. function Mem2File( Filename: PChar; Mem: Pointer; Len: Integer ): Integer;
  9018. {* Saves memory block to a file (if file exists it is overriden, created new if
  9019. not exists). }
  9020. function File2Mem( Filename: PChar; Mem: Pointer; MaxLen: Integer ): Integer;
  9021. {* Loads file content to memory. }
  9022. function FileSize( const Path: String ) : Integer;
  9023. {* Returns file size in bytes without opening it. If file too large
  9024. to represent its size as Integer, -1 is returned. }
  9025. function GetUniqueFilename( PathName: string ) : String;
  9026. {* If file given by PathName exists, modifies it to create unique
  9027. filename in target folder and returns it. Modification is performed
  9028. by incrementing last number in name (if name part of file does not
  9029. represent a number, such number is generated and concatenated to
  9030. it). E.g., if file aaa.aaa is already exist, the function checks
  9031. names aaa1.aaa, aaa2.aaa, ..., aaa10.aaa, etc. For name abc123.ext,
  9032. names abc124.ext, abc125.ext, etc. will be checked. }
  9033. function FileTimeCompare( const FT1, FT2 : TFileTime ) : Integer;
  9034. {* Compares time of file (createing, writing, accessing. Returns
  9035. -1, 0, 1 if correspondantly FT1<FT2, FT1=FT2, FT1>FT2. }
  9036. //[Directory FUNCTIONS DECLARATIONS]
  9037. function GetStartDir: String;
  9038. {* Returns path to directory where executable is located (regardless
  9039. of current directory). }
  9040. function DirectoryExists(const Name: string): Boolean;
  9041. {* Returns True if given directory (folder) exists. }
  9042. function DirectoryEmpty(const Name: String): Boolean;
  9043. {* Returns True if given directory is not exists or empty. }
  9044. {
  9045. function DirectorySize( const Path: String ): I64;
  9046. -- moved after PDirList
  9047. }
  9048. function DirectoryHasSubdirs( const Path: String ): Boolean;
  9049. {* Returns TRUE if given directory exists and has subdirectories. }
  9050. function CheckDirectoryContent( const Name: String; SubDirsOnly: Boolean; const Mask: String ): Boolean;
  9051. {* Returns TRUE if directory does not contain files (or directories only)
  9052. satisfying given mask. }
  9053. //---------------------------------------------------------
  9054. // Following functions/procedures are created by Edward Aretino:
  9055. // IncludeTrailingPathDelimiter, ExcludeTrailingPathDelimiter,
  9056. // ForceDirectories, CreateDir, ChangeFileExt
  9057. //---------------------------------------------------------
  9058. function IncludeTrailingPathDelimiter(const S: string): string;
  9059. {* by Edward Aretino. Adds '\' to the end if it is not present. }
  9060. function ExcludeTrailingPathDelimiter(const S: string): string;
  9061. {* by Edward Aretino. Removes '\' at the end if it is present. }
  9062. function ForceDirectories(Dir: String): Boolean;
  9063. {* by Edward Aretino. Creates given directory if not present. All needed
  9064. subdirectories are created if necessary. }
  9065. function CreateDir(const Dir: string): Boolean;
  9066. {* by Edward Aretino. Creates given directory. }
  9067. function ChangeFileExt(FileName: String; const Extension: string): string;
  9068. {* by Edward Aretino. Changes file extention. }
  9069. function ExcludeTrailingChar( const S: String; C: Char ): String;
  9070. {* If S is finished with character C, it is excluded. }
  9071. function IncludeTrailingChar( const S: String; C: Char ): String;
  9072. {* If S is not finished with character C, it is added. }
  9073. function ExtractFilePath( const Path: String ) : String;
  9074. {* Returns only path part from exact path to file. }
  9075. function ExtractFileName( const Path: String ) : String;
  9076. {* Extracts file name from exact path to file. }
  9077. function ExtractFileNameWOext( const Path: String ) : String;
  9078. {* Extracts file name from path to file or from filename. }
  9079. function ExtractFileExt( const Path: String ) : String;
  9080. {* Extracts extention from file name (returns it with dot '.' first) }
  9081. function ReplaceFileExt( const Path, NewExt: String ): String;
  9082. {* Returns a path with extension replaced to a given one. }
  9083. function ExtractShortPathName( const Path: String ): String;
  9084. {* }
  9085. function FilePathShortened( const Path: String; MaxLen: Integer ): String;
  9086. {* Returns shortened file path to fit MaxLen characters. }
  9087. function FilePathShortenPixels( const Path: String; DC: HDC; MaxPixels: Integer ): String;
  9088. {* Returns shortened file path to fit MaxPixels for a given DC. If you pass
  9089. Canvas.Handle of any control or bitmap object, ensure that font is valid
  9090. for it (or call TCanvas.RequiredState( FontValid ) method before. If DC passed
  9091. = 0, call is equivalent to call FilePathShortened, and MaxPixels means in such
  9092. case maximum number of characters. }
  9093. function MinimizeName( const Path: String; DC: HDC; MaxPixels: Integer ): String;
  9094. {* Exactly the same as MinimizeName in FileCtrl.pas (VCL). }
  9095. function GetSystemDir: String;
  9096. {* Returns path to windows system directory. }
  9097. function GetWindowsDir : string;
  9098. {* Returns path to Windows directory. }
  9099. function GetWorkDir : string;
  9100. {* Returns path to application's working directory. }
  9101. function GetTempDir : string;
  9102. {* Returns path to default temp folder (directory to place temporary files). }
  9103. function CreateTempFile( const DirPath, Prefix: String ): String;
  9104. {* Returns path to just created temporary file. }
  9105. function GetFileListStr(FPath{e.g.'c:\tmp\'}, FMask{e.g.'*.*'}: string): string;
  9106. {* List of files in string, separating each path from others with semicolon (';').
  9107. E.g.: 'c:\tmp\unit1.dcu;c:\tmp\unit1.~pa' (for use with DeleteFile2Recycle())}
  9108. function DeleteFiles( const DirPath: String ): Boolean;
  9109. {* Deletes files by file mask (given with wildcards '*' and '?'). }
  9110. function DeleteFile2Recycle( const Filename : String ) : Boolean;
  9111. {* Deletes file to recycle bin. This operation can be very slow, when
  9112. called for a single file. To delete group of files at once (fast),
  9113. pass a list of paths to files to be deleted, separating each path
  9114. from others with semicolon (';'). E.g.: 'unit1.dcu;unit1.~pa'
  9115. |<br>
  9116. FALSE is returned only in case when at least one file was not deleted
  9117. successfully.
  9118. |<br>
  9119. Note, that files are deleted not to recycle bin, if wildcards are
  9120. used or not fully qualified paths to files. }
  9121. function CopyMoveFiles( const FromList, ToList: String; Move: Boolean ): Boolean;
  9122. {* }
  9123. {-}
  9124. function DiskFreeSpace( const Path: String ): I64; {+}
  9125. {* Returns disk free space in bytes. Pass a path to root directory,
  9126. e.g. 'C:\'.
  9127. |<hr>
  9128. <R Wrappers to registry API functions>
  9129. These functions can be used independently to simplify access to Windows
  9130. registry. }
  9131. //[Registry FUNCTIONS DECLARATIONS]
  9132. {++}(*
  9133. function RegSetValueEx(hKey: HKEY; lpValueName: PChar;
  9134. Reserved: DWORD; dwType: DWORD; lpData: Pointer; cbData: DWORD): Longint; stdcall;
  9135. *){--}
  9136. function RegKeyOpenRead( Key: HKey; const SubKey: String ): HKey;
  9137. {* Opens registry key for read operations (including enumerating of subkeys).
  9138. Pass either handle of opened earlier key or one of constans
  9139. HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, HKEY_USERS
  9140. as a first parameter. If not successful, 0 is returned. }
  9141. function RegKeyOpenWrite( Key: HKey; const SubKey: String ): HKey;
  9142. {* Opens registry key for write operations (including adding new values or
  9143. subkeys), as well as for read operations too. See also RegKeyOpenRead. }
  9144. function RegKeyOpenCreate( Key: HKey; const SubKey: String ): HKey;
  9145. {* Creates and opens key. }
  9146. function RegKeyGetStr( Key: HKey; const ValueName: String ): String;
  9147. {* Reads key, which must have type REG_SZ (null-terminated string). If
  9148. not successful, empty string is returned. This function as well as all
  9149. other registry manipulation functions, does nothing, if Key passed is 0
  9150. (without producing any error). }
  9151. function RegKeyGetStrEx( Key: HKey; const ValueName: String ): String;
  9152. {* Like RegKeyGetStr, but accepts REG_EXPAND_SZ type, expanding all
  9153. environment variables in resulting string.
  9154. |<br>
  9155. Code provided by neuron, e-mailto:neuron@hollowtube.mine.nu }
  9156. function RegKeyGetDw( Key: HKey; const ValueName: String ): DWORD;
  9157. {* Reads key value, which must have type REG_DWORD. If ValueName passed
  9158. is '' (empty string), unnamed (default) value is reading. If not
  9159. successful, 0 is returned. }
  9160. function RegKeySetStr(Key: HKey; const ValueName: String; const Value: String ): Boolean;
  9161. {* Writes new key value as null-terminated string (type REG_SZ). If not
  9162. successful, returns False. }
  9163. function RegKeySetStrEx( Key: HKey; const ValueName: string; const Value: string;
  9164. expand: boolean): Boolean;
  9165. {* Writes new key value as REG_SZ or REG_EXPAND_SZ. - by neuron, e-mailto:neuron@hollowtube.mine.nu }
  9166. function RegKeySetDw( Key: HKey; const ValueName: String; Value: DWORD ): Boolean;
  9167. {* Writes new key value as dword (with type REG_DWORD). Returns False,
  9168. if not successful. }
  9169. procedure RegKeyClose( Key: HKey );
  9170. {* Closes key, opened using RegKeyOpenRead or RegKeyOpenWrite. (But does
  9171. nothing, if Key passed is 0). }
  9172. function RegKeyDelete( Key: HKey; const SubKey: String ): Boolean;
  9173. {* Deletes key. Does nothing if key passed is 0 (returns FALSE). }
  9174. function RegKeyDeleteValue( Key: HKey; const SubKey: String ): Boolean;
  9175. {* Deletes value. - by neuron, e-mailto:neuron@hollowtube.mine.nu }
  9176. function RegKeyExists( Key: HKey; const SubKey: String ): Boolean;
  9177. {* Returns TRUE, if given subkey exists under given Key. }
  9178. function RegKeyValExists( Key: HKey; const ValueName: String ): Boolean;
  9179. {* Returns TRUE, if given value exists under the Key.
  9180. }
  9181. function RegKeyValueSize( Key: HKey; const ValueName: String ): Integer;
  9182. {* Returns a size of value. This is a size of buffer needed to store
  9183. registry key value. For string value, size returned is equal to a
  9184. length of string plus 1 for terminated null character. }
  9185. function RegKeyGetBinary( Key: HKey; const ValueName: String; var Buffer; Count: Integer ): Integer;
  9186. {* Reads binary data from a registry, writing it to the Buffer.
  9187. It is supposed that size of Buffer provided is at least Count bytes.
  9188. Returned value is actul count of bytes read from the registry and written
  9189. to the Buffer.
  9190. |<br>
  9191. This function can be used to get data of any type from the registry, not
  9192. only REG_BINARY. }
  9193. function RegKeySetBinary( Key: HKey; const ValueName: String; const Buffer; Count: Integer ): Boolean;
  9194. {* Stores binary data in the registry. }
  9195. function RegKeyGetDateTime(Key: HKey; const ValueName: String): TDateTime;
  9196. {* Returns datetime variable stored in registry in binary format. }
  9197. function RegKeySetDateTime(Key: HKey; const ValueName: String; DateTime: TDateTime): Boolean;
  9198. {* Stores DateTime variable in the registry. }
  9199. //-------------------------------------------------------
  9200. // registry functions by Valerian Luft <luft@valerian.de>
  9201. //-------------------------------------------------------
  9202. function RegKeyGetSubKeys( const Key: HKEY; List: PStrList): Boolean;
  9203. {* The function enumerates subkeys of the specified open registry key.
  9204. True is returned, if successful.
  9205. }
  9206. function RegKeyGetValueNames(const Key: HKEY; List: PStrList): Boolean;
  9207. {* The function enumerates value names of the specified open registry key.
  9208. True is returned, if successful.
  9209. }
  9210. function RegKeyGetValueTyp (const Key:HKEY; const ValueName: String) : DWORD;
  9211. {* The function receives the type of data stored in the specified value.
  9212. |<br>
  9213. If the function fails, the return value is the Key value.
  9214. |<br>
  9215. If the function succeeds, the return value return will be one of the following:
  9216. |<br>
  9217. REG_BINARY , REG_DWORD, REG_DWORD_LITTLE_ENDIAN,
  9218. REG_DWORD_BIG_ENDIAN, REG_EXPAND_SZ, REG_LINK , REG_MULTI_SZ,
  9219. REG_NONE, REG_RESOURCE_LIST, REG_SZ
  9220. |<hr>
  9221. <R Data sorting (quicksort implementation)>
  9222. This part contains implementation of 'quick sort' algorithm,
  9223. based on following code:
  9224. |<pre>
  9225. | TQSort by Mike Junkin 10/19/95.
  9226. | DoQSort routine adapted from Peter Szymiczek's QSort procedure which
  9227. | was presented in issue#8 of The Unofficial Delphi Newsletter.
  9228. | TQSort changed by Vladimir Kladov (Mr.Bonanzas) to allow 32-bit
  9229. | sorting (of big arrays with more than 64K elements).
  9230. |</pre>
  9231. Finally, this sort procedure is adapted to XCL (and then to KOL)
  9232. requirements (no references to SysUtils, Classes etc. TQSort object
  9233. is transferred to a single procedure call and DoQSort method is
  9234. renamed to SortData - which is a regular procedure now). }
  9235. //[Sorting TYPES]
  9236. type
  9237. TCompareEvent = function (const Data: Pointer; const e1,e2 : Dword) : Integer;
  9238. {* Event type to define comparison function between two elements of an array.
  9239. This event handler must return -1 or +1 (correspondently for cases e1<e2
  9240. and e2>e2). Items are enumerated from 0 to uNElem. }
  9241. TSwapEvent = procedure (const Data : Pointer; const e1,e2 : Dword);
  9242. {* Event type to define swap procedure which is swapping two elements of an
  9243. array. }
  9244. //[SortData FUNCTIONS DECLARATIONS]
  9245. procedure SortData( const Data: Pointer; const uNElem: Dword;
  9246. const CompareFun: TCompareEvent;
  9247. const SwapProc: TSwapEvent );
  9248. {* Call it to sort any array of data of any kind, passing total
  9249. number of items in an array and two defined (regular) function
  9250. and procedure to perform custom compare and swap operations.
  9251. First procedure parameter is to pass it to callback function
  9252. CompareFun and procedure SwapProc. Items are enumerated from
  9253. 0 to uNElem-1. }
  9254. procedure SortIntegerArray( var A : array of Integer );
  9255. {* procedure to sort array of integers. }
  9256. procedure SortDwordArray( var A : array of DWORD );
  9257. {* Procedure to sort array of unsigned 32-bit integers.
  9258. |<hr>
  9259. }
  9260. { -- directory list object -- }
  9261. //[DirList Object]
  9262. type
  9263. TDirItemAction = ( diSkip, diAccept, diCancel );
  9264. TOnDirItem = procedure( Sender: PObj; var DirItem: TWin32FindData; var Accept: TDirItemAction )
  9265. of object;
  9266. TSortDirRules = ( sdrNone, sdrFoldersFirst, sdrCaseSensitive, sdrByName, sdrByExt,
  9267. sdrBySize, sdrBySizeDescending, sdrByDateCreate, sdrByDateChanged,
  9268. sdrByDateAccessed );
  9269. {* List of rules (options) to sort directories. Rules are passed to Sort
  9270. method in an array, and first placed rules are applied first. }
  9271. {++}(*TDirList = class;*){--}
  9272. PDirList = {-}^{+}TDirList;
  9273. { ----------------------------------------------------------------------
  9274. TDirList - Directory scanning
  9275. ----------------------------------------------------------------------- }
  9276. //[TDirList DEFINITION]
  9277. TDirList = object( TObj )
  9278. {* Allows easy directory scanning. This is not visual object, but
  9279. storage to simplify working with directory content. }
  9280. protected
  9281. FList : PList;
  9282. FPath: string;
  9283. fFilters: PStrList;
  9284. fOnItem: TOnDirItem;
  9285. function Get(Idx: Integer): PWin32FindData;
  9286. function GetCount: Integer;
  9287. function GetNames(Idx: Integer): string;
  9288. function GetIsDirectory(Idx: Integer): Boolean;
  9289. protected
  9290. function SatisfyFilter( FileName : PChar; FileAttr, FindAttr : DWord ) : Boolean;
  9291. {++}(*public*){--}
  9292. destructor Destroy; {-}virtual;{+}{++}(*override;*){--}
  9293. {* Destructor. As usual, call Free method to destroy an object. }
  9294. public
  9295. property Items[ Idx : Integer ] : PWin32FindData read Get; default;
  9296. {* Full access to scanned items (files and subdirectories). }
  9297. property IsDirectory[ Idx: Integer ]: Boolean read GetIsDirectory;
  9298. {* Returns TRUE, if specified item represents a directory, not a file. }
  9299. property Count : Integer read GetCount;
  9300. {* Number of items. }
  9301. property Names[ Idx : Integer ] : string read GetNames;
  9302. {* Full long names of directory items. }
  9303. property Path : string read FPath;
  9304. {* Path of scanned directory. }
  9305. procedure Clear;
  9306. {* Call it to clear list of files. }
  9307. procedure ScanDirectory( const DirPath, Filter : String; Attr : DWord );
  9308. {* Call it to rescan directory or to scan another directory content
  9309. (method Clear is called first). Pass path to directory, file filter
  9310. and attributes to scan directory immediately.
  9311. |<br>&nbsp;&nbsp;&nbsp;
  9312. Note: Pass FILE_ATTRIBUTE_... constants or-combination as Attr
  9313. parameter. If 0 passed, both files and directories are listed. }
  9314. procedure ScanDirectoryEx( const DirPath, Filters : String; Attr : DWord );
  9315. {* Call it to rescan directory or to scan another directory content
  9316. (method Clear is called first). Pass path to directory, file filter
  9317. and attributes to scan directory immediately.
  9318. |<br>&nbsp;&nbsp;&nbsp;
  9319. Note: Pass FILE_ATTRIBUTE_... constants or-combination as Attr
  9320. parameter. }
  9321. procedure Sort( Rules : array of TSortDirRules );
  9322. {* Sorts directory entries. If empty rules array passed, default rules
  9323. array DefSortDirRules is used. }
  9324. function FileList( const Separator {e.g.: ';', or #13}: String;
  9325. Dirs, FullPaths: Boolean ): String;
  9326. {* Returns a string containing all names separated with Separator.
  9327. If Dirs=FALSE, only files are returned. }
  9328. property OnItem: TOnDirItem read fOnItem write fOnItem;
  9329. {* This event is called on reading each item while scanning directory.
  9330. To use it, first create PDirList object with empty path to scan, then
  9331. assign OnItem event and call ScanDirectory with correct path. }
  9332. end;
  9333. //[END OF TDirList DEFINITION]
  9334. //[NewDirList DECLARATIONS]
  9335. function NewDirList( const DirPath, Filter: String; Attr: DWORD ): PDirList;
  9336. {* Creates directory list object using easy one-string filter. If Attr = FILE_ATTRIBUTE_NORMAL,
  9337. only files are scanned without directories. If Attr = 0, both files and
  9338. directories are listed. }
  9339. function NewDirListEx( const DirPath, Filters: String; Attr: DWORD ): PDirList;
  9340. {* Creates directory list object using several filters, separated by ';'.
  9341. Filters starting from '^' consider to be anti-filters, i.e. files,
  9342. satisfying to those masks, are skept during scanning. }
  9343. const DefSortDirRules : array[ 0..3 ] of TSortDirRules = ( sdrFoldersFirst,
  9344. sdrByName, sdrBySize, sdrByDateCreate );
  9345. {* Default rules to sort directory entries. }
  9346. //[DirectorySize DECLARATION]
  9347. {-}
  9348. function DirectorySize( const Path: String ): I64;
  9349. {* Returns directory size in bytes as large 64 bit integer. }
  9350. {+}
  9351. //[OpenSaveDialog OPTIONS]
  9352. type
  9353. TOpenSaveOption = ( OSCreatePrompt,
  9354. OSExtensionDiffent,
  9355. OSFileMustExist,
  9356. OSHideReadonly,
  9357. OSNoChangedir,
  9358. OSNoReferenceLinks,
  9359. OSAllowMultiSelect,
  9360. OSNoNetworkButton,
  9361. OSNoReadonlyReturn,
  9362. OSOverwritePrompt,
  9363. OSPathMustExist,
  9364. OSReadonly,
  9365. OSNoValidate
  9366. //{$IFDEF OpenSaveDialog_Extended}
  9367. ,
  9368. OSTemplate,
  9369. OSHook
  9370. //{$ENDIF}
  9371. );
  9372. TOpenSaveOptions = set of TOpenSaveOption;
  9373. {* Options available for TOpenSaveDialog. }
  9374. {++}(*TOpenSaveDialog = class;*){--}
  9375. POpenSaveDialog = {-}^{+}TOpenSaveDialog;
  9376. { ----------------------------------------------------------------------
  9377. TOpenSaveDialog
  9378. ----------------------------------------------------------------------- }
  9379. //[TOpenSaveDialog DEFINITION]
  9380. TOpenSaveDialog = object( TObj )
  9381. {* Object to show standard Open/Save dialog. Initially provided
  9382. for XCL by Carlo Kok. }
  9383. protected
  9384. FFilter : String;
  9385. fFilterIndex : Integer;
  9386. fOpenDialog : Boolean;
  9387. FInitialDir : String;
  9388. FDefExtension : String;
  9389. FFilename : string;
  9390. FTitle : string;
  9391. FOptions : TOpenSaveOptions;
  9392. fWnd: THandle;
  9393. public
  9394. {$IFDEF OpenSaveDialog_Extended}
  9395. TemplateName: String;
  9396. HookProc: Pointer;
  9397. {$ENDIF}
  9398. destructor Destroy; {-}virtual;{+}{++}(*override;*){--}
  9399. {* destructor }
  9400. Function Execute : Boolean;
  9401. {* Call it after creating to perform selecting of file by user. }
  9402. property Filename : String read FFilename write FFileName;
  9403. {*
  9404. Filename is seperated by #13 when multiselect is true and the first
  9405. file, is the path of the files selected.
  9406. |<pre>
  9407. | C:\Projects
  9408. | Test1.Dpr
  9409. | Test2.Dpr
  9410. |</pre>
  9411. If only one file is selected, it is provided as (e.g.)
  9412. C:\Projects\Test1.dpr
  9413. |<br> For case when OSAllowMultiselect option used, after each
  9414. call initial value for a Filename containing several files prevents
  9415. system from opening the dialog. To fix this, assign another initial
  9416. value to Filename property in your code, when you use multiselect.
  9417. }
  9418. property InitialDir : string read FInitialDir write FInitialDir;
  9419. {* Initial directory path. If not set, current directory (usually
  9420. directory when program is started) is used. }
  9421. property Filter : String read FFilter write FFilter;
  9422. {* A list of pairs of filter names and filter masks, separated with '|'.
  9423. If a mask contains more than one mask, it should be separated with ';'.
  9424. E.g.:
  9425. ! 'All files|*.*|Text files|*.txt;*.1st;*.diz' }
  9426. property FilterIndex : Integer read FFilterIndex write FFilterIndex;
  9427. {* Index of default filter mask (0 by default, which means "first"). }
  9428. property OpenDialog : Boolean read FOpenDialog write FOpenDialog;
  9429. {* True, if "Open" dialog. False, if "Save" dialog. True is default. }
  9430. property Title : String read Ftitle write Ftitle;
  9431. {* Title for dialog. }
  9432. property Options : TOpenSaveOptions read FOptions write FOptions;
  9433. {* Options. }
  9434. property DefExtension : String read FDefExtension write FDefExtension;
  9435. {* Default extention. Set it to desired extension without leading period,
  9436. e.g. 'txt', but not '.txt'. }
  9437. property WndOwner: THandle read fWnd write fWnd;
  9438. {* Owner window handle. If not assigned, Applet.Handle is used (whenever
  9439. possible). Assign it, if your application has stay-on-top forms, and
  9440. a separate Applet object is used. }
  9441. end;
  9442. //[END OF TOpenSaveDialog DEFINITION]
  9443. //[Default OpenSaveDialog OPTIONS]
  9444. const DefOpenSaveDlgOptions: TOpenSaveOptions = [ OSHideReadonly,
  9445. OSOverwritePrompt, OSFileMustExist, OSPathMustExist ];
  9446. //[NewOpenSaveDialog DECLARATION]
  9447. function NewOpenSaveDialog( const Title, StrtDir: String;
  9448. Options: TOpenSaveOptions ): POpenSaveDialog;
  9449. {* Creates object, which can be used (several times) to open file(s)
  9450. selecting dialog. }
  9451. //[OpenDirectory Object]
  9452. type
  9453. {++}(*TOpenDirDialog = class;*){--}
  9454. POpenDirDialog = {-}^{+}TOpenDirDialog;
  9455. TOpenDirOption = ( odBrowseForComputer, odBrowseForPrinter, odDontGoBelowDomain,
  9456. odOnlyFileSystemAncestors, odOnlySystemDirs, odStatusText,
  9457. odBrowseIncludeFiles, odEditBox, odNewDialogStyle );
  9458. {* Flags available for TOpenDirDialog object. }
  9459. // odfStatusText - do not support status callback
  9460. TOpenDirOptions = set of TOpenDirOption;
  9461. {* Set of all flags used to control ZOpenDirDialog class. }
  9462. TOnODSelChange = procedure( Sender: POpenDirDialog; NewSelDir: PChar;
  9463. var EnableOK: Integer; var StatusText: String )
  9464. of object;
  9465. {* Event type to be called when user select another directory in OpenDirDialog.
  9466. Set EnableOK to -1 to disable OK button, or to +1 to enable it.
  9467. It is also possible to set new StatusText string. }
  9468. { ----------------------------------------------------------------------
  9469. TOpenDirDialog
  9470. ----------------------------------------------------------------------- }
  9471. //[TOpenDirDialog DEFINITION]
  9472. TOpenDirDialog = object( TObj )
  9473. {* Dialog for open directories, uses SHBrowseForFolder. }
  9474. protected
  9475. FTitle: String;
  9476. FOptions: TOpenDirOptions;
  9477. FCallBack: Pointer;
  9478. FCenterProc: procedure( Wnd: HWnd );
  9479. FBuf : array[ 0..MAX_PATH ] of Char;
  9480. FInitialPath: String;
  9481. FCenterOnScreen: Boolean;
  9482. FDoSelChanged: procedure( Wnd: HWnd; Msg: DWORD; lParam, lpData: LParam ); stdcall;
  9483. FOnSelChanged: TOnODSelChange;
  9484. FStatusText: String;
  9485. FWnd: HWnd;
  9486. function GetPath: String;
  9487. procedure SetInitialPath(const Value: String);
  9488. procedure SetCenterOnScreen(const Value: Boolean);
  9489. procedure SetOnSelChanged(const Value: TOnODSelChange);
  9490. function GetInitialPath: String;
  9491. public
  9492. destructor Destroy; {-}virtual;{+}{++}(*override;*){--}
  9493. {* destructor }
  9494. function Execute : Boolean;
  9495. {* Call it to select directory by user. Returns True, if operation was
  9496. not cancelled by user. }
  9497. property Title : String read FTitle write FTitle;
  9498. {* Title for a dialog. }
  9499. property Options : TOpenDirOptions read FOptions write FOptions;
  9500. {* Option flags. }
  9501. property Path : String read GetPath;
  9502. {* Resulting (selected by user) path. }
  9503. property InitialPath: String read GetInitialPath write SetInitialPath;
  9504. {* Set this property to a path of directory to be selected initially
  9505. in a dialog. }
  9506. property CenterOnScreen: Boolean read FCenterOnScreen write SetCenterOnScreen;
  9507. {* Set it to True to center dialog on screen. }
  9508. property OnSelChanged: TOnODSelChange read FOnSelChanged write SetOnSelChanged;
  9509. {* This event is called every time, when user selects another directory.
  9510. It is possible to eneble/disable OK button in dialog and/or change
  9511. dialog status text in responce to event. }
  9512. property WndOwner: HWnd read FWnd write FWnd;
  9513. {* Owner window. If you want to provide your dialog visible over stay-on-top
  9514. form, fire it as a child of the form, assigning the handle of form window
  9515. to this property first. }
  9516. end;
  9517. //[END OF TOpenDirDialog DEFINITION]
  9518. //[NewOpenSaveDialog DECLARATION]
  9519. function NewOpenDirDialog( const Title: String; Options: TOpenDirOptions ):
  9520. POpenDirDialog;
  9521. {* Creates object, which can be used (several times) to open directory
  9522. selecting dialog (using SHBrowseForFolder API call). }
  9523. //[Color Dialog Object]
  9524. type
  9525. TColorCustomOption = ( ccoFullOpen, ccoShortOpen, ccoPreventFullOpen );
  9526. {++}(*TColorDialog = class;*){--}
  9527. PColorDialog = {-}^{+}TColorDialog;
  9528. { ----------------------------------------------------------------------
  9529. TColorDialog
  9530. ----------------------------------------------------------------------- }
  9531. //[TColorDialog DEFINITION]
  9532. TColorDialog = object( TObj )
  9533. {* Color choosing dialog. }
  9534. protected
  9535. public
  9536. OwnerWindow: HWnd;
  9537. {* Owner window (can be 0). }
  9538. CustomColors: array[ 1..16 ] of TColor;
  9539. {* Array of stored custom colors. }
  9540. ColorCustomOption: TColorCustomOption;
  9541. {* Options (how to open a dialog). }
  9542. Color: TColor;
  9543. {* Returned color (if the result of Execute is True). }
  9544. function Execute: Boolean;
  9545. {* Call this method to open a dialog and wait its result. }
  9546. end;
  9547. //[END OF TColorDialog DEFINITION]
  9548. //[NewColorDialog DECLARATION]
  9549. function NewColorDialog( FullOpen: TColorCustomOption ): PColorDialog;
  9550. {* Creates color choosing dialog object. }
  9551. //[Ini files]
  9552. type
  9553. TIniFileMode = ( ifmRead, ifmWrite );
  9554. {* ifmRead is default mode (means "read" data from ini-file.
  9555. Set mode to ifmWrite to write data to ini-file, correspondent to
  9556. TIniFile. }
  9557. {++}(*TIniFile = class;*){--}
  9558. PIniFile = {-}^{+}TIniFile;
  9559. { ----------------------------------------------------------------------
  9560. TIniFile - store/load data to ini-files
  9561. ----------------------------------------------------------------------- }
  9562. //[TIniFile DEFINITION]
  9563. TIniFile = object( TObj )
  9564. {* Ini file incapsulation. The main feature is what the same block of
  9565. read-write operations could be defined (difference must be only in
  9566. Mode value).
  9567. |*Ini file sample.
  9568. This sample shows how the same Pascal operators can be used both
  9569. for read and write for the same variables, when working with TIniFile:
  9570. ! procedure ReadWriteIni( Write: Boolean );
  9571. ! var Ini: PIniFile;
  9572. ! begin
  9573. ! Ini := OpenIniFile( 'MyIniFile.ini' );
  9574. ! Ini.Section := 'Main';
  9575. ! if Write then // if Write, the same operators will save
  9576. ! Ini.Mode := ifmWrite; // data rather then load.
  9577. ! MyForm.Left := Ini.ValueInteger( 'Left', MyForm.Left );
  9578. ! MyForm.Top := Ini.ValueInteger( 'Top', MyForm.Top );
  9579. ! Ini.Free;
  9580. ! end;
  9581. !
  9582. |* }
  9583. protected
  9584. fMode: TIniFileMode;
  9585. fFileName: String;
  9586. fSection: String;
  9587. protected
  9588. public
  9589. destructor Destroy; {-}virtual;{+}{++}(*override;*){--}
  9590. {* destructor }
  9591. property Mode: TIniFileMode read fMode write fMode;
  9592. {* ifmWrite, if write data to ini-file rather than read it. }
  9593. property FileName: String read fFileName;
  9594. {* Ini file name. }
  9595. property Section: String read fSection write fSection;
  9596. {* Current ini section. }
  9597. function ValueInteger( const Key: String; Value: Integer ): Integer;
  9598. {* Reads or writes integer data value. }
  9599. function ValueString( const Key: String; const Value: String ): String;
  9600. {* Reads or writes string data value. }
  9601. function ValueBoolean( const Key: String; Value: Boolean ): Boolean;
  9602. {* Reads or writes boolean data value. }
  9603. function ValueData( const Key: String; Value: Pointer; Count: Integer ): Boolean;
  9604. {* Reads or writes data from/to buffer. Returns True, if success. }
  9605. procedure ClearAll;
  9606. {* Clears all sections of ini-file. }
  9607. procedure ClearSection;
  9608. {* Clears current Section of ini-file. }
  9609. procedure ClearKey( const Key: String );
  9610. {* Clears given key in current section. }
  9611. /////////////// + by Vyacheslav A. Gavrik:
  9612. procedure GetSectionNames(Names:PStrList);
  9613. {* Retrieves section names, storing it in string list passed as a parameter.
  9614. String list does not cleared before processing. Section names are added
  9615. to the end of the string list. }
  9616. procedure SectionData(Names:PStrList);
  9617. {* Read/write current section content to/from string list. (Depending on
  9618. current Mode value). }
  9619. ///////////////
  9620. end;
  9621. //[END OF TIniFile DEFINITION]
  9622. //[OpenIniFile DECLARATION]
  9623. function OpenIniFile( const FileName: String ): PIniFile;
  9624. {* Opens ini file, creating TIniFile object instance to work with it. }
  9625. //[MENU OBJECT]
  9626. type
  9627. TMenuitemInfo = packed record
  9628. cbSize: UINT;
  9629. fMask: UINT;
  9630. fType: UINT; { used if MIIM_TYPE}
  9631. fState: UINT; { used if MIIM_STATE}
  9632. wID: UINT; { used if MIIM_ID}
  9633. hSubMenu: HMENU; { used if MIIM_SUBMENU}
  9634. hbmpChecked: HBITMAP; { used if MIIM_CHECKMARKS}
  9635. hbmpUnchecked: HBITMAP; { used if MIIM_CHECKMARKS}
  9636. dwItemData: DWORD; { used if MIIM_DATA}
  9637. dwTypeData: PAnsiChar; { used if MIIM_TYPE}
  9638. cch: UINT; { used if MIIM_TYPE}
  9639. hbmpItem: HBITMAP; { used if MIIM_BITMAP - not exists under Windows95 }
  9640. end;
  9641. type
  9642. {++}(*TMenu = class;*){--}
  9643. PMenu = {-}^{+}TMenu;
  9644. TOnMenuItem = procedure( Sender : PMenu; Item : Integer ) of object;
  9645. {* Event type to define OnMenuItem event. }
  9646. TMenuAccelerator = packed Record
  9647. {* Menu accelerator record. Use MakeAccelerator function to combine desired
  9648. attributes into a record, describing the accelerator. }
  9649. fVirt: Byte; // or-combination of FSHIFT, FCONTROL, FALT, FVIRTKEY, FNOINVERT
  9650. Key: Word; // character or virtual key code (FVIRTKEY flag is present above)
  9651. NotUsed: Byte; // not used
  9652. end;
  9653. // by Sergey Shisminzev:
  9654. TMenuOption = (moDefault, moDisabled, moChecked,
  9655. moCheckMark, moRadioMark, moSeparator, moBitmap, moSubMenu,
  9656. moBreak, moBarBreak);
  9657. {* Options