Hallo,
ich habe eine Form die sich beim starten rechts unten im Desktop hochfährt und immer im Vordergrund bleibt.
Das klappt alles auch schon.
Nur ich habe es eigentlich so Programmiert, wenn die Maus über der Form fährt erhält Opacity (Trasparents) den Wert 20.
Und wenn Sie die Form wieder verlässt bekommt Opacity den wert 10 (Opacity=10).
Nur aus irgendeinem Grund bekommt das fenster wenn man mit der Maus drüber fährt oder die Maus das fenster verlässt den wert 100, Sprich das Fenster ist nicht durchsichtig. Der defaultwert von Opacity ist 10, und wenn das Programm gestartet wird, ist das Fenster auch durchsichtig.
Ich habe mal den kompletten Code beigefügt:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54:
| using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
namespace fensterrechtsunten { public partial class Form1 : Form { int locationx; int locationy; public Form1() { InitializeComponent(); }
private void timer1_Tick(object sender, EventArgs e) { if (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height - Size.Height < locationy) { locationy = locationy - 2; } Focus(); TopMost = true; Location = new Point(locationx, locationy); }
public void transparent_da(object sender, EventArgs e) { Opacity = 10; Application.DoEvents(); }
public void transparent_weg(object sender, EventArgs e) { Opacity = 20; } private void Form1_Load(object sender, EventArgs e) { locationx = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width - Size.Width; locationy = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height; MouseEnter += transparent_weg; MouseLeave += transparent_da; MouseHover += transparent_da; } } } |