views:

74

answers:

2

with the help of the stackoverflow community i have designed an app that colors the screen, and makes it look like you are wearing different color glasses.

i would also like to add the functionality of instead of coloring the whole screen, ONLY coloring the background of a document exactly like this program does:

http://www.thomson-software-solutions.com/html/screen_tinter.html

anyone have any clue how to do this in vb.net?

+1  A: 

Offtopic a bit, but you can change Word to default to "White on Blue". Blue background, white text.

Marineio
+1  A: 

That's a pretty simple trick, it just replaces the system color that's used for window backgrounds. You'd change it by P/Invoking the SetSysColor() API function. Here's a sample Windows Forms app that demonstrates the technique. Start a new WF app and drop a button on the form. Then paste this code:

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace WindowsFormsApplication1 {
  public partial class Form1 : Form {
    int oldcolor;
    public Form1() {
      InitializeComponent();
      oldcolor = GetSysColor(COLOR_WINDOW);
      this.FormClosed += new FormClosedEventHandler(Form1_FormClosed);
      this.button1.Click += new EventHandler(button1_Click);
    }

    private void Form1_FormClosed(object sender, FormClosedEventArgs e) {
      int element = COLOR_WINDOW;
      SetSysColors(1, ref element, ref oldcolor);
    }

    private int Color2COLORREF(Color color) {
      return color.R | (color.G << 8) | (color.B << 0x10);
    }

    private void button1_Click(object sender, EventArgs e) {
      int element = COLOR_WINDOW;
      int colorref = Color2COLORREF(Color.NavajoWhite);
      SetSysColors(1, ref element, ref colorref);
    }

    private const int COLOR_WINDOW = 5;
    [DllImport("user32.dll")]
    private static extern bool SetSysColors(int one, ref int element, ref int color);
    [DllImport("user32.dll")]
    private static extern int GetSysColor(int element);

  }
}
Hans Passant
im pressing the button and nothing is happening
I__