source: branches/2.20_branch/Components/SystemIconUnit.PAS@ 415

Last change on this file since 415 was 15, checked in by RBRi, 19 years ago

+ components stuff

  • Property svn:eol-style set to native
File size: 3.3 KB
Line 
1Unit SystemIconUnit;
2
3Interface
4
5Uses
6 Classes, Forms, Graphics, OS2Def;
7
8{Declare new class}
9Type
10 TSystemIconID =
11 (
12 siArrow, // Arrow pointer
13 siText, // Text I-beam pointer
14 siWait, // Hourglass pointer
15 siSize, // Size pointer
16 siMove, // Move pointer
17 siSizeNWSE, // Downward-sloping, double-headed arrow pointer
18 siSizeNESW, // Upward-sloping, double-headed arrow pointer
19 siSizeWE, // Horizontal, double-headed arrow pointer
20 siSizeNS, // Vertical, double-headed arrow pointer
21 siAppIcon, // Standard application icon pointer
22 siIconInformation, // Information icon pointer
23 siIconQuestion, // Question mark icon pointer
24 siIconError, // Exclamation mark icon pointer
25 siIconWarning, // Warning icon pointer
26 siIllegal, // Illegal operation icon pointer
27 siFile, // Single file icon pointer
28 siMultFile, // Multiple files icon pointer
29 siFolder, // Folder icon pointer
30 siProgram // Application program icon pointer
31 );
32
33 TSystemIcon = Class(TControl)
34 Protected
35 FHandle: HPOINTER;
36 FID: TSystemIconID;
37 Procedure SetupComponent; Override;
38 Procedure Redraw( const rec: TRect ); Override;
39 Procedure SetID( NewID: TSystemIconID );
40 Public
41 Destructor Destroy; Override;
42 Published
43 property ID: TSystemIconID read FID write SetID;
44 End;
45
46{Define components to export}
47{You may define a page of the component palette and a component bitmap file}
48Exports
49 TSystemIcon,'User','';
50
51Implementation
52
53Uses
54 PmWin, PmBitmap, PmGpi;
55
56const
57 IDCode: array[ Low( TSystemIconID ) .. High( TSystemIconID ) ] of ULONG =
58 (
59 SPTR_ARROW,
60 SPTR_TEXT,
61 SPTR_WAIT,
62 SPTR_SIZE,
63 SPTR_MOVE,
64 SPTR_SIZENWSE,
65 SPTR_SIZENESW,
66 SPTR_SIZEWE,
67 SPTR_SIZENS,
68 SPTR_APPICON,
69 SPTR_ICONINFORMATION,
70 SPTR_ICONQUESTION,
71 SPTR_ICONERROR,
72 SPTR_ICONWARNING,
73 SPTR_ILLEGAL,
74 SPTR_FILE,
75 SPTR_MULTFILE,
76 SPTR_FOLDER,
77 SPTR_PROGRAM
78 );
79
80Procedure TSystemIcon.SetupComponent;
81Begin
82 Inherited SetupComponent;
83 Width := 32;
84 Height := 32;
85 ID := siIconInformation;
86 Name := 'SystemIcon';
87 ParentColor := True;
88 Exclude( ComponentState, csAcceptsControls );
89End;
90
91Destructor TSystemIcon.Destroy;
92Begin
93 Inherited Destroy;
94End;
95
96Procedure TSystemIcon.SetID( NewID: TSystemIconID );
97var
98 Info: POINTERINFO;
99 BMInfo: BITMAPINFOHEADER;
100Begin
101 if NewID = FID then
102 exit;
103
104 FID := NewID;
105
106 FHandle := WinQuerySysPointer( HWND_DESKTOP,
107 IDCode[ NewID ],
108 false // don't copy
109 );
110 WinQueryPointerInfo( FHandle,
111 Info );
112 if Info.hbmColor > 0 then
113 // color bitmap
114 GpiQueryBitmapParameters( Info.hbmColor,
115 BMInfo )
116 else
117 // b/w only
118 GpiQueryBitmapParameters( Info.hbmPointer,
119 BMInfo );
120 Width := BmInfo.cx;
121 Height := BmInfo.cy;
122 Refresh;
123End;
124
125Procedure TSystemIcon.Redraw( const rec: TRect );
126Begin
127 Canvas.ClipRect := rec;
128 // clear background rectangle
129 Canvas.FillRect( rec, Color );
130
131 WinDrawPointer( Canvas.Handle, 0, 0, FHandle, DP_NORMAL );
132End;
133
134Initialization
135 {Register classes}
136 RegisterClasses([TSystemIcon]);
137End.
138
Note: See TracBrowser for help on using the repository browser.