CJC Delphi 技巧馆's Archiver

cjc Posted at 2018-9-20 10:32

Check Multi Monitors

function CheckMultiMonitors: Boolean;
var
  MonitorCount: Integer;
begin
  MonitorCount := GetSystemMetrics(SM_CMONITORS);
  Result := (MonitorCount > 1) and Assigned(GetMonitorInfoFunc);
end;

function GetPrimaryMonitorWorkArea(const WorkArea: Boolean): TRect;
begin
  if WorkArea
  then
    SystemParametersInfo(SPI_GETWORKAREA, 0, @Result, 0)
  else
    Result := Rect(0, 0, Screen.Width, Screen.Height);
end;

function GetMonitorWorkAreaFromPoint(const P: TPoint; const WorkArea: Boolean): TRect;
var
  MonitorInfo: TMonitorInfo;
  MH: THandle;
begin
  if CheckMultiMonitors
  then
    begin
      MH := MonitorFromPoint(P, MONITOR_DEFAULTTONEAREST);
      MonitorInfo.cbSize := SizeOf(MonitorInfo);
      if GetMonitorInfoFunc(MH, @MonitorInfo)
      then
        begin
          if not WorkArea
          then
            Result := MonitorInfo.rcMonitor
          else
            Result := MonitorInfo.rcWork;
        end;
    end
  else
    Result := GetPrimaryMonitorWorkArea(WorkArea);
end;

function GetMonitorWorkArea(const W: HWND; const WorkArea: Boolean): TRect;
var
  MonitorInfo: TMonitorInfo;
  MH: THandle;
begin
  if CheckMultiMonitors
  then
    begin
      MH := MonitorFromWindowFunc(W, MONITOR_DEFAULTTONEAREST);
      MonitorInfo.cbSize := SizeOf(MonitorInfo);
      if GetMonitorInfoFunc(MH, @MonitorInfo)
      then
        begin
          if not WorkArea
          then
            Result := MonitorInfo.rcMonitor
          else
            Result := MonitorInfo.rcWork;
        end;
    end
  else
    Result := GetPrimaryMonitorWorkArea(WorkArea);
end;

Page: [1]
CJC好玩背单词最新版本 - 是目前最好的背单词软件,游戏好玩,功能强大,词库众多,还有真人语音,免费下载,免费试用 !

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.