2014-03-27 3 views
0

vb.net에서 고 대비 모드를 사용할 수있는 단추 (btnHCon) 클릭 이벤트가 있습니까? (그렇다면 분명히 다시 꺼지는 이벤트)?모든 요소에 대해 VB.Net의 고 대비 모드를 전환하는 방법은 무엇입니까?

이 기능을 내 프로젝트에 추가하는 기능을 추가하려고합니다 (제어판의 고 대비 설정과 비슷 함)?

모든 의견을 매우 높이 평가합니다.

+0

고 대비 모드? 'picturebox'의 이미지를 하이 콘트라스트로 만들고 싶습니까? –

+0

높은 콘트라스트가 PC 자체에서 활성화되어 있으면 나타나는 것처럼 모든 이미지/버튼/등을 포함하여 고 대비로 전체 양식을 원합니다. – jbutler483

답변

1

고화질 모드 (고 대비 모드로 변경 될 수 있기 때문에)에서는 양식/컨트롤에 시스템 기본 색상을 사용하는 것이 유일한 방법입니다. 1 고 대비 모드를 켜려면 유일한 방법은 관리되지 않는 코드, 특히 SystemParametersInfo()uiActionSPI_SETHIGHCONTRAST, HIGHCONTRAST structurepvParam으로 사용하는 것입니다.

비 관리 코드를 호출하는 데별로 좋지는 않지만 고맙게도 chris128 at VBForums has done the hard work입니다. 당신은 그것을 다시 설정하는 당신 자신에있어! 그러나 위의 참조를 보면 적절한 조정이 가능하다고 생각합니다.

Imports System.Runtime.InteropServices 

Public Class Form1 
' 
'API declarations 
' 

Public Const HCF_HIGHCONTRASTON As Integer = 1 
Public Const SPI_SETHIGHCONTRAST As Integer = 67 
Public Const SPIF_SENDWININICHANGE As Integer = 2 

<System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)> _ 
Public Structure HIGHCONTRAST 
    Public cbSize As UInteger 
    Public dwFlags As UInteger 
    <System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPWStr)> _ 
    Public lpszDefaultScheme As String 
End Structure 

<System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint:="SystemParametersInfoW")> _ 
Public Shared Function SystemParametersInfoW(ByVal uiAction As UInteger, ByVal uiParam As UInteger, ByVal pvParam As System.IntPtr, ByVal fWinIni As UInteger) As <System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)> Boolean 
End Function 

' 
'End of API declarations 
' 

'Some button click event 
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 

    Dim highcontraststruct As New HIGHCONTRAST 
    highcontraststruct.dwFlags = HCF_HIGHCONTRASTON 
    highcontraststruct.cbSize = CUInt(Marshal.SizeOf(highcontraststruct)) 
    Dim highcontrastptr As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(highcontraststruct)) 
    Runtime.InteropServices.Marshal.StructureToPtr(highcontraststruct, highcontrastptr, False) 

    SystemParametersInfoW(SPI_SETHIGHCONTRAST, CUInt(Marshal.SizeOf(highcontraststruct)), highcontrastptr, SPIF_SENDWININICHANGE) 

End Sub 
End Class