Secondary Monitors

Does anyone know a software way to dim secondary monitors while keeping the main display screen completely bright? I researched some existing software, but most of them will only smooth out all monitors (or only primary ones). I feel this may be a change in the Windows registry, perhaps. (This will be for the Windows 7 platform). Even if someone can point me to registry entries that can be changed for screen brightness levels. I think this is handled in the OS, and not always on the monitor itself.

Any help is appreciated!

+3
source share
3 answers
+1

, , , , , , 50% . , , : WPF? Win32? Qt?

0

, . Visual Studio 2010 VB.NET, ? , - Codeproject

Imports System.Runtime.InteropServices


Public Class Form1

Public Enum GWL As Integer
    ExStyle = -20
End Enum

Public Enum WS_EX As Integer
    Transparent = &H20
    Layered = &H80000
End Enum

Public Enum LWA As Integer
    ColorKey = &H1
    Alpha = &H2
End Enum

<DllImport("user32.dll", EntryPoint:="GetWindowLong")> _
Public Shared Function GetWindowLong( _
    ByVal hWnd As IntPtr, _
    ByVal nIndex As GWL _
        ) As Integer
End Function

<DllImport("user32.dll", EntryPoint:="SetWindowLong")> _
Public Shared Function SetWindowLong( _
    ByVal hWnd As IntPtr, _
    ByVal nIndex As GWL, _
    ByVal dwNewLong As WS_EX _
        ) As Integer
End Function

<DllImport("user32.dll", _
  EntryPoint:="SetLayeredWindowAttributes")> _
Public Shared Function SetLayeredWindowAttributes( _
    ByVal hWnd As IntPtr, _
    ByVal crKey As Integer, _
    ByVal alpha As Byte, _
    ByVal dwFlags As LWA _
        ) As Boolean
End Function

Private _InitialStyle As Integer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    _InitialStyle = GetWindowLong(Me.Handle, GWL.ExStyle)
    Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
    Me.BackColor = Color.Black
    Me.Opacity = 0.1 'Range is 0 (Fully see through) to 1 (Fully opaque)
    Me.TopMost = True
    DimScreenByIndex(1) 'use 0, 1, etc depending on which screen you want to dim

    SetWindowLong(Me.Handle, GWL.ExStyle, _InitialStyle Or WS_EX.Layered Or WS_EX.Transparent)
    'Not needed if setting the opacity: SetLayeredWindowAttributes(Me.Handle, 0, 255 * 0.7, LWA.Alpha)

End Sub

Private Sub DimScreenByIndex(ByVal intScn As Integer)
    For intPtr As Integer = Screen.AllScreens.GetLowerBound(0) To Screen.AllScreens.GetUpperBound(0)
        If intPtr = intScn Then
            Me.Top = Screen.AllScreens(intPtr).Bounds.Top
            Me.Left = Screen.AllScreens(intPtr).Bounds.Left
            Me.Height = Screen.AllScreens(intPtr).Bounds.Height()
            Me.Width = Screen.AllScreens(intPtr).Bounds.Width
        End If
    Next
End Sub
End Class
0

Source: https://habr.com/ru/post/1775108/


All Articles