Verfügbare Bildschirmgröße

Deutschsprachiges X#-Forum – German language forum

Moderator: wriedmann

Post Reply
lagraf
Posts: 417
Joined: Thu Jan 18, 2018 9:03 am

Verfügbare Bildschirmgröße

Post by lagraf »

Hallo,
wie kann ich die verfügbare Bildschirmfläche (Breite und Höhe) in VO 2.8 ermitteln?

Code: Select all

hScrDC := CreateDC(Cast2Psz("DISPLAY"), NULL_PSZ, NULL_PSZ , NULL_PSZ )
GetDeviceCaps(hScrDC, HORZRES)
GetDeviceCaps(hScrDC, VERTRES)
bestimmt die gesamte Bildschirmgröße. Ich benötige aber den verfügbaren Platz (abzüglich Taskleiste unten oder anderswo platziert).
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am

Verfügbare Bildschirmgröße

Post by Karl-Heinz »

Hallo Franz,

Eine Suche findet das hier:

https://docs.microsoft.com/en-us/window ... etersinfoa

[...]
SPI_GETWORKAREA
0x0030

Retrieves the size of the work area on the primary display monitor. The work area is the portion of the screen not obscured by the system taskbar or by application desktop toolbars
[...]

Code: Select all

LOCAL struRect IS _winRECT 

IF SystemParametersInfo(SPI_GETWORKAREA, 0, @struRect, 0)
 
 ?  struRect.Top , struRect.Bottom , struRect.Left, struRect.Right

ENDIF		
Gruß
Karl-Heinz
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am

Verfügbare Bildschirmgröße

Post by Karl-Heinz »

Hallo Franz,

wahrscheinlich wäre es besser gleich die erwähnte GetMonitorInfo() zu verwenden.

Code: Select all

To get the work area of a monitor other than the primary display monitor, call the GetMonitorInfo function.
Ich habe momentan keinen ZUgriff auf einen zweiten Monitor um das zu überprüfen, aber falls die Anwendung mehrheitlich ;-) auf einem zweiten Monitor angezeigt wird würde a[1] und a[2] höchstwahrscheinlich andere Werte als SystemParametersInfo() anzeigen, auf jeden Fall müsste a[3] aber false beinhalten.

Code: Select all

LOCAL struRect IS _winrect
LOCAL a AS ARRAY	

	a := MonitorInfos ( GetDesktopWindow() )
	? a [1] , a [2]  , "primary monitor ?", a [3]  

 	SystemParametersInfo(SPI_GETWORKAREA, 0, @struRect, 0)
 
       ?  struRect.bottom , struRect.right

Code: Select all

STRUCTURE _winMONITORINFO 
	MEMBER cbSize AS DWORD
	MEMBER rcMonitor IS _winrect  
	MEMBER rcWork IS _winrect
	MEMBER dwFlags AS DWORD  
	
_DLL FUNCTION MonitorFromWindow ( hwnd AS PTR , dwFlags AS DWORD ) AS PTR PASCAL:User32.MonitorFromWindow

_DLL FUNCTION GetMonitorInfo ( hMonitor AS PTR, lpmi AS _winMONITORINFO ) AS LOGIC PASCAL:User32.GetMonitorInfoA
  
DEFINE MONITORINFOF_PRIMARY := 0x00000001
   
FUNCTION MonitorInfos ( hwnd AS PTR ) AS ARRAY PASCAL   
LOCAL struInfo IS _winMONITORINFO 
LOCAL hMonitor AS PTR 
  
	hMonitor := MonitorFromWindow( hwnd, MONITOR_DEFAULTTONEAREST )

	struInfo.cbSize := _SIZEOF(_winMONITORINFO)
	
	GetMonitorInfo( hMonitor, @struInfo) 
	
	RETURN { struInfo.rcWork.bottom - struInfo.rcWork.top ,  struInfo.rcWork.right - struInfo.rcWork.Left , struInfo.dwFlags ==  MONITORINFOF_PRIMARY }  
Gruß
Karl-Heinz
lagraf
Posts: 417
Joined: Thu Jan 18, 2018 9:03 am

Verfügbare Bildschirmgröße

Post by lagraf »

Hallo Karl-Heinz,
danke für deinen Code!

Die Anwendung läuft ausschließlich auf einem System mit 1 Monitor, sodaß die erste Variante genügen wird. Ich selber habe auch nur 1 Monitor, kanns daher auch nicht für mehrere Monitore probieren.
Post Reply