mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-17 14:49:28 +02:00
LCL: Refactoring, combine identical code in TScreen to a function.
git-svn-id: trunk@54465 -
This commit is contained in:
parent
d3f3c58edc
commit
93da17aa07
@ -1068,6 +1068,8 @@ type
|
||||
procedure SetIconFont(const AValue: TFont);
|
||||
procedure SetMenuFont(const AValue: TFont);
|
||||
procedure SetSystemFont(const AValue: TFont);
|
||||
function UpdatedMonitor(AHandle: HMONITOR; ADefault: TMonitorDefaultTo;
|
||||
AErrorMsg: string): TMonitor;
|
||||
procedure UpdateLastActive;
|
||||
procedure RestoreLastActive;
|
||||
procedure AddHandler(HandlerType: TScreenNotification;
|
||||
|
@ -413,6 +413,22 @@ begin
|
||||
FreeAndNil(AFormList);
|
||||
end;
|
||||
|
||||
function TScreen.UpdatedMonitor(AHandle: HMONITOR; ADefault: TMonitorDefaultTo;
|
||||
AErrorMsg: string): TMonitor;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
Result := nil;
|
||||
if (AHandle = 0) and (ADefault = mdNull) then
|
||||
Exit;
|
||||
// the user expects some monitor but handle wasn't found -> the monitor list has probably changed
|
||||
UpdateMonitors;
|
||||
for i := 0 to MonitorCount - 1 do
|
||||
if Monitors[i].Handle = AHandle then
|
||||
Exit(Monitors[i]);
|
||||
RaiseGDBException(AErrorMsg); // internal error
|
||||
end;
|
||||
|
||||
function TScreen.MonitorFromPoint(const Point: TPoint;
|
||||
MonitorDefault: TMonitorDefaultTo): TMonitor;
|
||||
var
|
||||
@ -431,17 +447,7 @@ begin
|
||||
Result := MonitorFromRect(R, MonitorDefault);
|
||||
end
|
||||
else
|
||||
if (MonitorHandle = 0) and (MonitorDefault = mdNull) then
|
||||
Result := nil
|
||||
else
|
||||
begin
|
||||
// the user expects some monitor but handle wasn't found -> the monitor list has probably changed
|
||||
UpdateMonitors;
|
||||
for i := 0 to MonitorCount - 1 do
|
||||
if Monitors[i].Handle = MonitorHandle then
|
||||
Exit(Monitors[i]);
|
||||
RaiseGDBException('TScreen.MonitorFromPoint'); // internal error
|
||||
end;
|
||||
Result := UpdatedMonitor(MonitorHandle, MonitorDefault, 'TScreen.MonitorFromPoint');
|
||||
end;
|
||||
|
||||
function TScreen.MonitorFromRect(const Rect: TRect;
|
||||
@ -485,28 +491,14 @@ begin
|
||||
end;
|
||||
end;
|
||||
if Result = nil then
|
||||
begin
|
||||
if MonitorDefault = mdPrimary then
|
||||
Result := PrimaryMonitor
|
||||
else
|
||||
if MonitorDefault = mdNull then
|
||||
Result := nil
|
||||
else
|
||||
Result := Nearest;
|
||||
end;
|
||||
case MonitorDefault of
|
||||
mdPrimary: Result := PrimaryMonitor;
|
||||
mdNull : Result := nil;
|
||||
mdNearest: Result := Nearest;
|
||||
end;
|
||||
end
|
||||
else
|
||||
if (MonitorHandle = 0) and (MonitorDefault = mdNull) then
|
||||
Result := nil
|
||||
else
|
||||
begin
|
||||
// the user expects some monitor but handle wasn't found -> the monitor list has probably changed
|
||||
UpdateMonitors;
|
||||
for i := 0 to MonitorCount - 1 do
|
||||
if Monitors[i].Handle = MonitorHandle then
|
||||
Exit(Monitors[i]);
|
||||
RaiseGDBException('TScreen.MonitorFromRect'); // internal error
|
||||
end;
|
||||
Result := UpdatedMonitor(MonitorHandle, MonitorDefault, 'TScreen.MonitorFromRect');
|
||||
end;
|
||||
|
||||
function TScreen.MonitorFromWindow(const Handle: THandle;
|
||||
@ -526,17 +518,7 @@ begin
|
||||
Result := MonitorFromRect(R, MonitorDefault);
|
||||
end
|
||||
else
|
||||
if (MonitorHandle = 0) and (MonitorDefault = mdNull) then
|
||||
Result := nil
|
||||
else
|
||||
begin
|
||||
// the user expects some monitor but handle wasn't found -> the monitor list has probably changed
|
||||
UpdateMonitors;
|
||||
for i := 0 to MonitorCount - 1 do
|
||||
if Monitors[i].Handle = MonitorHandle then
|
||||
Exit(Monitors[i]);
|
||||
RaiseGDBException('TScreen.MonitorFromWindow'); // internal error
|
||||
end;
|
||||
Result := UpdatedMonitor(MonitorHandle, MonitorDefault, 'TScreen.MonitorFromWindow');
|
||||
end;
|
||||
|
||||
procedure GetScreenFontsList(FontList: TStrings);
|
||||
|
Loading…
Reference in New Issue
Block a user