Last change
on this file since 470 was 15, checked in by RBRi, 19 years ago |
+ components stuff
|
-
Property svn:eol-style
set to
native
|
File size:
1.2 KB
|
Rev | Line | |
---|
[15] | 1 | Unit IconImageUnit;
|
---|
| 2 |
|
---|
| 3 | Interface
|
---|
| 4 |
|
---|
| 5 | Uses
|
---|
| 6 | Classes, Forms, Graphics;
|
---|
| 7 |
|
---|
| 8 | {Declare new class}
|
---|
| 9 | Type
|
---|
| 10 | TIconImage=Class(TControl)
|
---|
| 11 | Protected
|
---|
| 12 | FIcon: TIcon;
|
---|
| 13 | Procedure SetupComponent; Override;
|
---|
| 14 | Procedure SetIcon( NewIcon: TIcon );
|
---|
| 15 | Procedure Redraw( const rec: TRect ); Override;
|
---|
| 16 | Public
|
---|
| 17 | Destructor Destroy; Override;
|
---|
| 18 | Published
|
---|
| 19 | property Icon: TIcon read FIcon write SetIcon;
|
---|
| 20 | End;
|
---|
| 21 |
|
---|
| 22 | {Define components to export}
|
---|
| 23 | {You may define a page of the component palette and a component bitmap file}
|
---|
| 24 | Exports
|
---|
| 25 | TIconImage,'User','';
|
---|
| 26 |
|
---|
| 27 | Implementation
|
---|
| 28 |
|
---|
| 29 | Uses
|
---|
| 30 | PmWin;
|
---|
| 31 |
|
---|
| 32 | Procedure TIconImage.SetupComponent;
|
---|
| 33 | Begin
|
---|
| 34 | Inherited SetupComponent;
|
---|
| 35 | FIcon := TIcon.Create;
|
---|
| 36 | Width := 32;
|
---|
| 37 | Height := 32;
|
---|
| 38 | Name := 'IconImage';
|
---|
| 39 | ParentColor := True;
|
---|
| 40 | Exclude( ComponentState, csAcceptsControls );
|
---|
| 41 | End;
|
---|
| 42 |
|
---|
| 43 | Destructor TIconImage.Destroy;
|
---|
| 44 | Begin
|
---|
| 45 | Inherited Destroy;
|
---|
| 46 | FIcon.Destroy;
|
---|
| 47 | End;
|
---|
| 48 |
|
---|
| 49 | Procedure TIconImage.SetIcon( NewIcon: TIcon );
|
---|
| 50 | Begin
|
---|
| 51 | FIcon.Assign( NewIcon );
|
---|
| 52 | Width := FIcon.Width;
|
---|
| 53 | Height := FIcon.Height;
|
---|
| 54 | End;
|
---|
| 55 |
|
---|
| 56 | Procedure TIconImage.Redraw( const rec: TRect );
|
---|
| 57 | Begin
|
---|
| 58 | Canvas.ClipRect := rec;
|
---|
| 59 | // clear background rectangle
|
---|
| 60 | Canvas.FillRect( rec, Color );
|
---|
| 61 |
|
---|
| 62 | Canvas.Draw( 0, 0, FIcon );
|
---|
| 63 | End;
|
---|
| 64 |
|
---|
| 65 | Initialization
|
---|
| 66 | {Register classes}
|
---|
| 67 | RegisterClasses([TIconImage]);
|
---|
| 68 | End.
|
---|
| 69 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.