Note that there are some explanatory texts on larger screens.

plurals
  1. POGet current/native screen resolution of all monitors in Delphi (DirectX)
    text
    copied!<p>our delphi application can have multiple DirectX windows, often on multiple screens. up to now the user had to specify the fullscreen resolution using a dropdown with the supported resolutions. it would be very nice, if he could use a setting like 'current' which would be the resolution of the screen on which the window is.</p> <p>we are using delphi with clootie directX headers. can someone give me a hint, how i would write a method using directX, winAPI or delphi methods to get the resolution of the current screen on which the window is?</p> <p>kind regards, thalm</p> <p><strong>Final Solution:</strong></p> <p>ok, delphi 2007 MultiMon.pas returns crap for GetMonitorInfo, <a href="http://www.koders.com/delphi/fid54D3A0B686F2428E142E99EA9661BBF29A4D516B.aspx?s=md5" rel="nofollow">so i found</a> this method, which works for me, using the winAPI directly:</p> <pre><code>function GetRectOfMonitorContainingRect(const R: TRect): TRect; { Returns bounding rectangle of monitor containing or nearest to R } type HMONITOR = type THandle; TMonitorInfo = record cbSize: DWORD; rcMonitor: TRect; rcWork: TRect; dwFlags: DWORD; end; const MONITOR_DEFAULTTONEAREST = $00000002; var Module: HMODULE; MonitorFromRect: function(const lprc: TRect; dwFlags: DWORD): HMONITOR; stdcall; GetMonitorInfo: function(hMonitor: HMONITOR; var lpmi: TMonitorInfo): BOOL; stdcall; M: HMONITOR; Info: TMonitorInfo; begin Module := GetModuleHandle(user32); MonitorFromRect := GetProcAddress(Module, 'MonitorFromRect'); GetMonitorInfo := GetProcAddress(Module, 'GetMonitorInfoA'); if Assigned(MonitorFromRect) and Assigned(GetMonitorInfo) then begin M := MonitorFromRect(R, MONITOR_DEFAULTTONEAREST); Info.cbSize := SizeOf(Info); if GetMonitorInfo(M, Info) then begin Result := Info.rcMonitor; Exit; end; end; Result := GetRectOfPrimaryMonitor(True); end; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload