Controls draw slow on forms

  • Thread starter Thread starter Stephen
  • Start date Start date
S

Stephen

I have a simple Help->About window with about 15 labels,
5 buttons, and 2 web links in VB.NET. It also has 2
pictureboxes, an icon 48x48x32bpp and the other
180x180x8bpp. I am running a decent machine at 2.4GHz,
nothing running to slow it down, but you can see the form
draw each control separately. Making it invisible until
after the InitializeComponent has no effect.
The .NET Framework is supposed to make things run more
efficiently, and when the form is cached it is instant,
but the JIT compiler is slow to run something the first
time it seems. Is there some trick to having the whole
form pop up at once, pre-drawn? The Visual Studio About
dialog is instantly drawn and it is much more complex
than my simple one.

Stephen
 
Hello,

Stephen said:
I have a simple Help->About window with about 15 labels,
5 buttons, and 2 web links in VB.NET. It also has 2
pictureboxes, an icon 48x48x32bpp and the other
180x180x8bpp. I am running a decent machine at 2.4GHz,
nothing running to slow it down, but you can see the form
draw each control separately. Making it invisible until
after the InitializeComponent has no effect.
The .NET Framework is supposed to make things run more
efficiently, and when the form is cached it is instant,
but the JIT compiler is slow to run something the first
time it seems. Is there some trick to having the whole

I feel sorry, I do not have a solution.
form pop up at once, pre-drawn? The Visual Studio About
dialog is instantly drawn and it is much more complex
than my simple one.

I think it's not implemented in .NET.

Regards,
Herfried K. Wagner
 
Hello Stephen,
I'm not clear about how slow does your form show up. if it's just a
bit slower than the About Box in VS.NET I think this is normal,because the
About Box of VS.NET uses standard common control and the embeded resources,
in other words, all is ready and in memory. So if you want to make your
form show faster, you may set the FlatStyle property of the Button Label as
well as LinkLabel to System,then these controls will be drawn by system. If
you want to show picture more quickly
I think you may try embed it as resource. you may refer to the following
link for more information:
(Note it's about Cursor, you should change to Bitmap)
ms-help://MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfSystemWindowsFormsCursorCl
assctorTopic4.htm

Is this helpful to you? Please let me know if you still have problem with
this issue, thanks!


Kind regards,

Ying-Shen Yu [MS]
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
reserved.
--------------------
| Content-Class: urn:content-classes:message
| From: "Stephen" <[email protected]>
| Sender: "Stephen" <[email protected]>
| Subject: Controls draw slow on forms
| Date: Sun, 31 Aug 2003 21:43:24 -0700
| Lines: 16
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcNwQ5Q0OML56clgS/eW+JURWkuLdg==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:51359
| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| I have a simple Help->About window with about 15 labels,
| 5 buttons, and 2 web links in VB.NET. It also has 2
| pictureboxes, an icon 48x48x32bpp and the other
| 180x180x8bpp. I am running a decent machine at 2.4GHz,
| nothing running to slow it down, but you can see the form
| draw each control separately. Making it invisible until
| after the InitializeComponent has no effect.
| The .NET Framework is supposed to make things run more
| efficiently, and when the form is cached it is instant,
| but the JIT compiler is slow to run something the first
| time it seems. Is there some trick to having the whole
| form pop up at once, pre-drawn? The Visual Studio About
| dialog is instantly drawn and it is much more complex
| than my simple one.
|
| Stephen
|
 
Setting the Image property to a file at design-time
automatically creates a resource file for the form and
the code to extract the image from it, so it is already
reading from a resource file. I'm not loading from a
file at run-time. I set the FlatStyle of all controls to
System and it didn't have an effect.

-----Original Message-----
Hello Stephen,
I'm not clear about how slow does your form show up. if it's just a
bit slower than the About Box in VS.NET I think this is normal,because the
About Box of VS.NET uses standard common control and the embeded resources,
in other words, all is ready and in memory. So if you want to make your
form show faster, you may set the FlatStyle property of the Button Label as
well as LinkLabel to System,then these controls will be drawn by system. If
you want to show picture more quickly
I think you may try embed it as resource. you may refer to the following
link for more information:
(Note it's about Cursor, you should change to Bitmap)
ms- help://MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfSystemWindo
wsFormsCursorCl
assctorTopic4.htm

Is this helpful to you? Please let me know if you still have problem with
this issue, thanks!


Kind regards,

Ying-Shen Yu [MS]
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
reserved.
--------------------
| Content-Class: urn:content-classes:message
| From: "Stephen" <[email protected]>
| Sender: "Stephen" <[email protected]>
| Subject: Controls draw slow on forms
| Date: Sun, 31 Aug 2003 21:43:24 -0700
| Lines: 16
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcNwQ5Q0OML56clgS/eW+JURWkuLdg==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:51359
| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| I have a simple Help->About window with about 15 labels,
| 5 buttons, and 2 web links in VB.NET. It also has 2
| pictureboxes, an icon 48x48x32bpp and the other
| 180x180x8bpp. I am running a decent machine at 2.4GHz,
| nothing running to slow it down, but you can see the form
| draw each control separately. Making it invisible until
| after the InitializeComponent has no effect.
| The .NET Framework is supposed to make things run more
| efficiently, and when the form is cached it is instant,
| but the JIT compiler is slow to run something the first
| time it seems. Is there some trick to having the whole
| form pop up at once, pre-drawn? The Visual Studio About
| dialog is instantly drawn and it is much more complex
| than my simple one.
|
| Stephen
|

.
 
Setting the Image property to a file at design-time
automatically creates a resource file for the form and
the code to extract the image from it, so it is already
reading from a resource file.

I think Ying-Shen was referring to a Windows resource, not a .NET
resource. Windows resources are harder to work with from .NET, but they
would quite likely be faster, since there's less overhead and they're
already in native Windows format.

Anyway, I suspect that the Visual Studio about box either (1) isn't
written in .NET, or (2) is pre-compiled to native code with ngen, so it
doesn't have to wait for JIT compilation. You could try using ngen on
your app and see if that helps you out.

Also, is your About box the first place your app ever shows a Label or a
LinkLabel? You might see if you can show one of each sometime before
the About box ever appears, so they're already JIT-compiled by the time
your dialog is shown. If JIT-compile time is the issue, then showing
one of each beforehand should take care of it. (This probably wouldn't
matter if you used ngen.)
 
Hi Stephen,
The resource I referred to is Windows Resource that embeded with you
executable file, thanks Joe. On my machine it shows faster than specifying
an image file in PictureBox.Image. In addition, you set the image in
PictureBox.Image not PictureBox.BackgroundImage? On my machine, setting an
image in BackgroundImage of the PictureBox will make the form draw slowly.

ngen will also make your program a little faster, VS.NET uses this feature,
you may see the ngen assembly list use
ngen /show,but as you can see, since the main assemblies (e.g.mscorlib,
System, Drawing, Winform) are already NGENed, so maybe you are not able to
gain much performance up by ngen.

Thanks!
Be free to let me know if you still have problems on this issue!


Kind regards,

Ying-Shen Yu [MS]
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
reserved.
--------------------
| Message-ID: <[email protected]>
| Date: Mon, 01 Sep 2003 11:42:32 -0500
| From: Joe White <[email protected]>
| User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2)
Gecko/20030208 Netscape/7.02
| X-Accept-Language: en-us, en
| MIME-Version: 1.0
| Subject: Re: Controls draw slow on forms
| References: <[email protected]>
<[email protected]>
<[email protected]>
| Content-Type: text/plain; charset=us-ascii; format=flowed
| Content-Transfer-Encoding: 7bit
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| NNTP-Posting-Host: ip68-96-138-248.om.om.cox.net 68.96.138.248
| Lines: 1
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGXS02.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA0
5.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:51400
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| > Setting the Image property to a file at design-time
| > automatically creates a resource file for the form and
| > the code to extract the image from it, so it is already
| > reading from a resource file.
|
| I think Ying-Shen was referring to a Windows resource, not a .NET
| resource. Windows resources are harder to work with from .NET, but they
| would quite likely be faster, since there's less overhead and they're
| already in native Windows format.
|
| Anyway, I suspect that the Visual Studio about box either (1) isn't
| written in .NET, or (2) is pre-compiled to native code with ngen, so it
| doesn't have to wait for JIT compilation. You could try using ngen on
| your app and see if that helps you out.
|
| Also, is your About box the first place your app ever shows a Label or a
| LinkLabel? You might see if you can show one of each sometime before
| the About box ever appears, so they're already JIT-compiled by the time
| your dialog is shown. If JIT-compile time is the issue, then showing
| one of each beforehand should take care of it. (This probably wouldn't
| matter if you used ngen.)
|
|
 
I ngen'ed my exe and ran it, no difference. So I started looking at the
files (ngen'ed one and original exe), both have all my variable and class
names blatantly visible just by opening exe in notepad. I ngen'ed again to
make sure and it said "up to date." I ran comp.exe on them and they are
identical. I thought this changed code into native code?? Even if I was
wrong, shouldn't it do SOMEthing?

Stephen
 
Hello Stephen,
ngen doesn't ouput an native version of that exe, it just create the
native image and added it to the native image cache.
you may get a list using the example I showed you in my reply. for more
information, you may refer to :

ms-help://MS.MSDNQTR.2003FEB.1033/cptools/html/cpgrfnativeimagegeneratorngen
exe.htm
thanks!


Kind regards,

Ying-Shen Yu [MS]
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
reserved.
--------------------
| From: "Stephen" <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]> <[email protected]>
| Subject: Re: Controls draw slow on forms
| Date: Tue, 2 Sep 2003 01:06:29 -0400
| Lines: 35
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| NNTP-Posting-Host: c-66-177-177-97.se.client2.attbi.com 66.177.177.97
| Path:
cpmsftngxa06.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
..phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:51436
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| I ngen'ed my exe and ran it, no difference. So I started looking at the
| files (ngen'ed one and original exe), both have all my variable and class
| names blatantly visible just by opening exe in notepad. I ngen'ed again
to
| make sure and it said "up to date." I ran comp.exe on them and they are
| identical. I thought this changed code into native code?? Even if I was
| wrong, shouldn't it do SOMEthing?
|
| Stephen
|
| | > > Setting the Image property to a file at design-time
| > > automatically creates a resource file for the form and
| > > the code to extract the image from it, so it is already
| > > reading from a resource file.
| >
| > I think Ying-Shen was referring to a Windows resource, not a .NET
| > resource. Windows resources are harder to work with from .NET, but they
| > would quite likely be faster, since there's less overhead and they're
| > already in native Windows format.
| >
| > Anyway, I suspect that the Visual Studio about box either (1) isn't
| > written in .NET, or (2) is pre-compiled to native code with ngen, so it
| > doesn't have to wait for JIT compilation. You could try using ngen on
| > your app and see if that helps you out.
| >
| > Also, is your About box the first place your app ever shows a Label or a
| > LinkLabel? You might see if you can show one of each sometime before
| > the About box ever appears, so they're already JIT-compiled by the time
| > your dialog is shown. If JIT-compile time is the issue, then showing
| > one of each beforehand should take care of it. (This probably wouldn't
| > matter if you used ngen.)
| >
|
|
|
 
Hi Stephen,
You may try overridding the OnPaintBackground method of your form, and
draw your images in it, this will reduce the delay of displaying image, but
you must postion it by code, and you shouldn't draw large images or your
form might get flicker when moving from the screen edge, however 180x180 is
acceptable in my mind. I feel sorry I haven't find a better way to make the
controls draw faster.
In addition could you tell me why you need draw the form quickly at first
time? thanks!

Here is an simple example:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Diagnostics;

namespace Drag_n_Drop
{
/// <summary>
/// Summary description for Form2.
/// </summary>
public class Form2 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private Bitmap bmp = null;
public Form2()
{
InitializeComponent();
// Changed it to your own image
file
bmp = new Bitmap(@"DJAqua.JPG");
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(352, 88);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "Close";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(352, 24);
this.button2.Name = "button2";
this.button2.TabIndex = 1;
this.button2.Text = "button2";
//
// button3
//
this.button3.Location = new System.Drawing.Point(352, 56);
this.button3.Name = "button3";
this.button3.TabIndex = 2;
this.button3.Text = "button3";
//
// Form2
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(432, 205);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form2";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.Text = "Form2";
this.ResumeLayout(false);

}
#endregion

private void button1_Click(object sender, System.EventArgs e)
{
Close();
}

protected override void OnPaintBackground(PaintEventArgs e)
{
base.OnPaintBackground (e);
//draw your image here
e.Graphics.DrawImage(bmp,new Rectangle(5,5,180,180),
new Rectangle(0,0,180,180),GraphicsUnit.Pixel);
}

}
}


Kind regards,

Ying-Shen Yu [MS]
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
reserved.
--------------------
| From: "Stephen" <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]> <[email protected]>
| Subject: Re: Controls draw slow on forms
| Date: Tue, 2 Sep 2003 01:06:29 -0400
| Lines: 35
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| NNTP-Posting-Host: c-66-177-177-97.se.client2.attbi.com 66.177.177.97
| Path:
cpmsftngxa06.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:51436
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| I ngen'ed my exe and ran it, no difference. So I started looking at the
| files (ngen'ed one and original exe), both have all my variable and class
| names blatantly visible just by opening exe in notepad. I ngen'ed again
to
| make sure and it said "up to date." I ran comp.exe on them and they are
| identical. I thought this changed code into native code?? Even if I was
| wrong, shouldn't it do SOMEthing?
|
| Stephen
|
| | > > Setting the Image property to a file at design-time
| > > automatically creates a resource file for the form and
| > > the code to extract the image from it, so it is already
| > > reading from a resource file.
| >
| > I think Ying-Shen was referring to a Windows resource, not a .NET
| > resource. Windows resources are harder to work with from .NET, but they
| > would quite likely be faster, since there's less overhead and they're
| > already in native Windows format.
| >
| > Anyway, I suspect that the Visual Studio about box either (1) isn't
| > written in .NET, or (2) is pre-compiled to native code with ngen, so it
| > doesn't have to wait for JIT compilation. You could try using ngen on
| > your app and see if that helps you out.
| >
| > Also, is your About box the first place your app ever shows a Label or a
| > LinkLabel? You might see if you can show one of each sometime before
| > the About box ever appears, so they're already JIT-compiled by the time
| > your dialog is shown. If JIT-compile time is the issue, then showing
| > one of each beforehand should take care of it. (This probably wouldn't
| > matter if you used ngen.)
| >
|
|
|
 
Just because it looks unprofessional coming together piece-by-piece, and if
I can notice it on my system it will be worse on slower systems the
application is designed to target.

Ying-Shen Yu said:
Hi Stephen,
You may try overridding the OnPaintBackground method of your form, and
draw your images in it, this will reduce the delay of displaying image, but
you must postion it by code, and you shouldn't draw large images or your
form might get flicker when moving from the screen edge, however 180x180 is
acceptable in my mind. I feel sorry I haven't find a better way to make the
controls draw faster.
In addition could you tell me why you need draw the form quickly at first
time? thanks!

Here is an simple example:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Diagnostics;

namespace Drag_n_Drop
{
/// <summary>
/// Summary description for Form2.
/// </summary>
public class Form2 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private Bitmap bmp = null;
public Form2()
{
InitializeComponent();
// Changed it to your own image
file
bmp = new Bitmap(@"DJAqua.JPG");
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(352, 88);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "Close";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(352, 24);
this.button2.Name = "button2";
this.button2.TabIndex = 1;
this.button2.Text = "button2";
//
// button3
//
this.button3.Location = new System.Drawing.Point(352, 56);
this.button3.Name = "button3";
this.button3.TabIndex = 2;
this.button3.Text = "button3";
//
// Form2
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(432, 205);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form2";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.Text = "Form2";
this.ResumeLayout(false);

}
#endregion

private void button1_Click(object sender, System.EventArgs e)
{
Close();
}

protected override void OnPaintBackground(PaintEventArgs e)
{
base.OnPaintBackground (e);
//draw your image here
e.Graphics.DrawImage(bmp,new Rectangle(5,5,180,180),
new Rectangle(0,0,180,180),GraphicsUnit.Pixel);
}

}
}


Kind regards,

Ying-Shen Yu [MS]
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
reserved.
--------------------
| From: "Stephen" <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]> <[email protected]>
| Subject: Re: Controls draw slow on forms
| Date: Tue, 2 Sep 2003 01:06:29 -0400
| Lines: 35
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| NNTP-Posting-Host: c-66-177-177-97.se.client2.attbi.com 66.177.177.97
| Path:
cpmsftngxa06.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:51436
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| I ngen'ed my exe and ran it, no difference. So I started looking at the
| files (ngen'ed one and original exe), both have all my variable and class
| names blatantly visible just by opening exe in notepad. I ngen'ed again
to
| make sure and it said "up to date." I ran comp.exe on them and they are
| identical. I thought this changed code into native code?? Even if I was
| wrong, shouldn't it do SOMEthing?
|
| Stephen
|
| | > > Setting the Image property to a file at design-time
| > > automatically creates a resource file for the form and
| > > the code to extract the image from it, so it is already
| > > reading from a resource file.
| >
| > I think Ying-Shen was referring to a Windows resource, not a .NET
| > resource. Windows resources are harder to work with from .NET, but they
| > would quite likely be faster, since there's less overhead and they're
| > already in native Windows format.
| >
| > Anyway, I suspect that the Visual Studio about box either (1) isn't
| > written in .NET, or (2) is pre-compiled to native code with ngen, so it
| > doesn't have to wait for JIT compilation. You could try using ngen on
| > your app and see if that helps you out.
| >
| > Also, is your About box the first place your app ever shows a Label or a
| > LinkLabel? You might see if you can show one of each sometime before
| > the About box ever appears, so they're already JIT-compiled by the time
| > your dialog is shown. If JIT-compile time is the issue, then showing
| > one of each beforehand should take care of it. (This probably wouldn't
| > matter if you used ngen.)
| >
|
|
|
 
Hi Stephen,

Then, how about drawing in the OnPaintBackground method? Is it helpful?
I must say there's not many way to improve the painting speed at first time.
Maybe you should try developing your application using Visual C++ or etc,
if the painting speed is
really important.
Thanks!


Kind regards,

Ying-Shen Yu [MS]
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
reserved.
--------------------
| From: "Stephen" <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]> <[email protected]>
<[email protected]>
<[email protected]>
| Subject: Re: Controls draw slow on forms
| Date: Wed, 3 Sep 2003 18:42:11 -0400
| Lines: 215
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| NNTP-Posting-Host: c-66-177-177-97.se.client2.attbi.com 66.177.177.97
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:51587
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| Just because it looks unprofessional coming together piece-by-piece, and
if
| I can notice it on my system it will be worse on slower systems the
| application is designed to target.
|
| | > Hi Stephen,
| > You may try overridding the OnPaintBackground method of your form,
and
| > draw your images in it, this will reduce the delay of displaying image,
| but
| > you must postion it by code, and you shouldn't draw large images or your
| > form might get flicker when moving from the screen edge, however 180x180
| is
| > acceptable in my mind. I feel sorry I haven't find a better way to make
| the
| > controls draw faster.
| > In addition could you tell me why you need draw the form quickly at
| first
| > time? thanks!
| >
| > Here is an simple example:
| > using System;
| > using System.Drawing;
| > using System.Collections;
| > using System.ComponentModel;
| > using System.Windows.Forms;
| > using System.Diagnostics;
| >
| > namespace Drag_n_Drop
| > {
| > /// <summary>
| > /// Summary description for Form2.
| > /// </summary>
| > public class Form2 : System.Windows.Forms.Form
| > {
| > private System.Windows.Forms.Button button1;
| > private System.Windows.Forms.Button button2;
| > private System.Windows.Forms.Button button3;
| > /// <summary>
| > /// Required designer variable.
| > /// </summary>
| > private System.ComponentModel.Container components = null;
| > private Bitmap bmp = null;
| > public Form2()
| > {
| > InitializeComponent();
| > // Changed it to your own
| image
| > file
| > bmp = new Bitmap(@"DJAqua.JPG");
| > }
| >
| > /// <summary>
| > /// Clean up any resources being used.
| > /// </summary>
| > protected override void Dispose( bool disposing )
| > {
| > if( disposing )
| > {
| > if(components != null)
| > {
| > components.Dispose();
| > }
| > }
| > base.Dispose( disposing );
| > }
| >
| > #region Windows Form Designer generated code
| > /// <summary>
| > /// Required method for Designer support - do not modify
| > /// the contents of this method with the code editor.
| > /// </summary>
| > private void InitializeComponent()
| > {
| > this.button1 = new System.Windows.Forms.Button();
| > this.button2 = new System.Windows.Forms.Button();
| > this.button3 = new System.Windows.Forms.Button();
| > this.SuspendLayout();
| > //
| > // button1
| > //
| > this.button1.Location = new System.Drawing.Point(352, 88);
| > this.button1.Name = "button1";
| > this.button1.TabIndex = 0;
| > this.button1.Text = "Close";
| > this.button1.Click += new System.EventHandler(this.button1_Click);
| > //
| > // button2
| > //
| > this.button2.Location = new System.Drawing.Point(352, 24);
| > this.button2.Name = "button2";
| > this.button2.TabIndex = 1;
| > this.button2.Text = "button2";
| > //
| > // button3
| > //
| > this.button3.Location = new System.Drawing.Point(352, 56);
| > this.button3.Name = "button3";
| > this.button3.TabIndex = 2;
| > this.button3.Text = "button3";
| > //
| > // Form2
| > //
| > this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
| > this.ClientSize = new System.Drawing.Size(432, 205);
| > this.Controls.Add(this.button3);
| > this.Controls.Add(this.button2);
| > this.Controls.Add(this.button1);
| > this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
| > this.MaximizeBox = false;
| > this.MinimizeBox = false;
| > this.Name = "Form2";
| > this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
| > this.Text = "Form2";
| > this.ResumeLayout(false);
| >
| > }
| > #endregion
| >
| > private void button1_Click(object sender, System.EventArgs e)
| > {
| > Close();
| > }
| >
| > protected override void OnPaintBackground(PaintEventArgs e)
| > {
| > base.OnPaintBackground (e);
| > //draw your image here
| > e.Graphics.DrawImage(bmp,new Rectangle(5,5,180,180),
| > new Rectangle(0,0,180,180),GraphicsUnit.Pixel);
| > }
| >
| > }
| > }
| >
| >
| > Kind regards,
| >
| > Ying-Shen Yu [MS]
| > Microsoft Support Engineer
| >
| > This posting is provided "AS IS" with no warranties, and confers no
| rights.
| > You assume all risk for your use. 2001 Microsoft Corporation. All
rights
| > reserved.
| > --------------------
| > | From: "Stephen" <[email protected]>
| > | References: <[email protected]>
| > <[email protected]>
| > <[email protected]> <[email protected]>
| > | Subject: Re: Controls draw slow on forms
| > | Date: Tue, 2 Sep 2003 01:06:29 -0400
| > | Lines: 35
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| > | Message-ID: <[email protected]>
| > | Newsgroups: microsoft.public.dotnet.framework.windowsforms
| > | NNTP-Posting-Host: c-66-177-177-97.se.client2.attbi.com 66.177.177.97
| > | Path:
| >
|
cpmsftngxa06.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
| > phx.gbl!TK2MSFTNGP10.phx.gbl
| > | Xref: cpmsftngxa06.phx.gbl
| > microsoft.public.dotnet.framework.windowsforms:51436
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
| > |
| > | I ngen'ed my exe and ran it, no difference. So I started looking at
the
| > | files (ngen'ed one and original exe), both have all my variable and
| class
| > | names blatantly visible just by opening exe in notepad. I ngen'ed
again
| > to
| > | make sure and it said "up to date." I ran comp.exe on them and they
are
| > | identical. I thought this changed code into native code?? Even if I
| was
| > | wrong, shouldn't it do SOMEthing?
| > |
| > | Stephen
| > |
| > | | > | > > Setting the Image property to a file at design-time
| > | > > automatically creates a resource file for the form and
| > | > > the code to extract the image from it, so it is already
| > | > > reading from a resource file.
| > | >
| > | > I think Ying-Shen was referring to a Windows resource, not a .NET
| > | > resource. Windows resources are harder to work with from .NET, but
| they
| > | > would quite likely be faster, since there's less overhead and
they're
| > | > already in native Windows format.
| > | >
| > | > Anyway, I suspect that the Visual Studio about box either (1) isn't
| > | > written in .NET, or (2) is pre-compiled to native code with ngen, so
| it
| > | > doesn't have to wait for JIT compilation. You could try using ngen
on
| > | > your app and see if that helps you out.
| > | >
| > | > Also, is your About box the first place your app ever shows a Label
or
| a
| > | > LinkLabel? You might see if you can show one of each sometime
before
| > | > the About box ever appears, so they're already JIT-compiled by the
| time
| > | > your dialog is shown. If JIT-compile time is the issue, then
showing
| > | > one of each beforehand should take care of it. (This probably
| wouldn't
| > | > matter if you used ngen.)
| > | >
| > |
| > |
| > |
| >
|
|
|
 
I suppose it is just something I will have to live with. It's
disappointment more than anything. Don't get me wrong, I thing the .NET
Framework is a huge step forward, but I guess the lack of machine code slows
things down, but it's a necessity. Thank you for your help though. You
have been very patient with me.

Stephen


Ying-Shen Yu said:
Hi Stephen,

Then, how about drawing in the OnPaintBackground method? Is it helpful?
I must say there's not many way to improve the painting speed at first time.
Maybe you should try developing your application using Visual C++ or etc,
if the painting speed is
really important.
Thanks!


Kind regards,

Ying-Shen Yu [MS]
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
reserved.
--------------------
| From: "Stephen" <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]> <[email protected]>
<[email protected]>
<[email protected]>
| Subject: Re: Controls draw slow on forms
| Date: Wed, 3 Sep 2003 18:42:11 -0400
| Lines: 215
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| NNTP-Posting-Host: c-66-177-177-97.se.client2.attbi.com 66.177.177.97
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:51587
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| Just because it looks unprofessional coming together piece-by-piece, and
if
| I can notice it on my system it will be worse on slower systems the
| application is designed to target.
|
| | > Hi Stephen,
| > You may try overridding the OnPaintBackground method of your form,
and
| > draw your images in it, this will reduce the delay of displaying image,
| but
| > you must postion it by code, and you shouldn't draw large images or your
| > form might get flicker when moving from the screen edge, however 180x180
| is
| > acceptable in my mind. I feel sorry I haven't find a better way to make
| the
| > controls draw faster.
| > In addition could you tell me why you need draw the form quickly at
| first
| > time? thanks!
| >
| > Here is an simple example:
| > using System;
| > using System.Drawing;
| > using System.Collections;
| > using System.ComponentModel;
| > using System.Windows.Forms;
| > using System.Diagnostics;
| >
| > namespace Drag_n_Drop
| > {
| > /// <summary>
| > /// Summary description for Form2.
| > /// </summary>
| > public class Form2 : System.Windows.Forms.Form
| > {
| > private System.Windows.Forms.Button button1;
| > private System.Windows.Forms.Button button2;
| > private System.Windows.Forms.Button button3;
| > /// <summary>
| > /// Required designer variable.
| > /// </summary>
| > private System.ComponentModel.Container components = null;
| > private Bitmap bmp = null;
| > public Form2()
| > {
| > InitializeComponent();
| > // Changed it to your own
| image
| > file
| > bmp = new Bitmap(@"DJAqua.JPG");
| > }
| >
| > /// <summary>
| > /// Clean up any resources being used.
| > /// </summary>
| > protected override void Dispose( bool disposing )
| > {
| > if( disposing )
| > {
| > if(components != null)
| > {
| > components.Dispose();
| > }
| > }
| > base.Dispose( disposing );
| > }
| >
| > #region Windows Form Designer generated code
| > /// <summary>
| > /// Required method for Designer support - do not modify
| > /// the contents of this method with the code editor.
| > /// </summary>
| > private void InitializeComponent()
| > {
| > this.button1 = new System.Windows.Forms.Button();
| > this.button2 = new System.Windows.Forms.Button();
| > this.button3 = new System.Windows.Forms.Button();
| > this.SuspendLayout();
| > //
| > // button1
| > //
| > this.button1.Location = new System.Drawing.Point(352, 88);
| > this.button1.Name = "button1";
| > this.button1.TabIndex = 0;
| > this.button1.Text = "Close";
| > this.button1.Click += new System.EventHandler(this.button1_Click);
| > //
| > // button2
| > //
| > this.button2.Location = new System.Drawing.Point(352, 24);
| > this.button2.Name = "button2";
| > this.button2.TabIndex = 1;
| > this.button2.Text = "button2";
| > //
| > // button3
| > //
| > this.button3.Location = new System.Drawing.Point(352, 56);
| > this.button3.Name = "button3";
| > this.button3.TabIndex = 2;
| > this.button3.Text = "button3";
| > //
| > // Form2
| > //
| > this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
| > this.ClientSize = new System.Drawing.Size(432, 205);
| > this.Controls.Add(this.button3);
| > this.Controls.Add(this.button2);
| > this.Controls.Add(this.button1);
| > this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
| > this.MaximizeBox = false;
| > this.MinimizeBox = false;
| > this.Name = "Form2";
| > this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
| > this.Text = "Form2";
| > this.ResumeLayout(false);
| >
| > }
| > #endregion
| >
| > private void button1_Click(object sender, System.EventArgs e)
| > {
| > Close();
| > }
| >
| > protected override void OnPaintBackground(PaintEventArgs e)
| > {
| > base.OnPaintBackground (e);
| > //draw your image here
| > e.Graphics.DrawImage(bmp,new Rectangle(5,5,180,180),
| > new Rectangle(0,0,180,180),GraphicsUnit.Pixel);
| > }
| >
| > }
| > }
| >
| >
| > Kind regards,
| >
| > Ying-Shen Yu [MS]
| > Microsoft Support Engineer
| >
| > This posting is provided "AS IS" with no warranties, and confers no
| rights.
| > You assume all risk for your use. 2001 Microsoft Corporation. All
rights
| > reserved.
| > --------------------
| > | From: "Stephen" <[email protected]>
| > | References: <[email protected]>
| > <[email protected]>
| > <[email protected]>
 
Stephen said:
disappointment more than anything. Don't get me wrong, I thing the .NET
Framework is a huge step forward, but I guess the lack of machine code slows
things down, but it's a necessity.

Its probably more a design oversight than lack of machine code,
if the problem is not the load time, but simply the fact that
you can't delay showing the Form until all controls are initialized.
Maybe this will get fixed in a future version.
 
Back
Top