Acquista i nostri libri consigliati su Amazon.it
+ Rispondi al messaggio
Pagina 1 di 2 12 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 11

attivare/disattivare la duplicazione dello schermo

  1. #1
    L'avatar di muttley005
    muttley005 ora è in linea Topo di biblioteca
    Ciao a tutti,
    devo riuscire ad attivare / disattivare da codice la duplicazione dello schermo.
    In pratica vorrei da codice fare la stessa cosa che si fa premendo FN+F8 (nel mio caso) o FN+F4 (in altri).

    Descrivo lo scenario:
    Ho una tavoletta wacom per la raccolta della firma e vorrei che si attivasse solo quando lo dico io duplicando ciò che ho al monitor principale. Non voglio estendere il monitor ma duplicarlo.

    M.

  2. #2
    L'avatar di @Alex
    @Alex non è in linea Moderatore Globale
    Hai provato se Sendkeys funziona....?
    ℹ️ Leggi di più su @Alex ...

  3. #3
    L'avatar di muttley005
    muttley005 ora è in linea Topo di biblioteca
    Ciao Alex, il sendkey avevo pensato di usarlo ma non trovo come fare per il FN (function)
    Ho anche cercato ma trovo solo le combinazioni che sfruttano:
    • CTRL ---> ^
    • ALT ---> %
    • SHIFT ---> +
    come da guida ms

    poi comunque non sarebbe il massimo perchè la combinazione cambia da marca a marca di pc.
    Certo potrei parametrizzarlo in un setup ma dubito che sarebbe molto carino da vedere come effetto.
    Vorrei intervenire in maniera diversa ... API? Registro?

    certo che se funzionasse con il sendkey sarebbe quantomeno un inizio

  4. #4
    L'avatar di muttley005
    muttley005 ora è in linea Topo di biblioteca
    ho trovato questo ma devo studiarlo
    https://stackoverflow.com/questions/...d-monitor-in-c

  5. #5
    L'avatar di @Alex
    @Alex non è in linea Moderatore Globale
    ℹ️ Leggi di più su @Alex ...

  6. #6
    L'avatar di muttley005
    muttley005 ora è in linea Topo di biblioteca
    Grazie Alex, non l'avevo trovato.
    Ho letto tutto attentamente e testato i vari codici postati e ora riesco
    con questa ...
    Option Compare Database
    Option Explicit
    
    Private Declare Function SendMessage Lib _
        "user32" Alias "SendMessageA" (ByVal hWnd As Long, _
        ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long
    
    Const SC_MONITORPOWER = &HF170&
    Public Const MONITOR_ON = -1&
    Public Const MONITOR_OFF = 2&
    Const WM_SYSCOMMAND = &H112
    
    Sub TurnMonitorOff()
           SendMessage Application.hWndAccessApp, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF
    End Sub
    
    Sub TurnMonitorOn()
           SendMessage Application.hWndAccessApp, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_ON
    End Sub
    
    ... a spegnere il monitor (ma li spegne entrambi, io vorrei disattivare solo il secondo, il duplicato)

    con questa ...
    Option Compare Database
    Option Explicit
    
    'Sources:
    'GetSystemMetrics function :            https://msdn.microsoft.com/en-us/library/windows/desktop/ms724385(v=vs.85).aspx
    'Using the GetSystemMetrics Function :  https://msdn.microsoft.com/en-us/library/aa227571(v=vs.60).aspx
    
    'Monitor references:
    'Multiple Display Monitors Reference :  https://msdn.microsoft.com/en-us/library/windows/desktop/dd145073(v=vs.85).aspx
    'GetMonitorInfo function:               https://msdn.microsoft.com/en-us/library/windows/desktop/dd144901(v=vs.85).aspx
    
    'Monitor Related:
    Const SM_CMONITORS = 80  'The number of display monitors on a desktop. For more information, see the Remarks section in this topic.
    Const SM_CXFULLSCREEN = 16  'The width of the client area for a full-screen window on the primary display monitor, in pixels. To get the coordinates of the portion of the screen that is not obscured by the system taskbar or by application desktop toolbars, call the SystemParametersInfo function with the SPI_GETWORKAREA value.
    Const SM_CXMAXIMIZED = 61  'The default width, in pixels, of a maximized top-level window on the primary display monitor.
    Const SM_CXSCREEN = 0  'The width of the screen of the primary display monitor, in pixels. This is the same value obtained by calling GetDeviceCaps as follows: GetDeviceCaps( hdcPrimaryMonitor, HORZRES).
    Const SM_CXVIRTUALSCREEN = 78  'The width of the virtual screen, in pixels. The virtual screen is the bounding rectangle of all display monitors. The SM_XVIRTUALSCREEN metric is the coordinates for the left side of the virtual screen.
    Const SM_CYFULLSCREEN = 17  'The height of the client area for a full-screen window on the primary display monitor, in pixels. To get the coordinates of the portion of the screen not obscured by the system taskbar or by application desktop toolbars, call the SystemParametersInfo function with the SPI_GETWORKAREA value.
    Const SM_CYMAXIMIZED = 62  'The default height, in pixels, of a maximized top-level window on the primary display monitor.
    Const SM_CYSCREEN = 1  'The height of the screen of the primary display monitor, in pixels. This is the same value obtained by calling GetDeviceCaps as follows: GetDeviceCaps( hdcPrimaryMonitor, VERTRES).
    Const SM_CYVIRTUALSCREEN = 79  'The height of the virtual screen, in pixels. The virtual screen is the bounding rectangle of all display monitors. The SM_YVIRTUALSCREEN metric is the coordinates for the top of the virtual screen.
    Const SM_SAMEDISPLAYFORMAT = 81  'Nonzero if all the display monitors have the same color format, otherwise, 0. Two displays can have the same bit depth, but different color formats. For example, the red, green, and blue pixels can be encoded with different numbers of bits, or those bits can be located in different places in a pixel color value.
    Const SM_XVIRTUALSCREEN = 76  'The coordinates for the left side of the virtual screen. The virtual screen is the bounding rectangle of all display monitors. The SM_CXVIRTUALSCREEN metric is the width of the virtual screen.
    Const SM_YVIRTUALSCREEN = 77  'The coordinates for the top of the virtual screen. The virtual screen is the bounding rectangle of all display monitors. The SM_CYVIRTUALSCREEN metric is the height of the virtual screen.
    
    
    Private Declare Function GetSystemMetrics Lib "user32" _
        (ByVal nIndex As Long) As Long
    
    
    Sub testGetSystemMetrics()
    
    Debug.Print "Monitor Related:"
    Debug.Print "SM_CMONITORS = " & GetSystemMetrics(SM_CMONITORS), "The number of display monitors on a desktop. For more information, see the Remarks section in this topic."
    Debug.Print "SM_CXFULLSCREEN = " & GetSystemMetrics(SM_CXFULLSCREEN), "The width of the client area for a full-screen window on the primary display monitor, in pixels. To get the coordinates of the portion of the screen that is not obscured by the system taskbar or by application desktop toolbars, call the SystemParametersInfo function with the SPI_GETWORKAREA value."
    Debug.Print "SM_CXMAXIMIZED = " & GetSystemMetrics(SM_CXMAXIMIZED), "The default width, in pixels, of a maximized top-level window on the primary display monitor."
    Debug.Print "SM_CXSCREEN = " & GetSystemMetrics(SM_CXSCREEN), "The width of the screen of the primary display monitor, in pixels. This is the same value obtained by calling GetDeviceCaps as follows: GetDeviceCaps( hdcPrimaryMonitor, HORZRES)."
    Debug.Print "SM_CXVIRTUALSCREEN = " & GetSystemMetrics(SM_CXVIRTUALSCREEN), "The width of the virtual screen, in pixels. The virtual screen is the bounding rectangle of all display monitors. The SM_XVIRTUALSCREEN metric is the coordinates for the left side of the virtual screen."
    Debug.Print "SM_CYFULLSCREEN = " & GetSystemMetrics(SM_CYFULLSCREEN), "The height of the client area for a full-screen window on the primary display monitor, in pixels. To get the coordinates of the portion of the screen not obscured by the system taskbar or by application desktop toolbars, call the SystemParametersInfo function with the SPI_GETWORKAREA value."
    Debug.Print "SM_CYMAXIMIZED = " & GetSystemMetrics(SM_CYMAXIMIZED), "The default height, in pixels, of a maximized top-level window on the primary display monitor."
    Debug.Print "SM_CYSCREEN = " & GetSystemMetrics(SM_CYSCREEN), "The height of the screen of the primary display monitor, in pixels. This is the same value obtained by calling GetDeviceCaps as follows: GetDeviceCaps( hdcPrimaryMonitor, VERTRES)."
    Debug.Print "SM_CYVIRTUALSCREEN = " & GetSystemMetrics(SM_CYVIRTUALSCREEN), "The height of the virtual screen, in pixels. The virtual screen is the bounding rectangle of all display monitors. The SM_YVIRTUALSCREEN metric is the coordinates for the top of the virtual screen."
    Debug.Print "SM_SAMEDISPLAYFORMAT = " & GetSystemMetrics(SM_SAMEDISPLAYFORMAT), "Nonzero if all the display monitors have the same color format, otherwise, 0. Two displays can have the same bit depth, but different color formats. For example, the red, green, and blue pixels can be encoded with different numbers of bits, or those bits can be located in different places in a pixel color value."
    Debug.Print "SM_XVIRTUALSCREEN = " & GetSystemMetrics(SM_XVIRTUALSCREEN), "The coordinates for the left side of the virtual screen. The virtual screen is the bounding rectangle of all display monitors. The SM_CXVIRTUALSCREEN metric is the width of the virtual screen."
    Debug.Print "SM_YVIRTUALSCREEN = " & GetSystemMetrics(SM_YVIRTUALSCREEN), "The coordinates for the top of the virtual screen. The virtual screen is the bounding rectangle of all display monitors. The SM_CYVIRTUALSCREEN metric is the height of the virtual screen."
    
    End Sub
    
    ... a rilevare alcuni parametri del monitor

    questa è un'altra ...
    Option Compare Database
    Option Explicit
    
    'Constants
    Public Const DD_Desktop = &H1
    Public Const DD_MultiDriver = &H2
    Public Const DD_Primary = &H4
    Public Const DD_Mirror = &H8
    Public Const DD_VGA = &H10
    Public Const DD_Removable = &H20
    Public Const DD_ModeSpruned = &H8000000
    Public Const DD_Remote = &H4000000
    Public Const DD_Disconnect = &H2000000
    
    Public Const DD_Active = &H1
    Public Const DD_Attached = &H2
    
    Public Const CCHDEVICENAME = 32
    Public Const CCHFORMNAME = 32
    
    Public Const ENUM_CURRENT_SETTINGS = -1
    Public Const ENUM_REGISTRY_SETTINGS = -2
    
    Public Const MONITOR_DEFAULTTONULL = 0
    Public Const MONITOR_DEFAULTTOPRIMARY = 1
    Public Const MONITOR_DEFAULTTONEAREST = 2
    
    'User Defined Types
    Private Type DisplayDevice
        cb As Long
        DeviceName As String * 32
        DeviceString As String * 128
        StateFlags As Long
        DeviceID As String * 128
        DeviceKey As String * 128
    End Type
    
    Private Type POINTL
        x As Long
        y As Long
    End Type
    
    Private Type DEVMODE
        DeviceName As String * CCHDEVICENAME
        SpecVersion As Integer
        DriverVersion As Integer
        Size As Integer
        DriverExtra As Integer
        Fields As Long
        Position As POINTL
        Scale As Integer
        Copies As Integer
        DefaultSource As Integer
        PrintQuality As Integer
        Color As Integer
        Duplex As Integer
        YResolution As Integer
        TTOption As Integer
        Collate As Integer
        FormName As String * CCHFORMNAME
        LogPixels As Integer
        BitsPerPel As Long
        PelsWidth As Long
        PelsHeight As Long
        DisplayFlags As Long
        DisplayFrequency As Long
    End Type
    
    Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
    End Type
    
    Private Type MonitorInfo
        cbSize As Long
        rcMonitor As RECT
        rcWork As RECT
        dwFlags As Long
    End Type
    
    'Declares
    Public Declare Function EnumDisplayDevices Lib "user32" Alias "EnumDisplayDevicesA" (ByVal lpDevice As String, _
        ByVal iDevNum As Long, lpDisplayDevice As DisplayDevice, dwFlags As Long) As Long
    Public Declare Function EnumDisplaySettingsEx Lib "user32" Alias "EnumDisplaySettingsExA" (ByVal lpszDeviceName As String, _
        ByVal iModeNum As Long, lpDevMode As DEVMODE, dwFlags As Long) As Long
    Public Declare Function MonitorFromPoint Lib "user32" (ByVal ptY As Long, ByVal ptX As Long, ByVal dwFlags As Long) As Long
    Public Declare Function GetMonitorInfo Lib "user32" Alias "GetMonitorInfoA" (ByVal hMonitor As Long, lpmi As MonitorInfo) As Long
    Public Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As String, ByVal iModeNum As Long, lpDevMode As Any) As Boolean
    Public Declare Function ChangeDisplaySettingsEx Lib "user32" Alias "ChangeDisplaySettingsExA" (lpszDeviceName As Any, _
        lpDevMode As Any, ByVal hWnd As Long, ByVal dwFlags As Long, lParam As Any) As Long
    
    
    'Public Parts that will be used
    Public Type Monitors
        Name As String
        Handle As Long
        x As Long
        y As Long
        Width As Long
        Height As Long
        DevString As String
        Detected As Boolean
    End Type
    
    Public PrimaryMon As Monitors
    Public SecondaryMon As Monitors
    
    Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
    'Declare Function GetSystemMetrics16 Lib "user" _
    'Alias "GetSystemMetrics" (ByVal nIndex As Integer) As Integer
    Public Const SM_CXSCREEN = 0
    Public Const SM_CYSCREEN = 1
    
    '------------------------------------------------------------------------
    Public vidwidth As Integer
    Public vidheight As Integer
    Dim Msg
    Dim ans
    Dim msg1
    Public Originalvidwidth As Integer 'stores original screen setting to use to restore later
    Public Originalvidheight As Integer 'stores original screen setting to use to restore later
    Public ResetScreen As Boolean
    
    
    Public Sub GetDisplays()
    Dim DispDev As DisplayDevice, MonDev As DisplayDevice 'holds device info/monitor info
    Dim DispDevInd As Long, MonDevInd As Long 'Index for the devices
    Dim MonMode As DEVMODE 'holds mode information for each monitor
    Dim hMonitor As Long 'holds handle to the correct monitor context
    Dim MonInfo As MonitorInfo
    
        'initialisations
        DispDev.cb = Len(DispDev)
        MonDev.cb = Len(MonDev)
        DispDevInd = 0: MonDevInd = 0
        PrimaryMon.Detected = False
        SecondaryMon.Detected = False
        
        Do While EnumDisplayDevices(vbNullString, DispDevInd, DispDev, 0) <> 0 'enumerate the graphics cards
            If Not CBool(DispDev.StateFlags And DD_Mirror) Then
                'if it is real
                Do While EnumDisplayDevices(DispDev.DeviceName, MonDevInd, MonDev, 0) <> 0 'iterate to the correct MonDev
                    If CBool(MonDev.StateFlags And DD_Active) Then Exit Do
                    MonDevInd = MonDevInd + 1
                Loop
                'if the device string is empty then its a default monitor
                If cCstr(MonDev.DeviceString) = "" Then
                    EnumDisplayDevices DispDev.DeviceName, 0, MonDev, 0
                    If cCstr(MonDev.DeviceString) = "" Then MonDev.DeviceString = "Default Monitor"
                End If
                'get information about the display's position and the current display mode
                MonMode.Size = Len(MonMode)
                If EnumDisplaySettingsEx(DispDev.DeviceName, ENUM_CURRENT_SETTINGS, MonMode, 0) = 0 Then
                    EnumDisplaySettingsEx DispDev.DeviceName, ENUM_REGISTRY_SETTINGS, MonMode, 0
                End If
            
                'get the monitor handle and workspace
                MonInfo.cbSize = Len(MonInfo)
                If CBool(DispDev.StateFlags And DD_Desktop) Then
                    'display is enabled. only enabled displays have a monitor handle
                    hMonitor = MonitorFromPoint(MonMode.Position.x, MonMode.Position.y, MONITOR_DEFAULTTONULL)
                    If hMonitor <> 0 Then
                        GetMonitorInfo hMonitor, MonInfo
                    End If
                End If
            End If
            If CBool(DispDev.StateFlags And DD_Desktop) Then 'if it is an active monitor
                If CBool(DispDev.StateFlags And DD_Primary) Then 'if itis the primary
                    With PrimaryMon
                        If MonDev.DeviceName <> "" Then .Name = cCstr(MonDev.DeviceName) Else .Name = cCstr(DispDev.DeviceName)
                        MsgBox "1: " & .Name
                        .Detected = True
                        .Handle = hMonitor
                        .DevString = cCstr(MonDev.DeviceString) & " on " & cCstr(DispDev.DeviceString)
                        MsgBox .DevString
                        .x = MonMode.Position.x
                        .y = MonMode.Position.y
                        .Width = MonMode.PelsWidth
                        .Height = MonMode.PelsHeight
                    End With
                Else
                    If Not SecondaryMon.Detected Then 'if it is a secondary (only do one)
                        With SecondaryMon
                            If MonDev.DeviceName <> "" Then .Name = cCstr(MonDev.DeviceName) Else .Name = cCstr(DispDev.DeviceName)
                            MsgBox "2: " & .Name
                            .Detected = True
                            .Handle = hMonitor
                            .DevString = cCstr(MonDev.DeviceString) & " on " & cCstr(DispDev.DeviceString)
                            MsgBox .DevString
                            .x = MonMode.Position.x
                            .y = MonMode.Position.y
                            .Width = MonMode.PelsWidth
                            .Height = MonMode.PelsHeight
                        End With
                    End If
                End If
            End If
            DispDevInd = DispDevInd + 1 'next graphics card
        Loop
    '
    End Sub
    
    Private Function cCstr(str As String) As String
    Dim i As Long
    Dim char As String
    Dim Returned As String
    '
        For i = 1 To Len(str)
            char = Mid(str, i, 1)
            If char <> vbNullChar And char <> vbNullString Then
                Returned = Returned & char
            End If
        Next
        cCstr = Returned
    '
    End Function
    
    Public Sub DetectDualMonitor()
        GetDisplays
        vidwidth = GetSystemMetrics(SM_CXSCREEN)
        vidheight = GetSystemMetrics(SM_CYSCREEN)
        If SecondaryMon.Detected = True Then
            If vidwidth = 1024 And vidheight = 768 Then
                Exit Sub
            Else
                ans = MsgBox("A secondary monitor connection has been detected." & vbCrLf & _
                    "If this is for a presentation projector, would you like this program" & vbCrLf & _
                    "to change your screen resolution to 1024 x 768 so that the" & vbCrLf & _
                    "Issue Sheet and TTM plans will fill a standard projection screen?", vbYesNo)
            End If
        End If
        If ans = vbYes Then
            'Replace '1024,768,32,75' with the resolution you want to switch to.
            'You can change the color pallete by changing the '32' below with '16' ect...
            'You can also change refresh rate
            Originalvidwidth = vidwidth
            Originalvidheight = vidheight
            ResetScreen = True
            ' ChangeScreenSettings 1024, 768, 32, 60
            ' DoCmd.Close acForm, "frmMainEntryMenu", acSaveNo
            ' DoCmd.OpenForm "frmMainEntryMenu"
            ' Forms!frmMainEntryMenu!LblRestore.Visible = True
            ' Forms!frmMainEntryMenu!btnRestoreScreen.Visible = True
            ' Forms!frmMainEntryMenu!btnSet1024x768.Visible = False
            ' Forms!frmMainEntryMenu!LblPresentation.Visible = False
        Else
            ' Forms!frmMainEntryMenu!LblRestore.Visible = False
            ' Forms!frmMainEntryMenu!btnRestoreScreen.Visible = False
            ' Forms!frmMainEntryMenu!btnSet1024x768.Visible = True
            ' Forms!frmMainEntryMenu!LblPresentation.Visible = True
            Exit Sub
        End If
    End Sub
    '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    'Private Const DISP_CHANGE_SUCESSFUL As Long = 0
    'Private Const DISP_CHANGE_RESTART As Long = 1
    'Private Const DISP_CHANGE_FAILED As Long = -1
    'Private Const DISP_CHANGE_BADMODE As Long = -2
    'Private Const DISP_CHANGE_NOTUPDATED As Long = -3
    'Private Const DISP_CHANGE_BADFLAGS As Long = -4
    'Private Const DISP_CHANGE_BADPARAM As Long = -5
    Public Sub SetExtDeskTop()
    Dim dmPrimary As DEVMODE
    Dim dmSecondary As DEVMODE
    Dim dmTemp As DEVMODE
    ' const DMBITSPERPEL AS Long =0x00040000
    
    Const szPrimaryDisplay As String = "\\.\DISPLAY1"
    Const szSecondaryDisplay As String = "\\.\DISPLAY2"
    Const CDS_UPDATEREGISTRY As Long = &H1
    Const CDS_NORESET As Long = &H10000000
    Const CDS_RESET As Long = &H40000000
    Const DM_BITSPERPEL As Long = &H40000
    Const DM_PELSWIDTH As Long = &H80000
    Const DM_PELSHEIGHT As Long = &H100000
    Const DM_POSITION As Long = &H20
    Const DM_DISPLAYFREQUENCY As Long = &H400000
    
    Dim lngExtSucc As Long
    
        dmPrimary.Size = Len(dmPrimary)
        dmTemp.Size = Len(dmTemp)
        dmSecondary.Size = Len(dmSecondary)
    
        If EnumDisplaySettings(szPrimaryDisplay, ENUM_CURRENT_SETTINGS, dmTemp) = False Then
            MsgBox "Primary Settings couldn't be enumerated."
        Else
            With dmTemp
                Debug.Print "BitsPerPel: " & .BitsPerPel
                Debug.Print "Collate: " & .Collate
                Debug.Print "Color: " & .Color
                Debug.Print "Copies: " & .Copies
                Debug.Print "DefaultSource: " & .DefaultSource
                Debug.Print "DeviceName: " & .DeviceName
                Debug.Print "DisplayFlags: " & .DisplayFlags
                Debug.Print "DisplayFrequency: " & .DisplayFrequency
                Debug.Print "DriverExtra: " & .DriverExtra
                Debug.Print "DriverVersion: " & .DriverVersion
                Debug.Print "Duplex: " & .Duplex
                Debug.Print "Fields: " & .Fields
                Debug.Print "FormName: " & .FormName
                Debug.Print "LogPixels: " & .LogPixels
                Debug.Print "PelsHeight: " & .PelsHeight
                Debug.Print "PelsWidth: " & .PelsWidth
                Debug.Print "Position.x: " & .Position.x
                Debug.Print "Position.y: " & .Position.y
                Debug.Print "PrintQuality: " & .PrintQuality
                Debug.Print "Scale: " & .Scale
                Debug.Print "Size: " & .Size
                Debug.Print "SpecVersion: " & .SpecVersion
                Debug.Print "TTOption: " & .TTOption
                Debug.Print "YResolution: " & .YResolution
            End With
            With dmPrimary
                .BitsPerPel = dmTemp.BitsPerPel
                .PelsHeight = dmTemp.PelsHeight
                .PelsWidth = dmTemp.PelsWidth
                .DisplayFrequency = dmTemp.DisplayFrequency
                .Fields = DM_BITSPERPEL Or DM_PELSWIDTH Or DM_PELSHEIGHT
                With .Position
                    .x = dmTemp.Position.x
                    .y = dmTemp.Position.y
                End With
                .Fields = .Fields Or DM_POSITION
            End With
            If dmPrimary.DisplayFrequency <> 0 Then _
                dmPrimary.Fields = dmPrimary.Fields Or DM_DISPLAYFREQUENCY
            With dmSecondary
                .BitsPerPel = dmPrimary.BitsPerPel
                .PelsHeight = dmPrimary.PelsHeight
                .PelsWidth = dmPrimary.PelsWidth
                .DisplayFrequency = 60
                .Fields = (DM_BITSPERPEL Or DM_PELSWIDTH Or DM_PELSHEIGHT)
                If .DisplayFrequency <> 0 Then _
                    .Fields = .Fields Or DM_DISPLAYFREQUENCY
                With .Position
                    .x = dmPrimary.PelsWidth + 1
                    .y = 0
                End With
                .Fields = .Fields Or DM_POSITION
            End With
        
        ' lngExtSucc = ChangeDisplaySettingsEx(szPrimaryDisplay, _
        ' dmPrimary, 0&, UPDATEREGISTRY Or NORESET, 0&)
        '
        ' MsgBox lngExtSucc
        
            If ChangeDisplaySettingsEx(szPrimaryDisplay, _
                    dmPrimary, 0&, CDS_UPDATEREGISTRY Or CDS_NORESET, 0&) = 0 Then
                If ChangeDisplaySettingsEx(szSecondaryDisplay, _
                        dmSecondary, 0&, CDS_UPDATEREGISTRY Or CDS_NORESET, 0&) = 0 Then
                    If ChangeDisplaySettingsEx(vbNullString, _
                            vbNull, 0&, 0&, 0&) = 0 Then
                        lngExtSucc = ChangeDisplaySettingsEx(szPrimaryDisplay, dmPrimary, _
                            vbNull, CDS_UPDATEREGISTRY Or CDS_RESET, 0&)
                        MsgBox "Extended Desktop Set Successfully"
                    Else
                        MsgBox "Final CDS call failed"
                    End If
                Else
                    MsgBox "Second CDS call failed"
                End If
            Else
                MsgBox "First CDS call failed"
            End If
        End If
    End Sub
    
    ... ma non funziona correttamente, nel senso che la chiamata alla ChangeDisplaySettingsEx non ha esito positivo.

    Alla fine del 3D del tuo link l'autore (Isladog) ha scritto di aver risolto in una maniera completamente diversa ma ahimè senza postare alcun altro suggerimento

  7. #7
    L'avatar di muttley005
    muttley005 ora è in linea Topo di biblioteca
    non vorrei cadere nel crossposting quindi ci tengo ad informare il forum che ho contattato l'autore del link postato da Alex e stiamo proseguendo la discussione qui
    Vorrei tenere aperto anche questo 3D per poter eventualmente comunicare la soluzione ... se ne verrò a capo ma a sto punto inizio ad avere dei dubbi.

    Riepilogando vorrei avere 2 monitor in mod. duplicato e poter "spegnere" il secondo e "riaccenderlo" all'esigenza.
    Volendo spiegare meglio, attualmente un mio software sfrutta un dispositivo di raccolta firma digitale che si attiva all'invio di un comando lanciato dal mio programma e si disattiva alla conclusione della firma.
    Ora il cliente ha voluto cambiare dispositivo e passare ad una tavoletta wacom più evoluta in cui poter anche visualizzare per intero il documento da firmare. Il problema è che non può rimanere sempre attiva la tavoletta e questa non è possibile pensare che venga continuamente passata dal personale dell'accettazione agli utenti che dovranno firmare e non posso nemmeno pensare di mettere la tavoletta in modalità estesa perchè sarebbe poco pratico per loro.

    Chiaro che se qualcuno volesse continuare ad aiutarmi anche qui sarebbe cosa BEN gradita

    Grazie

  8. #8
    L'avatar di @Alex
    @Alex non è in linea Moderatore Globale
    Direi che hai fatto uso perfetto del CrossPost, certo hai fatto Necroing nell'altro

    Io purtroppo non saprei come aiutarti non potendo replicare la situazione.
    ℹ️ Leggi di più su @Alex ...

  9. #9
    L'avatar di willy55
    willy55 non è in linea Scribacchino
    Se devi impostare una sequenza di tasti che non siano supportati dalla istruzione Sendkey (nel particolare il tasto Windows, che possiamo trovare a destra e/o sinistra della tastiera, da abbinare con altri come Win+F8 , Win+F4 per passare al secondo monitor o aggiungerlo con Win+P)
    https://support.microsoft.com/it-it/...e-6fb9b8b636f1
    Puoi impiegare le API ed in particolar modo la sub Keybd_event agendo sulle possibili combinazioni di tasti.
    Ad esempio, giusto per dire:
    VK_LWIN 5B Left Windows key (Microsoft Natural Keyboard)
    VK_RWIN 5C Right Windows key (Microsoft Natural Keyboard)
    VK_APPS 5D Applications key (Microsoft Natural Keyboard)
    che puoi estrapolare nei link sottoriportati:
    https://www.vbforums.com/showthread....essage-Problem
    http://117.239.19.55:8080/xmlui/bits...=1&isAllowed=y
    https://www.ms-office-forum.net/foru...36&postcount=7
    https://www.vb-paradise.de/index.php...-mit-sendkeys/
    https://www.mrexcel.com/board/thread...thanks.747164/


    Aggiungo dei link che possono essere quale "spunto" per avere degli ulteriori esempi (oltre alle funzionalità già postate) nel caso si abbia un secondo monitor:
    Dual Monitor Setting in VBA
    https://www.codeproject.com/Question...Desktop-in-VBA
    https://www.vbforums.com/showthread....second-monitor
    https://www.tek-tips.com/viewthread.cfm?qid=1669894
    https://www.tek-tips.com/viewthread.cfm?qid=1779630
    https://stackoverflow.com/questions/...t-slideshow-is
    https://www.tek-tips.com/viewthread.cfm?qid=1551016
    https://www.tek-tips.com/viewthread.cfm?qid=520283
    https://www.devhut.net/2019/02/16/vb...f-the-monitor/
    ℹ️ Leggi di più su willy55 ...

  10. #10
    L'avatar di muttley005
    muttley005 ora è in linea Topo di biblioteca
    Quote Originariamente inviato da @Alex Visualizza il messaggio
    Direi che hai fatto uso perfetto del CrossPost, certo hai fatto Necroing nell'altro

    Io purtroppo non saprei come aiutarti non potendo replicare la situazione.
    si vecchiotto l'altro ehehe

+ Rispondi al messaggio
Pagina 1 di 2 12 ultimoultimo

Potrebbero interessarti anche ...

  1. Come attivare o disattivare un tasto con access
    Da A.Maurizio nel forum Microsoft Access
    Risposte: 5
    Ultimo Post: 15-02-2020, 08:36
  2. Risposte: 3
    Ultimo Post: 23-08-2019, 18:02
  3. Risolto: Attivare/disattivare caps lock da codice
    Da krossk2 nel forum Visual Basic .Net
    Risposte: 1
    Ultimo Post: 26-02-2011, 16:22
  4. Risposte: 7
    Ultimo Post: 04-01-2011, 16:44
  5. Disattivare/Attivare musica pag web
    Da Shumy300 nel forum HTML, CSS e JavaScript
    Risposte: 3
    Ultimo Post: 26-01-2005, 13:30