-
Notifications
You must be signed in to change notification settings - Fork 1
/
CSCImageImpl1.pas
338 lines (283 loc) · 8.03 KB
/
CSCImageImpl1.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
unit CSCImageImpl1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ActiveX, AxCtrls, CSCImageProj_TLB, ExtCtrls;
type
TCSCImageX = class(TActiveForm, ICSCImageX)
Image1: TImage;
procedure CSCImageCreate(Sender: TObject);
private
{ Private declarations }
m_ImageFile : String;
FEvents: ICSCImageXEvents;
procedure ActivateEvent(Sender: TObject);
procedure ClickEvent(Sender: TObject);
procedure CreateEvent(Sender: TObject);
procedure DblClickEvent(Sender: TObject);
procedure DeactivateEvent(Sender: TObject);
procedure DestroyEvent(Sender: TObject);
procedure KeyPressEvent(Sender: TObject; var Key: Char);
procedure PaintEvent(Sender: TObject);
protected
{ Protected declarations }
procedure EventSinkChanged(const EventSink: IUnknown); override;
procedure Initialize; override;
function Get_Active: WordBool; safecall;
function Get_AutoScroll: WordBool; safecall;
function Get_AxBorderStyle: TxActiveFormBorderStyle; safecall;
function Get_Caption: WideString; safecall;
function Get_Color: TColor; safecall;
function Get_Cursor: Smallint; safecall;
function Get_DropTarget: WordBool; safecall;
function Get_Enabled: WordBool; safecall;
function Get_Font: Font; safecall;
function Get_HelpFile: WideString; safecall;
function Get_KeyPreview: WordBool; safecall;
function Get_PixelsPerInch: Integer; safecall;
function Get_PrintScale: TxPrintScale; safecall;
function Get_Scaled: WordBool; safecall;
function Get_Visible: WordBool; safecall;
function Get_WindowState: TxWindowState; safecall;
procedure AboutBox; safecall;
procedure Set_AutoScroll(Value: WordBool); safecall;
procedure Set_AxBorderStyle(Value: TxActiveFormBorderStyle); safecall;
procedure Set_Caption(const Value: WideString); safecall;
procedure Set_Color(Value: TColor); safecall;
procedure Set_Cursor(Value: Smallint); safecall;
procedure Set_DropTarget(Value: WordBool); safecall;
procedure Set_Enabled(Value: WordBool); safecall;
procedure Set_Font(const Value: Font); safecall;
procedure Set_HelpFile(const Value: WideString); safecall;
procedure Set_KeyPreview(Value: WordBool); safecall;
procedure Set_PixelsPerInch(Value: Integer); safecall;
procedure Set_PrintScale(Value: TxPrintScale); safecall;
procedure Set_Scaled(Value: WordBool); safecall;
procedure Set_Visible(Value: WordBool); safecall;
procedure Set_WindowState(Value: TxWindowState); safecall;
function Get_ImageFile: OleVariant; safecall;
procedure Set_ImageFile(Value: OleVariant); safecall;
function Get_Stretch: Integer; safecall;
procedure Set_Stretch(Value: Integer); safecall;
public
{ Public declarations }
end;
implementation
uses ComServ, About1;
{$R *.DFM}
{ TCSCImageX }
procedure TCSCImageX.EventSinkChanged(const EventSink: IUnknown);
begin
FEvents := EventSink as ICSCImageXEvents;
end;
procedure TCSCImageX.Initialize;
begin
OnActivate := ActivateEvent;
OnClick := ClickEvent;
OnCreate := CreateEvent;
OnDblClick := DblClickEvent;
OnDeactivate := DeactivateEvent;
OnDestroy := DestroyEvent;
OnKeyPress := KeyPressEvent;
OnPaint := PaintEvent;
end;
function TCSCImageX.Get_Active: WordBool;
begin
Result := Active;
end;
function TCSCImageX.Get_AutoScroll: WordBool;
begin
Result := AutoScroll;
end;
function TCSCImageX.Get_AxBorderStyle: TxActiveFormBorderStyle;
begin
Result := Ord(AxBorderStyle);
end;
function TCSCImageX.Get_Caption: WideString;
begin
Result := WideString(Caption);
end;
function TCSCImageX.Get_Color: TColor;
begin
Result := Color;
end;
function TCSCImageX.Get_Cursor: Smallint;
begin
Result := Smallint(Cursor);
end;
function TCSCImageX.Get_DropTarget: WordBool;
begin
Result := DropTarget;
end;
function TCSCImageX.Get_Enabled: WordBool;
begin
Result := Enabled;
end;
function TCSCImageX.Get_Font: Font;
begin
GetOleFont(Font, Result);
end;
function TCSCImageX.Get_HelpFile: WideString;
begin
Result := WideString(HelpFile);
end;
function TCSCImageX.Get_KeyPreview: WordBool;
begin
Result := KeyPreview;
end;
function TCSCImageX.Get_PixelsPerInch: Integer;
begin
Result := PixelsPerInch;
end;
function TCSCImageX.Get_PrintScale: TxPrintScale;
begin
Result := Ord(PrintScale);
end;
function TCSCImageX.Get_Scaled: WordBool;
begin
Result := Scaled;
end;
function TCSCImageX.Get_Visible: WordBool;
begin
Result := Visible;
end;
function TCSCImageX.Get_WindowState: TxWindowState;
begin
Result := Ord(WindowState);
end;
procedure TCSCImageX.AboutBox;
begin
ShowCSCImageXAbout;
end;
procedure TCSCImageX.Set_AutoScroll(Value: WordBool);
begin
AutoScroll := Value;
end;
procedure TCSCImageX.Set_AxBorderStyle(Value: TxActiveFormBorderStyle);
begin
AxBorderStyle := TActiveFormBorderStyle(Value);
end;
procedure TCSCImageX.Set_Caption(const Value: WideString);
begin
Caption := TCaption(Value);
end;
procedure TCSCImageX.Set_Color(Value: TColor);
begin
Color := Value;
end;
procedure TCSCImageX.Set_Cursor(Value: Smallint);
begin
Cursor := TCursor(Value);
end;
procedure TCSCImageX.Set_DropTarget(Value: WordBool);
begin
DropTarget := Value;
end;
procedure TCSCImageX.Set_Enabled(Value: WordBool);
begin
Enabled := Value;
end;
procedure TCSCImageX.Set_Font(const Value: Font);
begin
SetOleFont(Font, Value);
end;
procedure TCSCImageX.Set_HelpFile(const Value: WideString);
begin
HelpFile := String(Value);
end;
procedure TCSCImageX.Set_KeyPreview(Value: WordBool);
begin
KeyPreview := Value;
end;
procedure TCSCImageX.Set_PixelsPerInch(Value: Integer);
begin
PixelsPerInch := Value;
end;
procedure TCSCImageX.Set_PrintScale(Value: TxPrintScale);
begin
PrintScale := TPrintScale(Value);
end;
procedure TCSCImageX.Set_Scaled(Value: WordBool);
begin
Scaled := Value;
end;
procedure TCSCImageX.Set_Visible(Value: WordBool);
begin
Visible := Value;
end;
procedure TCSCImageX.Set_WindowState(Value: TxWindowState);
begin
WindowState := TWindowState(Value);
end;
procedure TCSCImageX.ActivateEvent(Sender: TObject);
begin
if FEvents <> nil then FEvents.OnActivate;
end;
procedure TCSCImageX.ClickEvent(Sender: TObject);
begin
if FEvents <> nil then FEvents.OnClick;
end;
procedure TCSCImageX.CreateEvent(Sender: TObject);
begin
if FEvents <> nil then FEvents.OnCreate;
end;
procedure TCSCImageX.DblClickEvent(Sender: TObject);
begin
if FEvents <> nil then FEvents.OnDblClick;
end;
procedure TCSCImageX.DeactivateEvent(Sender: TObject);
begin
if FEvents <> nil then FEvents.OnDeactivate;
end;
procedure TCSCImageX.DestroyEvent(Sender: TObject);
begin
if FEvents <> nil then FEvents.OnDestroy;
end;
procedure TCSCImageX.KeyPressEvent(Sender: TObject; var Key: Char);
var
TempKey: Smallint;
begin
TempKey := Smallint(Key);
if FEvents <> nil then FEvents.OnKeyPress(TempKey);
Key := Char(TempKey);
end;
procedure TCSCImageX.PaintEvent(Sender: TObject);
begin
if FEvents <> nil then FEvents.OnPaint;
end;
procedure TCSCImageX.CSCImageCreate(Sender: TObject);
begin
Image1.Height := Height;
Image1.Width := Width;
end;
function TCSCImageX.Get_ImageFile: OleVariant;
begin
result := m_ImageFile;
end;
procedure TCSCImageX.Set_ImageFile(Value: OleVariant);
begin
m_ImageFile := Value;
Image1.Picture.LoadFromFile(m_ImageFile);
Image1.Height := Height;
Image1.Width := Width;
Image1.Repaint;
Repaint;
end;
function TCSCImageX.Get_Stretch: Integer;
begin
Result := Integer(Image1.Stretch);
end;
procedure TCSCImageX.Set_Stretch(Value: Integer);
begin
Image1.Stretch := Boolean(Value);
end;
initialization
TActiveFormFactory.Create(
ComServer,
TActiveFormControl,
TCSCImageX,
Class_CSCImageX,
1,
'',
OLEMISC_SIMPLEFRAME or OLEMISC_ACTSLIKELABEL);
end.