so, hier bei mir funktioniert das nun mit 2 Monitoren. Position und Orientierung wird auch wieder hergestellt.
bei mir ist 1 Monitor Hochkant, das ist display 2, und der 2 Monitor im Querformat ist Primär. So wird das auch wiederhergestellt. Mal schauen wie das nachher zuhause mit den 3 Monitoren klappt
Najo, bei mir geht es hauptsächlich um die Kompatibilität für ältere spiele. Da die meist mit Multi Monitoren Systemen nicht zurecht kommen. Bild Bleibt Schwarz oder es startet. Erweiterten Monitor ausgeschaltet und das XY Game Startet.
In dem Code werden die Pseudo Display werden übersprungen und Displays die nicht aktiv sind
Code: Alles auswählen
; 0x00000001 DISPLAY_DEVICE_ATTACHED_TO_DESKTOP
; 0x00000004 DISPLAY_DEVICE_PRIMARY_DEVICE
; 0x00000008 DISPLAY_DEVICE_MIRRORING_DRIVER
[size=85]Procedure ZeroMemory(adr,len)
Protected i
For i=0 To len-1 : PokeB(adr+i,0) :Next
EndProcedure
Procedure DisplaySwitch(iState=0)
Protected DispNum = 0, Result = 0, FoundSecondaryDisp = #False,i = 0, szTemp$ = Space(200)
Define DisplayDevice.DISPLAY_DEVICE
;// initialize DisplayDevice
ZeroMemory(@DisplayDevice, SizeOf(DisplayDevice));
DisplayDevice\cb = SizeOf(DISPLAY_DEVICE)
;// get all display devices
While (EnumDisplayDevices_(0, DispNum, @DisplayDevice, 0))
MonitorDevice$ = PeekS(@DisplayDevice + OffsetOf(DISPLAY_DEVICE\DeviceName), SizeOf(DISPLAY_DEVICE\DeviceName))
;////////////////////////////////////////////////////////////////////////////
MonitorFlag = PeekA(@DisplayDevice + OffsetOf(DISPLAY_DEVICE\StateFlags))
Select MonitorFlag
Case 1
;/****************************************************************************
If (iState=0) And Not (DisplayDevice\StateFlags & #DISPLAY_DEVICE_PRIMARY_DEVICE)
Define DevMode.DEVMODE
ZeroMemory(@DevMode, SizeOf(DevMode))
DevMode\dmSize = SizeOf(DEVMODE)
DevMode\dmDriverExtra = 0
EnumDisplaySettings_(@DisplayDevice\DeviceName,#ENUM_CURRENT_SETTINGS,@DevMode)
Debug "Monitor : "+PeekS(@DisplayDevice\DeviceName,32)
Debug "Monitor Flag : "+DisplayDevice\StateFlags
Debug "Monitor HZ : "+DevMode\dmDisplayFrequency
Debug "Monitor Bits : "+DevMode\dmBitsPerPel
Debug "Monitor Width : "+DevMode\dmPelsWidth
Debug "Monitor Height: "+DevMode\dmPelsHeight
Debug "Monitor Pos X : "+Str(DevMode\dmOrientation+DevMode\dmPaperSize<<16) ; the default definition in purebasic didn't include the onion, well, this works as well
Debug "Monitor Pos Y : "+Str(DevMode\dmPaperLength+DevMode\dmPaperWidth<<16)
Debug "Monitor Orien : "+DevMode\dmOrientation
Debug "Monitor Paper : "+DevMode\dmPaperLength
DevMode\dmFields = #DM_PELSWIDTH |
#DM_PELSHEIGHT |
#DM_BITSPERPEL |
#DM_POSITION |
#DM_DISPLAYFLAGS |
#DM_DISPLAYFREQUENCY
DevMode\dmPelsWidth = 0
DevMode\dmPelsHeight= 0
Debug "Erweiterten Monitor ausschalten: "+MonitorDevice$
Result = ChangeDisplaySettingsEx_(MonitorDevice$,DevMode,0,#CDS_UPDATEREGISTRY,0)
Select Result
Case 0
Debug "Schalte "+MonitorDevice$+ " aus: #DISP_CHANGE_SUCCESSFUL"
ChangeDisplaySettings_(@DevMode, 1)
Case -2
Debug "Schalte "+MonitorDevice$+ " aus: #DISP_CHANGE_BADMODE"
Case -5
Debug "Schalte "+MonitorDevice$+ " aus: #DISP_CHANGE_BADPARAM"
Case -1
Debug "Schalte "+MonitorDevice$+ " aus: #DISP_CHANGE_FAILED"
Case 1
Debug "Schalte "+MonitorDevice$+ " aus: #DISP_CHANGE_NOTUPDATED"
EndSelect
;//////////////////////////////////////////////////////////////////////////////////////////////////
EndIf
Case 4
;Debug MonitorDevice$+" is the primary display device."
Case 8
;Debug MonitorDevice$+" is a pseudo-device."
Default
If (iState=1) And (DisplayDevice\StateFlags <> 0) And Not (DisplayDevice\StateFlags & #DISPLAY_DEVICE_PRIMARY_DEVICE)
Define defaultMode.DEVMODE
ZeroMemory(@defaultMode, SizeOf(defaultMode))
defaultMode\dmSize = SizeOf(DEVMODE)
EnumDisplaySettings_(@DisplayDevice\DeviceName,#ENUM_REGISTRY_SETTINGS,@defaultMode)
defaultMode\dmFields = #DM_POSITION
Debug "Monitor : "+PeekS(@DisplayDevice\DeviceName,32)
Debug "Monitor Flag : "+DisplayDevice\StateFlags
Debug "Monitor HZ : "+defaultMode\dmDisplayFrequency
Debug "Monitor Bits : "+defaultMode\dmBitsPerPel
Debug "Monitor Width : "+defaultMode\dmPelsWidth
Debug "Monitor Height: "+defaultMode\dmPelsHeight
Debug "Monitor Pos X : "+Str(defaultMode\dmOrientation+defaultMode\dmPaperSize<<16) ; the default definition in purebasic didn't include the onion, well, this works as well
Debug "Monitor Pos Y : "+Str(defaultMode\dmPaperLength+defaultMode\dmPaperWidth<<16)
Debug "Monitor Oritn : "+defaultMode\dmOrientation
Debug "Monitor Paper : "+defaultMode\dmPaperLength
If Not (DisplayDevice\StateFlags & #DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)
Debug "Erweiterten Monitor einschalten: "+MonitorDevice$
Result = ChangeDisplaySettingsEx_(MonitorDevice$,defaultMode,0,#CDS_UPDATEREGISTRY,0)
Select Result
Case 0
Debug "Schalte "+MonitorDevice$+ " ein: #DISP_CHANGE_SUCCESSFUL"
ChangeDisplaySettings_(0, 1)
Case -2
Debug "Schalte "+MonitorDevice$+ " ein: #DISP_CHANGE_BADMODE"
Case -5
Debug "Schalte "+MonitorDevice$+ " ein: #DISP_CHANGE_BADPARAM"
Case -1
Debug "Schalte "+MonitorDevice$+ " ein: #DISP_CHANGE_FAILED"
Case 1
Debug "Schalte "+MonitorDevice$+ " ein: #DISP_CHANGE_NOTUPDATED"
EndSelect
EndIf
EndIf
EndSelect
;//////////////////////////////////////////////////////////////////////////
;// Reinit DisplayDevice just To be extra clean
ZeroMemory(@DisplayDevice, SizeOf(DisplayDevice));
DisplayDevice\cb = SizeOf(DISPLAY_DEVICE)
DispNum = DispNum+1
Wend; // End While For all display devices
EndProcedure
DisplaySwitch(0)
MessageRequester("Test","Displays wieder einschalten")
Debug #CRLF$
DisplaySwitch(1)