Winforms application written in win7 looks different on win xp. What for?

I wrote a simple application in winforms (.net 4.0) on win 7. The application looks the way I want, but when I tried it on windows xp, everything looks different.

I created an example to show how it looks on win 7 and xp. What can I do to have the same appearance in both systems? The problem is associated not only with the background color and font, but also with the controls. Here I show what numericupdown looks like, but I have a problem with the layout of the table too.

win 7win xp

 private void InitializeComponent()
    {
        this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
        this.groupBox1 = new System.Windows.Forms.GroupBox();
        ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
        this.SuspendLayout();
        // 
        // numericUpDown1
        // 
        this.numericUpDown1.DecimalPlaces = 2;
        this.numericUpDown1.Increment = new decimal(new int[] {
        1,
        0,
        0,
        131072});
        this.numericUpDown1.Location = new System.Drawing.Point(21, 26);
        this.numericUpDown1.Maximum = new decimal(new int[] {
        1,
        0,
        0,
        0});
        this.numericUpDown1.Name = "numericUpDown1";
        this.numericUpDown1.Size = new System.Drawing.Size(54, 22);
        this.numericUpDown1.TabIndex = 0;
        // 
        // groupBox1
        // 
        this.groupBox1.Location = new System.Drawing.Point(21, 82);
        this.groupBox1.Name = "groupBox1";
        this.groupBox1.Size = new System.Drawing.Size(226, 99);
        this.groupBox1.TabIndex = 1;
        this.groupBox1.TabStop = false;
        this.groupBox1.Text = "groupBox1";
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.BackColor = System.Drawing.SystemColors.ActiveCaption;
        this.ClientSize = new System.Drawing.Size(407, 331);
        this.Controls.Add(this.groupBox1);
        this.Controls.Add(this.numericUpDown1);
        this.Name = "Form1";
        this.Text = "Form1";
        ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
        this.ResumeLayout(false);

    }

I did not change xp color themes. I have the same result on two different computers with win xp.

+3
source share
2 answers
    this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
    this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    this.BackColor = System.Drawing.SystemColors.ActiveCaption;

, . , BackColor , . , "". , , . - , .

AutoScaleDimensions DPI . XP. 120 -, 96 DPI ( ) XP. Win7, , , + , " (DPI)".

AutoScaleMode Font. , , . Win7 - DPI. , XP. NumericUpDown , ( ), /. , . .

, 100% . , , - dev 96 . , . , .

+10
+2

All Articles