PC Review


Reply
Thread Tools Rate Thread

Controls draw slow on forms

 
 
Stephen
Guest
Posts: n/a
 
      1st Sep 2003
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
 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      1st Sep 2003
Hello,

"Stephen" <(E-Mail Removed)> schrieb:
> 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
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet


 
Reply With Quote
 
Ying-Shen Yu[MS]
Guest
Posts: n/a
 
      1st Sep 2003
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" <(E-Mail Removed)>
| Sender: "Stephen" <(E-Mail Removed)>
| Subject: Controls draw slow on forms
| Date: Sun, 31 Aug 2003 21:43:24 -0700
| Lines: 16
| Message-ID: <03aa01c37043$9434bdb0$(E-Mail Removed)>
| 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
|

 
Reply With Quote
 
Stephen
Guest
Posts: n/a
 
      1st Sep 2003
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" <(E-Mail Removed)>
>| Sender: "Stephen" <(E-Mail Removed)>
>| Subject: Controls draw slow on forms
>| Date: Sun, 31 Aug 2003 21:43:24 -0700
>| Lines: 16
>| Message-ID: <03aa01c37043$9434bdb0$(E-Mail Removed)>
>| 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
>|
>
>.
>

 
Reply With Quote
 
Joe White
Guest
Posts: n/a
 
      1st Sep 2003
> 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.)

 
Reply With Quote
 
Ying-Shen Yu[MS]
Guest
Posts: n/a
 
      2nd Sep 2003
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: <(E-Mail Removed)>
| Date: Mon, 01 Sep 2003 11:42:32 -0500
| From: Joe White <(E-Mail Removed)>
| 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: <03aa01c37043$9434bdb0$(E-Mail Removed)>
<(E-Mail Removed)>
<06bf01c370a3$443f86e0$(E-Mail Removed)>
| 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.)
|
|

 
Reply With Quote
 
Stephen
Guest
Posts: n/a
 
      2nd Sep 2003
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

"Joe White" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> > 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.)
>



 
Reply With Quote
 
Ying-Shen Yu[MS]
Guest
Posts: n/a
 
      2nd Sep 2003
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" <(E-Mail Removed)>
| References: <03aa01c37043$9434bdb0$(E-Mail Removed)>
<(E-Mail Removed)>
<06bf01c370a3$443f86e0$(E-Mail Removed)> <(E-Mail Removed)>
| 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: <essV2$(E-Mail Removed)>
| 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
|
| "Joe White" <(E-Mail Removed)> wrote in message
| news:(E-Mail Removed)...
| > > 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.)
| >
|
|
|

 
Reply With Quote
 
Ying-Shen Yu[MS]
Guest
Posts: n/a
 
      2nd Sep 2003
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" <(E-Mail Removed)>
| References: <03aa01c37043$9434bdb0$(E-Mail Removed)>
<(E-Mail Removed)>
<06bf01c370a3$443f86e0$(E-Mail Removed)> <(E-Mail Removed)>
| 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: <essV2$(E-Mail Removed)>
| 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
|
| "Joe White" <(E-Mail Removed)> wrote in message
| news:(E-Mail Removed)...
| > > 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.)
| >
|
|
|

 
Reply With Quote
 
Stephen
Guest
Posts: n/a
 
      3rd Sep 2003
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[MS]" <v-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)>
> | References: <03aa01c37043$9434bdb0$(E-Mail Removed)>
> <(E-Mail Removed)>
> <06bf01c370a3$443f86e0$(E-Mail Removed)> <(E-Mail Removed)>
> | 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: <essV2$(E-Mail Removed)>
> | 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
> |
> | "Joe White" <(E-Mail Removed)> wrote in message
> | news:(E-Mail Removed)...
> | > > 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.)
> | >
> |
> |
> |
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Draw over controls Pavel Minaev Microsoft C# .NET 1 5th Aug 2008 08:55 AM
Windows forms slow drawing of controls =?Utf-8?B?Q2hhb3M=?= Microsoft Dot NET Framework Forms 8 9th Oct 2006 02:52 PM
Forms with Lots of Controls Very Slow ShakeDoctor Microsoft Dot NET Compact Framework 2 21st Apr 2005 10:57 PM
Message box breaks owner draw controls in .NET controls used as ActiveX controls (again) Clive Dixon Microsoft Dot NET Framework Forms 0 26th May 2004 10:15 AM
Draw over some controls Crirus Microsoft VB .NET 1 8th Dec 2003 02:25 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:07 AM.