1 | unit Dpi.Forms;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, Forms, LMessages, Controls, LCLType,
|
---|
7 | Generics.Collections, LCLProc, LResources, Graphics, Dpi.Controls,
|
---|
8 | Dpi.Graphics;
|
---|
9 |
|
---|
10 | const
|
---|
11 | crDefault = TCursor(0);
|
---|
12 |
|
---|
13 | type
|
---|
14 | TMessageEvent = procedure (var TheMessage : TLMessage) of object;
|
---|
15 | TCloseAction = Forms.TCloseAction;
|
---|
16 | TFormState = Forms.TFormState;
|
---|
17 | TFormStateType = Forms.TFormStateType;
|
---|
18 | TWindowState = Forms.TWindowState;
|
---|
19 | TScrollBarKind = Forms.TScrollBarKind;
|
---|
20 | TBorderIcon = Forms.TBorderIcon;
|
---|
21 | TShowInTaskbar = Forms.TShowInTaskbar;
|
---|
22 | TTaskBarBehavior = Forms.TTaskBarBehavior;
|
---|
23 |
|
---|
24 | { TFormEx }
|
---|
25 |
|
---|
26 | TFormEx = class(Forms.TForm)
|
---|
27 | private
|
---|
28 | FOnMessage: TMessageEvent;
|
---|
29 | protected
|
---|
30 | procedure WndProc(var TheMessage : TLMessage); override;
|
---|
31 | property OnMessage: TMessageEvent read FOnMessage write FOnMessage;
|
---|
32 | end;
|
---|
33 |
|
---|
34 | { TControlScrollBar }
|
---|
35 |
|
---|
36 | TControlScrollBar = class(TPersistent)
|
---|
37 | private
|
---|
38 | function GetVisible: Boolean;
|
---|
39 | procedure SetVisible(AValue: Boolean);
|
---|
40 | published
|
---|
41 | property Visible: Boolean read GetVisible write SetVisible;
|
---|
42 | end;
|
---|
43 |
|
---|
44 | { TScrollingWinControl }
|
---|
45 |
|
---|
46 | TScrollingWinControl = class(TCustomControl)
|
---|
47 | private
|
---|
48 | FHorzScrollBar: TControlScrollBar;
|
---|
49 | FVertScrollBar: TControlScrollBar;
|
---|
50 | protected
|
---|
51 | function GetNativeCustomControl: Controls.TCustomControl; override;
|
---|
52 | function GetNativeScrollingWinControl: Forms.TScrollingWinControl; virtual;
|
---|
53 | public
|
---|
54 | constructor Create(TheOwner: TComponent); override;
|
---|
55 | destructor Destroy; override;
|
---|
56 | published
|
---|
57 | property HorzScrollBar: TControlScrollBar read FHorzScrollBar write FHorzScrollBar;
|
---|
58 | property VertScrollBar: TControlScrollBar read FVertScrollBar write FVertScrollBar;
|
---|
59 | end;
|
---|
60 |
|
---|
61 | { TForm }
|
---|
62 |
|
---|
63 | TForm = class(TScrollingWinControl)
|
---|
64 | private
|
---|
65 | FOnActivate: TNotifyEvent;
|
---|
66 | FOnClose: TCloseEvent;
|
---|
67 | FOnCloseQuery: TCloseQueryEvent;
|
---|
68 | FOnDeactivate: TNotifyEvent;
|
---|
69 | function GetBorderIcons: TBorderIcons;
|
---|
70 | function GetBorderStyle: TFormBorderStyle;
|
---|
71 | function GetDesignTimePPI: Integer;
|
---|
72 | function GetFormState: TFormState;
|
---|
73 | function GetFormStyle: TFormStyle;
|
---|
74 | function GetKeyPreview: Boolean;
|
---|
75 | function GetLCLVersion: string;
|
---|
76 | function GetModalResult: TModalResult;
|
---|
77 | function GetOnCloseQuery: TCloseQueryEvent;
|
---|
78 | function GetOnCreate: TNotifyEvent;
|
---|
79 | function GetOnDeactivate: TNotifyEvent;
|
---|
80 | function GetOnDestroy: TNotifyEvent;
|
---|
81 | function GetOnHide: TNotifyEvent;
|
---|
82 | function GetOnShow: TNotifyEvent;
|
---|
83 | function GetPosition: TPosition;
|
---|
84 | function GetRestoredHeight: Integer;
|
---|
85 | function GetRestoredLeft: Integer;
|
---|
86 | function GetRestoredTop: Integer;
|
---|
87 | function GetRestoredWidth: Integer;
|
---|
88 | function GetScaled: Boolean;
|
---|
89 | function GetShowInTaskbar: TShowInTaskbar;
|
---|
90 | function GetWindowState: TWindowState;
|
---|
91 | procedure SetBorderIcons(AValue: TBorderIcons);
|
---|
92 | procedure SetBorderStyle(AValue: TFormBorderStyle);
|
---|
93 | procedure SetDesignTimePPI(AValue: Integer);
|
---|
94 | procedure SetFormStyle(AValue: TFormStyle);
|
---|
95 | procedure SetKeyPreview(AValue: Boolean);
|
---|
96 | procedure SetLCLVersion(AValue: string);
|
---|
97 | procedure SetModalResult(AValue: TModalResult);
|
---|
98 | procedure SetOnCloseQuery(AValue: TCloseQueryEvent);
|
---|
99 | procedure SetOnCreate(AValue: TNotifyEvent);
|
---|
100 | procedure SetOnDeactivate(AValue: TNotifyEvent);
|
---|
101 | procedure SetOnDestroy(AValue: TNotifyEvent);
|
---|
102 | procedure SetOnHide(AValue: TNotifyEvent);
|
---|
103 | procedure SetOnShow(AValue: TNotifyEvent);
|
---|
104 | procedure DoOnCreate;
|
---|
105 | procedure FormMessageHandler(var TheMessage: TLMessage);
|
---|
106 | procedure SetPosition(AValue: TPosition);
|
---|
107 | procedure SetScaled(AValue: Boolean);
|
---|
108 | procedure SetShowInTaskBar(AValue: TShowInTaskbar);
|
---|
109 | procedure SetWindowState(AValue: TWindowState);
|
---|
110 | procedure ActivateHandler(Sender: TObject);
|
---|
111 | procedure DeactivateHandler(Sender: TObject);
|
---|
112 | procedure DoClose(var CloseAction: TCloseAction); virtual;
|
---|
113 | procedure CloseHandler(Sender: TObject; var CloseAction: TCloseAction);
|
---|
114 | procedure CloseQueryHandler(Sender : TObject; var CanClose : boolean);
|
---|
115 | protected
|
---|
116 | procedure CreateParams(var p: TCreateParams); virtual;
|
---|
117 | procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
|
---|
118 | function GetNativeScrollingWinControl: Forms.TScrollingWinControl; override;
|
---|
119 | function GetNativeForm: Forms.TForm; virtual;
|
---|
120 | procedure UpdateNativeControl; override;
|
---|
121 | public
|
---|
122 | NativeForm: Forms.TForm;
|
---|
123 | procedure AfterConstruction; override;
|
---|
124 | property ModalResult: TModalResult read GetModalResult write SetModalResult;
|
---|
125 | function ShowModal: Integer; virtual;
|
---|
126 | procedure SetFocus; override;
|
---|
127 | procedure Close;
|
---|
128 | function CloseQuery: boolean; virtual;
|
---|
129 | procedure BringToFront;
|
---|
130 | procedure Release;
|
---|
131 | constructor Create(TheOwner: TComponent); override;
|
---|
132 | constructor CreateNew(AOwner: TComponent; Num: Integer = 0); virtual;
|
---|
133 | destructor Destroy; override;
|
---|
134 | published
|
---|
135 | property RestoredLeft: integer read GetRestoredLeft;
|
---|
136 | property RestoredTop: integer read GetRestoredTop;
|
---|
137 | property RestoredWidth: integer read GetRestoredWidth;
|
---|
138 | property RestoredHeight: integer read GetRestoredHeight;
|
---|
139 | property DesignTimePPI: Integer read GetDesignTimePPI write SetDesignTimePPI; // Not used
|
---|
140 | property FormState: TFormState read GetFormState;
|
---|
141 | property FormStyle: TFormStyle read GetFormStyle write SetFormStyle;
|
---|
142 | property BorderStyle: TFormBorderStyle read GetBorderStyle write SetBorderStyle default bsSizeable;
|
---|
143 | property BorderIcons: TBorderIcons read GetBorderIcons write SetBorderIcons;
|
---|
144 | property LCLVersion: string read GetLCLVersion write SetLCLVersion;
|
---|
145 | property KeyPreview: Boolean read GetKeyPreview write SetKeyPreview default False;
|
---|
146 | property Position: TPosition read GetPosition write SetPosition default poDesigned;
|
---|
147 | property WindowState: TWindowState read GetWindowState write SetWindowState default wsNormal;
|
---|
148 | property OnShow: TNotifyEvent read GetOnShow write SetOnShow;
|
---|
149 | property OnHide: TNotifyEvent read GetOnHide write SetOnHide;
|
---|
150 | property OnCreate: TNotifyEvent read GetOnCreate write SetOnCreate;
|
---|
151 | property OnDestroy: TNotifyEvent read GetOnDestroy write SetOnDestroy;
|
---|
152 | property OnActivate: TNotifyEvent read FOnActivate write FOnActivate;
|
---|
153 | property OnDeactivate: TNotifyEvent read FOnDeactivate write FOnDeactivate;
|
---|
154 | property OnClose: TCloseEvent read FOnClose write FOnClose;
|
---|
155 | property OnCloseQuery: TCloseQueryEvent read FOnCloseQuery write FOnCloseQuery;
|
---|
156 | property ClientHeight;
|
---|
157 | property ClientWidth;
|
---|
158 | property OnMouseUp;
|
---|
159 | property OnMouseDown;
|
---|
160 | property OnMouseMove;
|
---|
161 | property ShowInTaskBar: TShowInTaskbar read GetShowInTaskbar write SetShowInTaskBar
|
---|
162 | default stDefault;
|
---|
163 | property Scaled: Boolean read GetScaled write SetScaled default True;
|
---|
164 | end;
|
---|
165 |
|
---|
166 | TForms = TObjectList<TForm>;
|
---|
167 |
|
---|
168 | { TApplication }
|
---|
169 |
|
---|
170 | TApplication = class(TComponent)
|
---|
171 | private
|
---|
172 | FMainForm: TForm;
|
---|
173 | FCreatingForm: TForm;
|
---|
174 | function GetActive: Boolean;
|
---|
175 | function GetExeName: string;
|
---|
176 | function GetShowMainForm: Boolean;
|
---|
177 | function GetTaskBarBehavior: TTaskBarBehavior;
|
---|
178 | function GetTitle: string;
|
---|
179 | procedure SetMainForm(AValue: TForm);
|
---|
180 | function GetMainForm: TForm;
|
---|
181 | procedure SetShowMainForm(AValue: Boolean);
|
---|
182 | procedure SetTaskBarBehavior(AValue: TTaskBarBehavior);
|
---|
183 | procedure SetTitle(AValue: string);
|
---|
184 | protected
|
---|
185 | function GetNativeApplication: Forms.TApplication; virtual;
|
---|
186 | procedure DoBeforeFinalization;
|
---|
187 | public
|
---|
188 | constructor Create(AOwner: TComponent); override;
|
---|
189 | destructor Destroy; override;
|
---|
190 | procedure Run;
|
---|
191 | procedure Initialize;
|
---|
192 | procedure Terminate;
|
---|
193 | procedure ProcessMessages;
|
---|
194 | procedure UpdateMainForm(AForm: TForm);
|
---|
195 | procedure CreateForm(InstanceClass: TComponentClass; out Reference);
|
---|
196 | procedure RemoveStayOnTop(const ASystemTopAlso: Boolean = False);
|
---|
197 | procedure RestoreStayOnTop(const ASystemTopAlso: Boolean = False);
|
---|
198 | function MessageBox(Text, Caption: PChar; Flags: Longint = MB_OK): Integer;
|
---|
199 | property MainForm: TForm read GetMainForm write SetMainForm;
|
---|
200 | property ShowMainForm: Boolean read GetShowMainForm write SetShowMainForm default True;
|
---|
201 | property Title: string read GetTitle write SetTitle;
|
---|
202 | property Active: Boolean read GetActive;
|
---|
203 | property ExeName: string read GetExeName;
|
---|
204 | property TaskBarBehavior: TTaskBarBehavior read GetTaskBarBehavior write SetTaskBarBehavior;
|
---|
205 | end;
|
---|
206 |
|
---|
207 | { TMonitor }
|
---|
208 |
|
---|
209 | TMonitor = class
|
---|
210 | private
|
---|
211 | function GetLeft: Integer;
|
---|
212 | function GetHeight: Integer;
|
---|
213 | function GetTop: Integer;
|
---|
214 | function GetWidth: Integer;
|
---|
215 | function GetBoundsRect: TRect;
|
---|
216 | public
|
---|
217 | NativeMonitor: Forms.TMonitor;
|
---|
218 | property Left: Integer read GetLeft;
|
---|
219 | property Height: Integer read GetHeight;
|
---|
220 | property Top: Integer read GetTop;
|
---|
221 | property Width: Integer read GetWidth;
|
---|
222 | property BoundsRect: TRect read GetBoundsRect;
|
---|
223 | end;
|
---|
224 |
|
---|
225 | { TScreen }
|
---|
226 |
|
---|
227 | TScreen = class
|
---|
228 | private
|
---|
229 | FDpi: Integer;
|
---|
230 | FActiveForm: TForm;
|
---|
231 | FPrevActiveForms: TForms;
|
---|
232 | FPrimaryMonitor: TMonitor;
|
---|
233 | FForms: TForms;
|
---|
234 | procedure AddForm(AForm: TForm);
|
---|
235 | function GetDesktopHeight: Integer;
|
---|
236 | function GetDesktopLeft: Integer;
|
---|
237 | function GetDesktopTop: Integer;
|
---|
238 | function GetDesktopWidth: Integer;
|
---|
239 | function GetPrimaryMonitor: TMonitor;
|
---|
240 | procedure RemoveForm(AForm: TForm);
|
---|
241 | function GetActiveForm: TForm;
|
---|
242 | function GetCursor: TCursor;
|
---|
243 | function GetCursors(Index: Integer): HCURSOR;
|
---|
244 | function GetFormCount: Integer;
|
---|
245 | function GetForms(Index: Integer): TForm;
|
---|
246 | function GetHeight: Integer;
|
---|
247 | function GetWidth: Integer;
|
---|
248 | procedure SetCursor(AValue: TCursor);
|
---|
249 | procedure SetCursors(Index: Integer; AValue: HCURSOR);
|
---|
250 | procedure SetDpi(AValue: Integer);
|
---|
251 | procedure UpdateForms;
|
---|
252 | public
|
---|
253 | constructor Create;
|
---|
254 | destructor Destroy; override;
|
---|
255 | procedure UpdateActiveFormFromNativeScreen;
|
---|
256 | function DisableForms(SkipForm: TForm; DisabledList: Classes.TList = nil): Classes.TList;
|
---|
257 | procedure EnableForms(var AFormList: Classes.TList);
|
---|
258 | function GetSystemDpi: Integer;
|
---|
259 | property FormCount: Integer read GetFormCount;
|
---|
260 | property Forms[Index: Integer]: TForm read GetForms;
|
---|
261 | property ActiveForm: TForm read GetActiveForm;
|
---|
262 | property Cursor: TCursor read GetCursor write SetCursor;
|
---|
263 | property Cursors[Index: Integer]: HCURSOR read GetCursors write SetCursors;
|
---|
264 | published
|
---|
265 | property Dpi: Integer read FDpi write SetDpi;
|
---|
266 | property PixelsPerInch: Integer read FDpi;
|
---|
267 | property Width: Integer read GetWidth;
|
---|
268 | property Height: Integer read GetHeight;
|
---|
269 | property DesktopLeft: Integer read GetDesktopLeft;
|
---|
270 | property DesktopTop: Integer read GetDesktopTop;
|
---|
271 | property DesktopWidth: Integer read GetDesktopWidth;
|
---|
272 | property DesktopHeight: Integer read GetDesktopHeight;
|
---|
273 | property PrimaryMonitor: TMonitor read GetPrimaryMonitor;
|
---|
274 | end;
|
---|
275 |
|
---|
276 | var
|
---|
277 | Application: TApplication;
|
---|
278 | Screen: TScreen;
|
---|
279 |
|
---|
280 |
|
---|
281 | implementation
|
---|
282 |
|
---|
283 | uses
|
---|
284 | Dpi.Common;
|
---|
285 |
|
---|
286 | var
|
---|
287 | LCLScreen: Forms.TScreen absolute Forms.Screen;
|
---|
288 |
|
---|
289 | { TFormEx }
|
---|
290 |
|
---|
291 | procedure TFormEx.WndProc(var TheMessage: TLMessage);
|
---|
292 | begin
|
---|
293 | inherited WndProc(TheMessage);
|
---|
294 | if Assigned(FOnMessage) then
|
---|
295 | FOnMessage(TheMessage);
|
---|
296 | end;
|
---|
297 |
|
---|
298 | { TScrollingWinControl }
|
---|
299 |
|
---|
300 | function TScrollingWinControl.GetNativeCustomControl: Controls.TCustomControl;
|
---|
301 | begin
|
---|
302 | Result := GetNativeScrollingWinControl;
|
---|
303 | end;
|
---|
304 |
|
---|
305 | function TScrollingWinControl.GetNativeScrollingWinControl: Forms.TScrollingWinControl;
|
---|
306 | begin
|
---|
307 | Result := nil;
|
---|
308 | end;
|
---|
309 |
|
---|
310 | constructor TScrollingWinControl.Create(TheOwner: TComponent);
|
---|
311 | begin
|
---|
312 | inherited;
|
---|
313 | FHorzScrollBar := TControlScrollBar.Create;
|
---|
314 | FVertScrollBar := TControlScrollBar.Create;
|
---|
315 | end;
|
---|
316 |
|
---|
317 | destructor TScrollingWinControl.Destroy;
|
---|
318 | begin
|
---|
319 | FreeAndNil(FHorzScrollBar);
|
---|
320 | FreeAndNil(FVertScrollBar);
|
---|
321 | inherited;
|
---|
322 | end;
|
---|
323 |
|
---|
324 | { TApplication }
|
---|
325 |
|
---|
326 | procedure TApplication.SetMainForm(AValue: TForm);
|
---|
327 | begin
|
---|
328 | FMainForm := AValue;
|
---|
329 | end;
|
---|
330 |
|
---|
331 | function TApplication.GetTitle: string;
|
---|
332 | begin
|
---|
333 | Result := GetNativeApplication.Title;
|
---|
334 | end;
|
---|
335 |
|
---|
336 | function TApplication.GetShowMainForm: Boolean;
|
---|
337 | begin
|
---|
338 | Result := GetNativeApplication.ShowMainForm;
|
---|
339 | end;
|
---|
340 |
|
---|
341 | function TApplication.GetTaskBarBehavior: TTaskBarBehavior;
|
---|
342 | begin
|
---|
343 | Result := GetNativeApplication.TaskBarBehavior;
|
---|
344 | end;
|
---|
345 |
|
---|
346 | function TApplication.GetActive: Boolean;
|
---|
347 | begin
|
---|
348 | Result := GetNativeApplication.Active;
|
---|
349 | end;
|
---|
350 |
|
---|
351 | function TApplication.GetExeName: string;
|
---|
352 | begin
|
---|
353 | Result := GetNativeApplication.ExeName;
|
---|
354 | end;
|
---|
355 |
|
---|
356 | function TApplication.GetMainForm: TForm;
|
---|
357 | begin
|
---|
358 | Result := FMainForm;
|
---|
359 | end;
|
---|
360 |
|
---|
361 | procedure TApplication.SetShowMainForm(AValue: Boolean);
|
---|
362 | begin
|
---|
363 | GetNativeApplication.ShowMainForm := AValue;
|
---|
364 | end;
|
---|
365 |
|
---|
366 | procedure TApplication.SetTaskBarBehavior(AValue: TTaskBarBehavior);
|
---|
367 | begin
|
---|
368 | GetNativeApplication.TaskBarBehavior := AValue;
|
---|
369 | end;
|
---|
370 |
|
---|
371 | procedure TApplication.SetTitle(AValue: string);
|
---|
372 | begin
|
---|
373 | GetNativeApplication.Title := AValue;
|
---|
374 | end;
|
---|
375 |
|
---|
376 | function TApplication.GetNativeApplication: Forms.TApplication;
|
---|
377 | begin
|
---|
378 | Result := Forms.Application;
|
---|
379 | end;
|
---|
380 |
|
---|
381 | procedure DpiBeforeFinalization;
|
---|
382 | // This is our ExitProc handler.
|
---|
383 | begin
|
---|
384 | Application.DoBeforeFinalization;
|
---|
385 | end;
|
---|
386 |
|
---|
387 | procedure TApplication.DoBeforeFinalization;
|
---|
388 | var
|
---|
389 | I: Integer;
|
---|
390 | begin
|
---|
391 | if Self = nil then Exit;
|
---|
392 | for I := ComponentCount - 1 downto 0 do begin
|
---|
393 | if I < ComponentCount then
|
---|
394 | Components[I].Free;
|
---|
395 | end;
|
---|
396 | end;
|
---|
397 |
|
---|
398 | function DpiFindApplicationComponent(const ComponentName: string): TComponent;
|
---|
399 | // Note: this function is used by TReader to auto rename forms to unique names.
|
---|
400 | begin
|
---|
401 | Result := Application.FindComponent(ComponentName);
|
---|
402 | end;
|
---|
403 |
|
---|
404 | constructor TApplication.Create(AOwner: TComponent);
|
---|
405 | begin
|
---|
406 | RegisterFindGlobalComponentProc(@DpiFindApplicationComponent);
|
---|
407 | AddExitProc(@DpiBeforeFinalization);
|
---|
408 | inherited;
|
---|
409 | end;
|
---|
410 |
|
---|
411 | destructor TApplication.Destroy;
|
---|
412 | begin
|
---|
413 | UnregisterFindGlobalComponentProc(@DpiFindApplicationComponent);
|
---|
414 | inherited;
|
---|
415 | end;
|
---|
416 |
|
---|
417 | procedure TApplication.Run;
|
---|
418 | begin
|
---|
419 | if (FMainForm <> nil) and GetShowMainForm then FMainForm.Show;
|
---|
420 | GetNativeApplication.Run;
|
---|
421 | end;
|
---|
422 |
|
---|
423 | procedure TApplication.Initialize;
|
---|
424 | begin
|
---|
425 | GetNativeApplication.Initialize;
|
---|
426 | end;
|
---|
427 |
|
---|
428 | procedure TApplication.Terminate;
|
---|
429 | begin
|
---|
430 | GetNativeApplication.Terminate;
|
---|
431 | end;
|
---|
432 |
|
---|
433 | procedure TApplication.ProcessMessages;
|
---|
434 | begin
|
---|
435 | GetNativeApplication.ProcessMessages;
|
---|
436 | end;
|
---|
437 |
|
---|
438 | procedure TApplication.UpdateMainForm(AForm: TForm);
|
---|
439 | begin
|
---|
440 | if (FMainForm = nil)
|
---|
441 | and (FCreatingForm = AForm)
|
---|
442 | //and (not (AppDestroying in FFlags))
|
---|
443 | and not (AForm.FormStyle in [fsMDIChild, fsSplash])
|
---|
444 | then
|
---|
445 | FMainForm := AForm;
|
---|
446 | GetNativeApplication.UpdateMainForm(AForm.GetNativeForm);
|
---|
447 | end;
|
---|
448 |
|
---|
449 | procedure TApplication.CreateForm(InstanceClass: TComponentClass; out
|
---|
450 | Reference);
|
---|
451 | var
|
---|
452 | Instance: TComponent;
|
---|
453 | Ok: Boolean;
|
---|
454 | AForm: TForm;
|
---|
455 | begin
|
---|
456 | // Allocate the instance, without calling the constructor
|
---|
457 | Instance := TComponent(InstanceClass.NewInstance);
|
---|
458 | // set the Reference before the constructor is called, so that
|
---|
459 | // events and constructors can refer to it
|
---|
460 | TComponent(Reference) := Instance;
|
---|
461 |
|
---|
462 | Ok := False;
|
---|
463 | try
|
---|
464 | if (FCreatingForm = nil) and (Instance is TForm) then
|
---|
465 | FCreatingForm := TForm(Instance);
|
---|
466 | Instance.Create(Self);
|
---|
467 | Ok := True;
|
---|
468 | finally
|
---|
469 | if not Ok then begin
|
---|
470 | TComponent(Reference) := nil;
|
---|
471 | if FCreatingForm = Instance then
|
---|
472 | FCreatingForm := nil;
|
---|
473 | end;
|
---|
474 | end;
|
---|
475 |
|
---|
476 | if (Instance is TForm) then begin
|
---|
477 | AForm := TForm(Instance);
|
---|
478 | UpdateMainForm(AForm);
|
---|
479 | if FMainForm = AForm then AForm.GetNativeForm.HandleNeeded;
|
---|
480 | if AForm.FormStyle = fsSplash then begin
|
---|
481 | // show the splash form and handle the paint message
|
---|
482 | AForm.Show;
|
---|
483 | AForm.Invalidate;
|
---|
484 | ProcessMessages;
|
---|
485 | end;
|
---|
486 | end;
|
---|
487 | end;
|
---|
488 |
|
---|
489 | procedure TApplication.RemoveStayOnTop(const ASystemTopAlso: Boolean);
|
---|
490 | begin
|
---|
491 | GetNativeApplication.RemoveStayOnTop(ASystemTopAlso);
|
---|
492 | end;
|
---|
493 |
|
---|
494 | procedure TApplication.RestoreStayOnTop(const ASystemTopAlso: Boolean);
|
---|
495 | begin
|
---|
496 | GetNativeApplication.RestoreStayOnTop(ASystemTopAlso);
|
---|
497 | end;
|
---|
498 |
|
---|
499 | function TApplication.MessageBox(Text, Caption: PChar; Flags: Longint
|
---|
500 | ): Integer;
|
---|
501 | begin
|
---|
502 | Result := Application.MessageBox(Text, Caption, Flags);
|
---|
503 | end;
|
---|
504 |
|
---|
505 | { TMonitor }
|
---|
506 |
|
---|
507 | function TMonitor.GetLeft: Integer;
|
---|
508 | begin
|
---|
509 | Result := ScaleFromNative(NativeMonitor.Left);
|
---|
510 | end;
|
---|
511 |
|
---|
512 | function TMonitor.GetHeight: Integer;
|
---|
513 | begin
|
---|
514 | Result := ScaleFromNative(NativeMonitor.Height);
|
---|
515 | end;
|
---|
516 |
|
---|
517 | function TMonitor.GetTop: Integer;
|
---|
518 | begin
|
---|
519 | Result := ScaleFromNative(NativeMonitor.Top);
|
---|
520 | end;
|
---|
521 |
|
---|
522 | function TMonitor.GetWidth: Integer;
|
---|
523 | begin
|
---|
524 | Result := ScaleFromNative(NativeMonitor.Width);
|
---|
525 | end;
|
---|
526 |
|
---|
527 | function TMonitor.GetBoundsRect: TRect;
|
---|
528 | begin
|
---|
529 | Result := ScaleRectFromNative(NativeMonitor.BoundsRect);
|
---|
530 | end;
|
---|
531 |
|
---|
532 | { TForm }
|
---|
533 |
|
---|
534 | function TForm.GetBorderIcons: TBorderIcons;
|
---|
535 | begin
|
---|
536 | Result := GetNativeForm.BorderIcons;
|
---|
537 | end;
|
---|
538 |
|
---|
539 | function TForm.GetBorderStyle: TFormBorderStyle;
|
---|
540 | begin
|
---|
541 | Result := GetNativeForm.BorderStyle;
|
---|
542 | end;
|
---|
543 |
|
---|
544 | function TForm.GetDesignTimePPI: Integer;
|
---|
545 | begin
|
---|
546 | Result := GetNativeForm.DesignTimePPI;
|
---|
547 | end;
|
---|
548 |
|
---|
549 | function TForm.GetFormState: TFormState;
|
---|
550 | begin
|
---|
551 | Result := GetNativeForm.FormState;
|
---|
552 | end;
|
---|
553 |
|
---|
554 | function TForm.GetFormStyle: TFormStyle;
|
---|
555 | begin
|
---|
556 | Result := GetNativeForm.FormStyle;
|
---|
557 | end;
|
---|
558 |
|
---|
559 | function TForm.GetKeyPreview: Boolean;
|
---|
560 | begin
|
---|
561 | Result := GetNativeForm.KeyPreview;
|
---|
562 | end;
|
---|
563 |
|
---|
564 | function TForm.GetLCLVersion: string;
|
---|
565 | begin
|
---|
566 | Result := GetNativeForm.LCLVersion;
|
---|
567 | end;
|
---|
568 |
|
---|
569 | function TForm.GetModalResult: TModalResult;
|
---|
570 | begin
|
---|
571 | Result := GetNativeForm.ModalResult;
|
---|
572 | end;
|
---|
573 |
|
---|
574 | function TForm.GetOnCloseQuery: TCloseQueryEvent;
|
---|
575 | begin
|
---|
576 | Result := GetNativeForm.OnCloseQuery;
|
---|
577 | end;
|
---|
578 |
|
---|
579 | function TForm.GetOnCreate: TNotifyEvent;
|
---|
580 | begin
|
---|
581 | Result := GetNativeForm.OnCreate;
|
---|
582 | end;
|
---|
583 |
|
---|
584 | function TForm.GetOnDeactivate: TNotifyEvent;
|
---|
585 | begin
|
---|
586 | Result := GetNativeForm.OnDeactivate;
|
---|
587 | end;
|
---|
588 |
|
---|
589 | function TForm.GetOnDestroy: TNotifyEvent;
|
---|
590 | begin
|
---|
591 | Result := GetNativeForm.OnDestroy;
|
---|
592 | end;
|
---|
593 |
|
---|
594 | function TForm.GetOnHide: TNotifyEvent;
|
---|
595 | begin
|
---|
596 | Result := GetNativeForm.OnHide;
|
---|
597 | end;
|
---|
598 |
|
---|
599 | function TForm.GetOnShow: TNotifyEvent;
|
---|
600 | begin
|
---|
601 | Result := GetNativeForm.OnShow;
|
---|
602 | end;
|
---|
603 |
|
---|
604 | function TForm.GetPosition: TPosition;
|
---|
605 | begin
|
---|
606 | Result := GetNativeForm.Position;
|
---|
607 | end;
|
---|
608 |
|
---|
609 | function TForm.GetRestoredHeight: Integer;
|
---|
610 | begin
|
---|
611 | Result := ScaleFromNative(GetNativeForm.RestoredHeight);
|
---|
612 | end;
|
---|
613 |
|
---|
614 | function TForm.GetRestoredLeft: Integer;
|
---|
615 | begin
|
---|
616 | Result := ScaleFromNative(GetNativeForm.RestoredLeft);
|
---|
617 | end;
|
---|
618 |
|
---|
619 | function TForm.GetRestoredTop: Integer;
|
---|
620 | begin
|
---|
621 | Result := ScaleFromNative(GetNativeForm.RestoredTop);
|
---|
622 | end;
|
---|
623 |
|
---|
624 | function TForm.GetRestoredWidth: Integer;
|
---|
625 | begin
|
---|
626 | Result := ScaleFromNative(GetNativeForm.RestoredWidth);
|
---|
627 | end;
|
---|
628 |
|
---|
629 | function TForm.GetScaled: Boolean;
|
---|
630 | begin
|
---|
631 | Result := GetNativeForm.Scaled;
|
---|
632 | end;
|
---|
633 |
|
---|
634 | function TForm.GetShowInTaskbar: TShowInTaskbar;
|
---|
635 | begin
|
---|
636 | Result := GetNativeForm.ShowInTaskBar;
|
---|
637 | end;
|
---|
638 |
|
---|
639 | function TForm.GetWindowState: TWindowState;
|
---|
640 | begin
|
---|
641 | Result := GetNativeForm.WindowState;
|
---|
642 | end;
|
---|
643 |
|
---|
644 | procedure TForm.SetBorderIcons(AValue: TBorderIcons);
|
---|
645 | begin
|
---|
646 | GetNativeForm.BorderIcons := AValue;
|
---|
647 | end;
|
---|
648 |
|
---|
649 | procedure TForm.SetBorderStyle(AValue: TFormBorderStyle);
|
---|
650 | begin
|
---|
651 | GetNativeForm.BorderStyle := AValue;
|
---|
652 | end;
|
---|
653 |
|
---|
654 | procedure TForm.SetDesignTimePPI(AValue: Integer);
|
---|
655 | begin
|
---|
656 | GetNativeForm.DesignTimePPI := AValue;
|
---|
657 | end;
|
---|
658 |
|
---|
659 | procedure TForm.SetFormStyle(AValue: TFormStyle);
|
---|
660 | begin
|
---|
661 | GetNativeForm.FormStyle := AValue;
|
---|
662 | end;
|
---|
663 |
|
---|
664 | procedure TForm.SetKeyPreview(AValue: Boolean);
|
---|
665 | begin
|
---|
666 | GetNativeForm.KeyPreview := AValue;
|
---|
667 | end;
|
---|
668 |
|
---|
669 | procedure TForm.SetLCLVersion(AValue: string);
|
---|
670 | begin
|
---|
671 | GetNativeForm.LCLVersion := AValue;
|
---|
672 | end;
|
---|
673 |
|
---|
674 | procedure TForm.SetModalResult(AValue: TModalResult);
|
---|
675 | begin
|
---|
676 | GetNativeForm.ModalResult := AValue;
|
---|
677 | end;
|
---|
678 |
|
---|
679 | procedure TForm.SetOnCloseQuery(AValue: TCloseQueryEvent);
|
---|
680 | begin
|
---|
681 | GetNativeForm.OnCloseQuery := AValue;
|
---|
682 | end;
|
---|
683 |
|
---|
684 | procedure TForm.SetOnCreate(AValue: TNotifyEvent);
|
---|
685 | begin
|
---|
686 | GetNativeForm.OnCreate := AValue;
|
---|
687 | end;
|
---|
688 |
|
---|
689 | procedure TForm.SetOnDeactivate(AValue: TNotifyEvent);
|
---|
690 | begin
|
---|
691 | GetNativeForm.OnDeactivate := AValue;
|
---|
692 | end;
|
---|
693 |
|
---|
694 | procedure TForm.SetOnDestroy(AValue: TNotifyEvent);
|
---|
695 | begin
|
---|
696 | GetNativeForm.OnDestroy := AValue;
|
---|
697 | end;
|
---|
698 |
|
---|
699 | procedure TForm.SetOnHide(AValue: TNotifyEvent);
|
---|
700 | begin
|
---|
701 | GetNativeForm.OnHide := AValue;
|
---|
702 | end;
|
---|
703 |
|
---|
704 | procedure TForm.SetOnShow(AValue: TNotifyEvent);
|
---|
705 | begin
|
---|
706 | GetNativeForm.OnShow := AValue;
|
---|
707 | end;
|
---|
708 |
|
---|
709 | procedure TForm.DoOnCreate;
|
---|
710 | begin
|
---|
711 | if Assigned(GetNativeForm.OnCreate) then
|
---|
712 | GetNativeForm.OnCreate(Self);
|
---|
713 | end;
|
---|
714 |
|
---|
715 | procedure TForm.FormMessageHandler(var TheMessage: TLMessage);
|
---|
716 | begin
|
---|
717 | Dispatch(TheMessage);
|
---|
718 | end;
|
---|
719 |
|
---|
720 | procedure TForm.SetPosition(AValue: TPosition);
|
---|
721 | begin
|
---|
722 | GetNativeForm.Position := AValue;
|
---|
723 | end;
|
---|
724 |
|
---|
725 | procedure TForm.SetScaled(AValue: Boolean);
|
---|
726 | begin
|
---|
727 | GetNativeForm.Scaled := AValue;
|
---|
728 | end;
|
---|
729 |
|
---|
730 | procedure TForm.SetShowInTaskBar(AValue: TShowInTaskbar);
|
---|
731 | begin
|
---|
732 | GetNativeForm.ShowInTaskBar := AValue;
|
---|
733 | end;
|
---|
734 |
|
---|
735 | procedure TForm.SetWindowState(AValue: TWindowState);
|
---|
736 | begin
|
---|
737 | GetNativeForm.WindowState := AValue;
|
---|
738 | end;
|
---|
739 |
|
---|
740 | procedure TForm.ActivateHandler(Sender: TObject);
|
---|
741 | begin
|
---|
742 | if Assigned(Screen.FActiveForm) then begin
|
---|
743 | if Screen.FPrevActiveForms.IndexOf(Screen.FActiveForm) <> - 1 then
|
---|
744 | Screen.FPrevActiveForms.Remove(Screen.FActiveForm);
|
---|
745 | Screen.FPrevActiveForms.Add(Screen.FActiveForm);
|
---|
746 | end;
|
---|
747 | Screen.FActiveForm := Self;
|
---|
748 | if Assigned(FOnActivate) then FOnActivate(Sender);
|
---|
749 | end;
|
---|
750 |
|
---|
751 | procedure TForm.DeactivateHandler(Sender: TObject);
|
---|
752 | begin
|
---|
753 | if Screen.FPrevActiveForms.Count > 0 then begin
|
---|
754 | Screen.FActiveForm := Screen.FPrevActiveForms.Last;
|
---|
755 | Screen.FPrevActiveForms.Delete(Screen.FPrevActiveForms.Count - 1);
|
---|
756 | end else Screen.FActiveForm := nil;
|
---|
757 | //Screen.UpdateActiveFormFromNativeScreen;
|
---|
758 | if Assigned(FOnDeactivate) then FOnDeactivate(Sender);
|
---|
759 | end;
|
---|
760 |
|
---|
761 | procedure TForm.DoClose(var CloseAction: TCloseAction);
|
---|
762 | begin
|
---|
763 | if Assigned(FOnClose) then FOnClose(Self, CloseAction);
|
---|
764 | end;
|
---|
765 |
|
---|
766 | procedure TForm.CloseHandler(Sender: TObject; var CloseAction: TCloseAction);
|
---|
767 | begin
|
---|
768 | Close;
|
---|
769 | end;
|
---|
770 |
|
---|
771 | procedure TForm.CloseQueryHandler(Sender : TObject; var CanClose : boolean);
|
---|
772 | begin
|
---|
773 | if Assigned(FOnCloseQuery) then FOnCloseQuery(Self, CanClose);
|
---|
774 | end;
|
---|
775 |
|
---|
776 | procedure TForm.CreateParams(var p: TCreateParams);
|
---|
777 | begin
|
---|
778 | // TODO: NativeForm.CreateParams(P);
|
---|
779 | end;
|
---|
780 |
|
---|
781 | // This method is called by TWriter to retrieve the child components to write
|
---|
782 | procedure TForm.GetChildren(Proc: TGetChildProc; Root: TComponent);
|
---|
783 | var
|
---|
784 | I: Integer;
|
---|
785 | OwnedComponent: TComponent;
|
---|
786 | begin
|
---|
787 | DebugLn(['TDpiForm.GetChildren ComponentCount=', ComponentCount]);
|
---|
788 | inherited GetChildren(Proc, Root);
|
---|
789 | if Root = Self then begin
|
---|
790 | for I := 0 to ComponentCount - 1 do begin
|
---|
791 | OwnedComponent := Components[I];
|
---|
792 | if not OwnedComponent.HasParent then Proc(OwnedComponent);
|
---|
793 | end;
|
---|
794 | end;
|
---|
795 | end;
|
---|
796 |
|
---|
797 | function TForm.GetNativeScrollingWinControl: Forms.TScrollingWinControl;
|
---|
798 | begin
|
---|
799 | Result := GetNativeForm;
|
---|
800 | end;
|
---|
801 |
|
---|
802 | function TForm.GetNativeForm: Forms.TForm;
|
---|
803 | begin
|
---|
804 | if not Assigned(NativeForm) then begin
|
---|
805 | NativeForm := TFormEx.CreateNew(nil);
|
---|
806 | (NativeForm as TFormEx).OnMessage := FormMessageHandler;
|
---|
807 | //NativeForm := Forms.TForm.Create(nil);
|
---|
808 | end;
|
---|
809 | Result := NativeForm;
|
---|
810 | end;
|
---|
811 |
|
---|
812 | procedure TForm.UpdateNativeControl;
|
---|
813 | begin
|
---|
814 | inherited;
|
---|
815 | GetNativeForm.OnActivate := ActivateHandler;
|
---|
816 | GetNativeForm.OnDeactivate := DeactivateHandler;
|
---|
817 | GetNativeForm.OnClose := CloseHandler;
|
---|
818 | GetNativeForm.OnCloseQuery := CloseQueryHandler;
|
---|
819 | GetNativeForm.Name := Name + 'Native';
|
---|
820 | end;
|
---|
821 |
|
---|
822 | procedure TForm.AfterConstruction;
|
---|
823 | begin
|
---|
824 | inherited;
|
---|
825 | DoOnCreate;
|
---|
826 | end;
|
---|
827 |
|
---|
828 | function TForm.ShowModal: Integer;
|
---|
829 | begin
|
---|
830 | Result := GetNativeForm.ShowModal;
|
---|
831 | end;
|
---|
832 |
|
---|
833 | procedure TForm.SetFocus;
|
---|
834 | begin
|
---|
835 | GetNativeForm.SetFocus;
|
---|
836 | end;
|
---|
837 |
|
---|
838 | procedure TForm.Close;
|
---|
839 | var
|
---|
840 | CloseAction: TCloseAction;
|
---|
841 | IsMainForm: Boolean;
|
---|
842 | begin
|
---|
843 | if (fsModal in FormState) and (ModalResult = 0) then
|
---|
844 | ModalResult := mrCancel
|
---|
845 | else
|
---|
846 | begin
|
---|
847 | if CloseQuery then
|
---|
848 | begin
|
---|
849 | // IsMainForm flag set if we are closing MainForm or its parent
|
---|
850 | IsMainForm := (Application.MainForm = Self) or (Self.IsParentOf(Application.MainForm));
|
---|
851 | // Prepare default close action
|
---|
852 | if FormStyle = fsMDIChild then
|
---|
853 | begin
|
---|
854 | CloseAction := caNone;
|
---|
855 | // TODO: mdi logic
|
---|
856 | end
|
---|
857 | else
|
---|
858 | begin
|
---|
859 | if IsMainForm then
|
---|
860 | CloseAction := caFree
|
---|
861 | else
|
---|
862 | CloseAction := caHide;
|
---|
863 | end;
|
---|
864 | // call event handler and let user modify CloseAction
|
---|
865 | DoClose(CloseAction);
|
---|
866 | // execute action according to close action
|
---|
867 | case CloseAction of
|
---|
868 | caHide: Hide;
|
---|
869 | caMinimize: WindowState := wsMinimized;
|
---|
870 | caFree:
|
---|
871 | begin
|
---|
872 | // if form is MainForm, then terminate the application
|
---|
873 | // the owner of the MainForm is the application,
|
---|
874 | // so the Application will take care of free-ing the form
|
---|
875 | // and Release is not necessary
|
---|
876 | if IsMainForm then
|
---|
877 | Application.Terminate
|
---|
878 | else
|
---|
879 | Release;
|
---|
880 | end;
|
---|
881 | end;
|
---|
882 | end;
|
---|
883 | end;
|
---|
884 | end;
|
---|
885 |
|
---|
886 | function TForm.CloseQuery: boolean;
|
---|
887 | begin
|
---|
888 | Result := True;
|
---|
889 | if Assigned(FOnCloseQuery) then
|
---|
890 | FOnCloseQuery(Self, Result);
|
---|
891 | end;
|
---|
892 |
|
---|
893 | procedure TForm.BringToFront;
|
---|
894 | begin
|
---|
895 | GetNativeForm.BringToFront;
|
---|
896 | end;
|
---|
897 |
|
---|
898 | procedure TForm.Release;
|
---|
899 | begin
|
---|
900 | Free;
|
---|
901 | end;
|
---|
902 |
|
---|
903 | // Init the component with an IDE resource
|
---|
904 | constructor TForm.Create(TheOwner: TComponent);
|
---|
905 | begin
|
---|
906 | //inherited;
|
---|
907 | //DebugLn(['TDpiForm.Create ', DbgSName(TheOwner)]);
|
---|
908 | GlobalNameSpace.BeginWrite;
|
---|
909 | try
|
---|
910 | CreateNew(TheOwner, 1); // this calls BeginFormUpdate, which is ended in AfterConstruction
|
---|
911 | if (ClassType <> TForm) and not (csDesigning in ComponentState) then begin
|
---|
912 | if not InitResourceComponent(Self, TDataModule) then begin
|
---|
913 | raise EResNotFound.Create('Resource missing for class ' + ClassName);
|
---|
914 | end;
|
---|
915 | end;
|
---|
916 | finally
|
---|
917 | GlobalNameSpace.EndWrite;
|
---|
918 | end;
|
---|
919 | ScreenChanged;
|
---|
920 | UpdateNativeControl;
|
---|
921 | end;
|
---|
922 |
|
---|
923 | constructor TForm.CreateNew(AOwner: TComponent; Num: Integer);
|
---|
924 | begin
|
---|
925 | inherited Create(AOwner);
|
---|
926 | Screen.AddForm(Self);
|
---|
927 | end;
|
---|
928 |
|
---|
929 | destructor TForm.Destroy;
|
---|
930 | begin
|
---|
931 | // TODO: Can't destroy directly?
|
---|
932 | TFormEx(NativeForm).OnMessage := nil;
|
---|
933 | FreeAndNil(NativeForm);
|
---|
934 |
|
---|
935 | Screen.RemoveForm(Self);
|
---|
936 | inherited;
|
---|
937 | end;
|
---|
938 |
|
---|
939 | { TScreen }
|
---|
940 |
|
---|
941 | procedure TScreen.SetDpi(AValue: Integer);
|
---|
942 | begin
|
---|
943 | if FDpi = AValue then Exit;
|
---|
944 | FDpi := AValue;
|
---|
945 | ScreenInfo.Dpi := Dpi;
|
---|
946 | UpdateForms;
|
---|
947 | end;
|
---|
948 |
|
---|
949 | function TScreen.GetWidth: Integer;
|
---|
950 | begin
|
---|
951 | Result := ScaleFromNative(LCLScreen.Width);
|
---|
952 | end;
|
---|
953 |
|
---|
954 | procedure TScreen.SetCursor(AValue: TCursor);
|
---|
955 | begin
|
---|
956 | LCLScreen.Cursor := AValue;
|
---|
957 | end;
|
---|
958 |
|
---|
959 | procedure TScreen.SetCursors(Index: Integer; AValue: HCURSOR);
|
---|
960 | begin
|
---|
961 | LCLScreen.Cursors[Index] := AValue;
|
---|
962 | end;
|
---|
963 |
|
---|
964 | function TScreen.GetHeight: Integer;
|
---|
965 | begin
|
---|
966 | Result := ScaleFromNative(LCLScreen.Height);
|
---|
967 | end;
|
---|
968 |
|
---|
969 | function TScreen.GetFormCount: Integer;
|
---|
970 | begin
|
---|
971 | Result := FForms.Count;
|
---|
972 | end;
|
---|
973 |
|
---|
974 | function TScreen.GetForms(Index: Integer): TForm;
|
---|
975 | begin
|
---|
976 | Result := FForms[Index];
|
---|
977 | end;
|
---|
978 |
|
---|
979 | procedure TScreen.AddForm(AForm: TForm);
|
---|
980 | begin
|
---|
981 | if AForm is TForm then begin
|
---|
982 | FForms.Add(AForm);
|
---|
983 | //Application.UpdateVisible;
|
---|
984 | end;
|
---|
985 | end;
|
---|
986 |
|
---|
987 | function TScreen.GetDesktopHeight: Integer;
|
---|
988 | begin
|
---|
989 | Result := ScaleFromNative(LCLScreen.DesktopHeight);
|
---|
990 | end;
|
---|
991 |
|
---|
992 | function TScreen.GetDesktopLeft: Integer;
|
---|
993 | begin
|
---|
994 | Result := ScaleFromNative(LCLScreen.DesktopLeft);
|
---|
995 | end;
|
---|
996 |
|
---|
997 | function TScreen.GetDesktopTop: Integer;
|
---|
998 | begin
|
---|
999 | Result := ScaleFromNative(LCLScreen.DesktopTop);
|
---|
1000 | end;
|
---|
1001 |
|
---|
1002 | function TScreen.GetDesktopWidth: Integer;
|
---|
1003 | begin
|
---|
1004 | Result := ScaleFromNative(LCLScreen.DesktopWidth);
|
---|
1005 | end;
|
---|
1006 |
|
---|
1007 | function TScreen.GetPrimaryMonitor: TMonitor;
|
---|
1008 | begin
|
---|
1009 | if not Assigned(FPrimaryMonitor) then begin
|
---|
1010 | FPrimaryMonitor := TMonitor.Create;
|
---|
1011 | FPrimaryMonitor.NativeMonitor := LCLScreen.PrimaryMonitor;
|
---|
1012 | end;
|
---|
1013 | Result := FPrimaryMonitor;
|
---|
1014 | end;
|
---|
1015 |
|
---|
1016 | procedure TScreen.RemoveForm(AForm: TForm);
|
---|
1017 | begin
|
---|
1018 | FForms.Remove(AForm);
|
---|
1019 | FPrevActiveForms.Remove(AForm);
|
---|
1020 | if AForm = FActiveForm then begin
|
---|
1021 | FActiveForm := nil;
|
---|
1022 | end;
|
---|
1023 | end;
|
---|
1024 |
|
---|
1025 | function TScreen.GetActiveForm: TForm;
|
---|
1026 | begin
|
---|
1027 | Result := FActiveForm;
|
---|
1028 | end;
|
---|
1029 |
|
---|
1030 | function TScreen.GetCursor: TCursor;
|
---|
1031 | begin
|
---|
1032 | Result := LCLScreen.Cursor;
|
---|
1033 | end;
|
---|
1034 |
|
---|
1035 | function TScreen.GetCursors(Index: Integer): HCURSOR;
|
---|
1036 | begin
|
---|
1037 | Result := LCLScreen.Cursors[Index];
|
---|
1038 | end;
|
---|
1039 |
|
---|
1040 | procedure TScreen.UpdateForms;
|
---|
1041 | var
|
---|
1042 | I: Integer;
|
---|
1043 | begin
|
---|
1044 | for I := 0 to FForms.Count - 1 do
|
---|
1045 | FForms[I].ScreenChanged;
|
---|
1046 | end;
|
---|
1047 |
|
---|
1048 | function TScreen.DisableForms(SkipForm: TForm; DisabledList: Classes.TList
|
---|
1049 | ): Classes.TList;
|
---|
1050 | begin
|
---|
1051 | Result := LCLScreen.DisableForms(SkipForm.GetNativeForm, DisabledList);
|
---|
1052 | end;
|
---|
1053 |
|
---|
1054 | procedure TScreen.EnableForms(var AFormList: Classes.TList);
|
---|
1055 | begin
|
---|
1056 | LCLScreen.EnableForms(AFormList);
|
---|
1057 | end;
|
---|
1058 |
|
---|
1059 | function TScreen.GetSystemDpi: Integer;
|
---|
1060 | begin
|
---|
1061 | Result := LCLScreen.PixelsPerInch;
|
---|
1062 | end;
|
---|
1063 |
|
---|
1064 | constructor TScreen.Create;
|
---|
1065 | begin
|
---|
1066 | FForms := TForms.Create;
|
---|
1067 | FForms.OwnsObjects := False;
|
---|
1068 | FPrevActiveForms := TForms.Create;
|
---|
1069 | FPrevActiveForms.OwnsObjects := False;
|
---|
1070 | // Froms.Screen.PixelsPerInch is not initialized at this point
|
---|
1071 | Dpi := 96;
|
---|
1072 | end;
|
---|
1073 |
|
---|
1074 | destructor TScreen.Destroy;
|
---|
1075 | begin
|
---|
1076 | FreeAndNil(FForms);
|
---|
1077 | FreeAndNil(FPrevActiveForms);
|
---|
1078 | if Assigned(FPrimaryMonitor) then
|
---|
1079 | FreeAndNil(FPrimaryMonitor);
|
---|
1080 | inherited;
|
---|
1081 | end;
|
---|
1082 |
|
---|
1083 | procedure TScreen.UpdateActiveFormFromNativeScreen;
|
---|
1084 | var
|
---|
1085 | I: Integer;
|
---|
1086 | F: TForm;
|
---|
1087 | begin
|
---|
1088 | if LCLScreen.ActiveForm = nil then FActiveForm := nil
|
---|
1089 | else begin
|
---|
1090 | for I := 0 to FormCount - 1 do begin
|
---|
1091 | F := Forms[I];
|
---|
1092 | if F.GetNativeForm = LCLScreen.ActiveForm then begin
|
---|
1093 | FActiveForm := F;
|
---|
1094 | Break;
|
---|
1095 | end;
|
---|
1096 | end;
|
---|
1097 | end;
|
---|
1098 | end;
|
---|
1099 |
|
---|
1100 | { TControlScrollBar }
|
---|
1101 |
|
---|
1102 | function TControlScrollBar.GetVisible: Boolean;
|
---|
1103 | begin
|
---|
1104 |
|
---|
1105 | end;
|
---|
1106 |
|
---|
1107 | procedure TControlScrollBar.SetVisible(AValue: Boolean);
|
---|
1108 | begin
|
---|
1109 |
|
---|
1110 | end;
|
---|
1111 |
|
---|
1112 | initialization
|
---|
1113 |
|
---|
1114 | RegisterPropertyToSkip(TForm, 'OldCreateOrder', 'Native compatibility property', '');
|
---|
1115 | RegisterPropertyToSkip(TForm, 'TextHeight', 'Native compatibility property', '');
|
---|
1116 | RegisterPropertyToSkip(TForm, 'Scaled', 'Native compatibility property', '');
|
---|
1117 | RegisterPropertyToSkip(TForm, 'TransparentColorValue', 'Native compatibility property', '');
|
---|
1118 | Screen := TScreen.Create;
|
---|
1119 | Application := TApplication.Create(nil);
|
---|
1120 |
|
---|
1121 | finalization
|
---|
1122 |
|
---|
1123 | FreeAndNil(Application);
|
---|
1124 | FreeAndNil(Screen);
|
---|
1125 |
|
---|
1126 | end.
|
---|
1127 |
|
---|