File: monitor.inc

package info (click to toggle)
lazarus 4.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 275,760 kB
  • sloc: pascal: 2,341,904; xml: 509,420; makefile: 348,726; cpp: 93,608; sh: 3,387; java: 609; perl: 297; sql: 222; ansic: 137
file content (103 lines) | stat: -rw-r--r-- 2,221 bytes parent folder | download | duplicates (6)
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
{%MainUnit ../forms.pp}

{******************************************************************************
                                  TMonitor
 ******************************************************************************

 *****************************************************************************
  This file is part of the Lazarus Component Library (LCL)

  See the file COPYING.modifiedLGPL.txt, included in this distribution,
  for details about the license.
 *****************************************************************************

}

{ TMonitor }

function TMonitor.GetInfo(out Info: TMonitorInfo): Boolean;
begin
  Info.cbSize := SizeOf(TMonitorInfo);
  Result := GetMonitorInfo(Handle, @Info);
end;

function TMonitor.GetLeft: Integer;
begin
  with GetBoundsRect do
    Result := Left;
end;

function TMonitor.GetPixelsPerInch: Integer;
var
  X, Y: UINT;
begin
  if WidgetSet.GetDpiForMonitor(FHandle, MDT_EFFECTIVE_DPI, X, Y)=S_OK then
    Result := X
  else
    Result := Screen.PixelsPerInch;
end;

function TMonitor.GetHeight: Integer;
begin
  with GetBoundsRect do
    Result := Bottom - Top;
end;

function TMonitor.GetTop: Integer;
begin
  with GetBoundsRect do
    Result := Top;
end;

function TMonitor.GetWidth: Integer;
begin
  with GetBoundsRect do
    Result := Right - Left;
end;

function TMonitor.GetBoundsRect: TRect;
var
  Info: TMonitorInfo;
begin
  if GetInfo(Info) then
    Result := Info.rcMonitor
  else
    Result := Rect(0, 0, 0, 0);
end;

function TMonitor.GetWorkareaRect: TRect;
var
  Info: TMonitorInfo;
begin
  if GetInfo(Info) then
    Result := Info.rcWork
  else
    Result := Rect(0, 0, 0, 0);
end;

function TMonitor.GetPrimary: Boolean;
var
  Info: TMonitorInfo;
begin
  Result := GetInfo(Info) and (Info.dwFlags and MONITORINFOF_PRIMARY <> 0)
end;

{ TMonitorList }

function TMonitorList.GetItem(AIndex: Integer): TMonitor;
begin
  Result := TMonitor(inherited Get(AIndex));
end;

procedure TMonitorList.SetItem(AIndex: Integer; const AValue: TMonitor);
begin
  inherited Put(AIndex, AValue)
end;

procedure TMonitorList.Notify(Ptr: Pointer; Action: TListNotification);
begin
  if Action = lnDeleted then
    TMonitor(Ptr).Free;
end;

// included by forms.pp