the following code is supposed to replace the system color that's used for window backgrounds. You'd change it by P/Invoking the SetSysColor() API function. i am using the following code that was suggested to me but unfortunately when i click the button nothing happens!
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Namespace WindowsFormsApplication1
Partial Public Class Form1
Inherits Form
Private oldcolor As Integer
Public Sub New()
InitializeComponent()
oldcolor = GetSysColor(COLOR_WINDOW)
AddHandler Me.FormClosed, AddressOf Form1_FormClosed
AddHandler Me.button1.Click, AddressOf button1_Click
End Sub
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As FormClosedEventArgs) Handles MyBase.FormClosed
Dim element As Integer = COLOR_WINDOW
SetSysColors(1, element, oldcolor)
End Sub
Private Function Color2COLORREF(ByVal color As Color) As Integer
Return color.R Or (color.G << 8) Or (color.B << &H10)
End Function
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Dim element As Integer = COLOR_WINDOW
Dim colorref As Integer = Color2COLORREF(Color.NavajoWhite)
SetSysColors(1, element, colorref)
End Sub
Private Const COLOR_WINDOW As Integer = 5
<DllImport("user32.dll")> _
Private Shared Function SetSysColors(ByVal one As Integer, ByRef element As Integer, ByRef color As Integer) As Boolean
End Function
<DllImport("user32.dll")> _
Private Shared Function GetSysColor(ByVal element As Integer) As Integer
End Function
Friend WithEvents Button1 As System.Windows.Forms.Button
Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(71, 61)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(153, 126)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Button1"
Me.Button1.UseVisualStyleBackColor = True
'
'Form1
'
Me.ClientSize = New System.Drawing.Size(284, 264)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.ResumeLayout(False)
End Sub
End Class
End Namespace