Frage

Ich versuche, Transparenz aller Fenster zu setzen. Ich habe folgenden Code ein.

public partial class Form1 : Form
{
    [DllImport("user32.dll")]
    static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

    [DllImport("user32.dll")]
    static extern int GetWindowLong(IntPtr hWnd, int nIndex);

    [DllImport("user32.dll")]
    static extern bool SetLayeredWindowAttributes(IntPtr hwnd, uint crKey, byte bAlpha, uint dwFlags);

    public const int GWL_EXSTYLE = -20;
    public const int WS_EX_LAYERED = 0x80000;
    public const int LWA_ALPHA = 0x2;

    public Form1()
    {
        InitializeComponent();
        this.Load += new EventHandler(Form1_Load);
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        Process[] processlist = Process.GetProcesses();

        foreach (Process theprocess in processlist)
        {
            SetWindowLong(theprocess.Handle, GWL_EXSTYLE,
                GetWindowLong(theprocess.Handle, GWL_EXSTYLE) ^ WS_EX_LAYERED);
            SetLayeredWindowAttributes(theprocess.Handle, 0, 128, LWA_ALPHA);
        }

    }
}

nichts passiert, wenn ich den Code auszuführen.

Was ist falsch ??

War es hilfreich?

Lösung

SetWindowLong nimmt einen Fenstergriff (hWnd), aber Sie es einen Prozess handeln, anstatt vorbei sind. Ändern Sie alle Instanzen von

theprocess.Handle

theProcess.MainWindowHandle

Danach Wechsel arbeitete er auf der Windows XP-Maschine, die ich es getestet. Jetzt bin ich gonna hat, um den Code zu ändern, um die Fenster wieder normal bekommen;) Zum Glück, das Visual Studio 2010 Fenster waren nicht betroffen

.

Andere Tipps

Dieser Teil des Codes: ^ WS_EX_LAYERED dreht die WS_EX_LAYERED Bit,

Ich glaube, Sie wollen: | WS_EX_LAYERED

Haben Sie versucht, Einstellung der Opazität

this.Opacity = 0.50;
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top