Hallo,
beschäftige mich gerade mit dynamischen speichern von Einstellungen.
Habe in meiner Form 2 Werte ( Fenstergrösse und Fensterposition )die bei beenden dynamisch gespeicher werden.
Nach erneutem start der Anwendung wird die gespeicherte Fenstergrösse und Fensterposition übernommen.
Bis jetzt noch alles ok.
Das Problem:
wenn ich die Anwendung minimiere wird sie nur im Tray angezeigt, ein Klick auf das Trayicon macht die Anwendung wieder sichtbar.
Das Problem ist nur das, dass die Fenstergrösse nicht mehr pass, das Fenster ist total klein.
C#-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18:
| private void button1_Click(object sender, EventArgs e) { WindowsApplicationFensterGroesse.Properties.Settings.Default.Save(); WindowsApplicationFensterGroesse.Form1.ActiveForm.Close(); } protected override void OnResize(EventArgs e) { base.OnResize(e); notifyIcon1.Visible = (this.WindowState == FormWindowState.Minimized); this.Visible = !notifyIcon1.Visible; }
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) { this.Visible = true; this.WindowState = FormWindowState.Normal; notifyIcon1.Visible = false;
} |
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: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74:
| namespace WindowsApplicationFensterGroesse { partial class Form1 { private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); }
#region Vom Windows Form-Designer generierter Code
private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); this.button1 = new System.Windows.Forms.Button(); this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components); this.SuspendLayout(); this.button1.Location = new System.Drawing.Point(47, 198); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(248, 50); this.button1.TabIndex = 0; this.button1.Text = "FESNSTERGROSSE UND POSITION SPEICHERN UND BEENDEN"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon"))); this.notifyIcon1.Text = "notifyIcon1"; this.notifyIcon1.Visible = true; this.notifyIcon1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseDoubleClick); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = global::WindowsApplicationFensterGroesse.Properties.Settings.Default.Fenstergroesse; this.Controls.Add(this.button1); this.DataBindings.Add(new System.Windows.Forms.Binding("ClientSize", global::WindowsApplicationFensterGroesse.Properties.Settings.Default, "Fenstergroesse", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); this.DataBindings.Add(new System.Windows.Forms.Binding("Location", global::WindowsApplicationFensterGroesse.Properties.Settings.Default, "Position", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); this.Location = global::WindowsApplicationFensterGroesse.Properties.Settings.Default.Position; this.Name = "Form1"; this.Text = "Form1"; this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button button1; private System.Windows.Forms.NotifyIcon notifyIcon1; } } |
Im Anhang ist das Projekt.
Gruss