我想知道是否有办法获得Windows 8窗口的完全颜色(标题栏中显示的颜色)。我发现了许多与此相关的论坛帖子,但它们都是指注册表项(HKEY_CURRENT_USER \ Software \ Microsoft \ Windows \ DWM \ ColorizationColor)或外部库(dwmapi.dll),它们都返回不同的颜色。
答案 0 :(得分:0)
它可能是"系统颜色之一"。
您是否尝试过例如:
SystemColors.InactiveCaption
SystemColors.ActiveCaption
SystemColors.GradientInactiveCaption
SystemColors.GradientActiveCaption
(还有其他一些可以尝试: cf:http://msdn.microsoft.com/en-us/library/System.Drawing.SystemColors_properties(v=vs.110).aspx
PS。
在RGB术语中,您显示的颜色应该是(如果调整alpha值):
Color.FromArgb(255, 117, 125, 187)
答案 1 :(得分:-2)
最后找到解决这个问题的方法。
Imports System.Runtime.InteropServices
Public Class Form1
<StructLayout(LayoutKind.Sequential)> _
Public Structure MARGINS
Public Destra As Integer
Public Sinistra As Integer
Public Su As Integer
Public Giu As Integer
End Structure
Declare Auto Function DwmIsCompositionEnabled Lib "dwmapi.dll" Alias "DwmIsCompositionEnabled" (ByRef pfEnabled As Boolean) As Integer
Declare Auto Function DwmExtendFrameIntoClientArea Lib "dwmapi.dll" Alias "DwmExtendFrameIntoClientArea" (ByVal hWnd As IntPtr, ByRef pMargin As Margins) As Integer
Dim pMargins As New Margins With {.Su = -1, .Sinistra = -1, .Destra = -1, .Giu = -1}
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim en As Boolean = False
DwmIsCompositionEnabled(en)
If en Then
DwmExtendFrameIntoClientArea(Me.Handle, pMargins)
End If
Me.TransparencyKey = Color.FromKnownColor(KnownColor.ActiveCaption)
Me.BackColor = Me.TransparencyKey
End Sub
End Class
(摘自http://gabriele97.wordpress.com/creare-una-finestra-aero-in-vb-net/)
这会将标题栏的颜色扩展到所有表单,因此,使表单的背景与Windows颜色相同。
我只是想知道为什么从注册表中读取确切的着色颜色是如此困难......
非常感谢@Pam和@HansPassant!