Autor Beitrag
highlander78
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 62



BeitragVerfasst: Fr 30.11.07 22:11 
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.

ausblenden 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;

        }


ausblenden volle Höhe C#-Quelltext
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
    {
        /// <summary>
        /// Erforderliche Designervariable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Verwendete Ressourcen bereinigen.
        /// </summary>
        /// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Vom Windows Form-Designer generierter Code

        /// <summary>
        /// Erforderliche Methode für die Designerunterstützung.
        /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
        /// </summary>
        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();
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(47198);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(24850);
            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);
            // 
            // notifyIcon1
            // 
            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);
            // 
            // Form1
            // 
            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
Einloggen, um Attachments anzusehen!


Zuletzt bearbeitet von highlander78 am Sa 01.12.07 05:54, insgesamt 2-mal bearbeitet
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Fr 30.11.07 22:14 
Hallo!

Poste doch bitte die relevanten Teile Deines Quelltextes im Beitrag, dann muss man sich nicht erst das Archiv runterladen, entpacken, öffnen, ... ;-)

Danke!

Grüße
Christian

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
highlander78 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 62



BeitragVerfasst: Fr 30.11.07 22:55 
ok, sorry :wink:
JüTho
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2021
Erhaltene Danke: 6

Win XP Prof
C# 2.0 (#D für NET 2.0, dazu Firebird); früher Delphi 5 und Delphi 2005 Pro
BeitragVerfasst: Sa 01.12.07 12:10 
Hallo,

eine richtige Erklärung habe ich nicht (es sei denn, es gibt noch andere Stellen im Programm, die die Größe des Formulars beeinflussen). Als Notlösung könntest Du in notifyIcon1_MouseDoubleClick() die Größe neu zuweisen; vielleicht bringt auch die Reihenfolge der Befehle "Visible" und "WindowState" die Darstellung durcheinander.

Gruß Jürgen