J
jack Charbonneau
Hi, My system is the same as yours. I wrote the simplest app possible
to do this - just a single form with your code in the Form1_Activated
method. I tested on 2 different machines - and no luck. Could you look
at my code and see if I got something wrong? Thanks again!
Here's the code:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
namespace WindowsApplication2
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Name = "Form1";
this.Text = "Form1";
this.Activated += new System.EventHandler(this.Form1_Activated);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
[DllImport("user32.dll")]
private static extern Int32 GetSysColor(Int32 Index);
[DllImport("user32.dll")]
private static extern bool SetSysColors(int cElements, Int32[]
lpaElements, Int32[] RgbValues);
private const int COLOR_ACTIVECAPTION = 2;
private const int COLOR_2NDACTIVECAPTION = 27;
private int oldSystemTitleBarColor;
private int[] element = new int[] {COLOR_ACTIVECAPTION};
private int[] element2 = new int[] {COLOR_2NDACTIVECAPTION};
private static int[] rgb = null;
private static int[] rgb_old = null;
private void Form1_Activated(object sender, System.EventArgs e)
{
if (rgb == null)
{
oldSystemTitleBarColor = GetSysColor(COLOR_ACTIVECAPTION);
oldSystemTitleBarColor = GetSysColor(COLOR_2NDACTIVECAPTION);
rgb = new int[]{Color.White.ToArgb() & 0x00ffffff};
}
bool b = SetSysColors(1, element, rgb);
b = SetSysColors(1, element2, rgb);
}
}
}
to do this - just a single form with your code in the Form1_Activated
method. I tested on 2 different machines - and no luck. Could you look
at my code and see if I got something wrong? Thanks again!
Here's the code:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
namespace WindowsApplication2
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Name = "Form1";
this.Text = "Form1";
this.Activated += new System.EventHandler(this.Form1_Activated);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
[DllImport("user32.dll")]
private static extern Int32 GetSysColor(Int32 Index);
[DllImport("user32.dll")]
private static extern bool SetSysColors(int cElements, Int32[]
lpaElements, Int32[] RgbValues);
private const int COLOR_ACTIVECAPTION = 2;
private const int COLOR_2NDACTIVECAPTION = 27;
private int oldSystemTitleBarColor;
private int[] element = new int[] {COLOR_ACTIVECAPTION};
private int[] element2 = new int[] {COLOR_2NDACTIVECAPTION};
private static int[] rgb = null;
private static int[] rgb_old = null;
private void Form1_Activated(object sender, System.EventArgs e)
{
if (rgb == null)
{
oldSystemTitleBarColor = GetSysColor(COLOR_ACTIVECAPTION);
oldSystemTitleBarColor = GetSysColor(COLOR_2NDACTIVECAPTION);
rgb = new int[]{Color.White.ToArgb() & 0x00ffffff};
}
bool b = SetSysColors(1, element, rgb);
b = SetSysColors(1, element2, rgb);
}
}
}