Hi,

I am developing a Windows Form app, that has graphical buttons.
Obviously I use the same button more than once throuout the application,
but Visual Studio would appear to embed a set of images for each button
into the program resources, instead of using a commen one.

If I can make it use a common copy, I could reduce the size of my final
exe file quite considerably.

Is there a way I can edit this, and what is the best way to do it?

Thanks.

Paul

Re: Resources by Bob

Bob
Fri Jul 15 12:20:49 CDT 2005

You can embed one copy of the button and then get that from the resources
using GetManifestResourceStream.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





"Paul Cheetham" <PAC.News@dsl.pipex.com> wrote in message
news:uY2LP1SiFHA.3056@TK2MSFTNGP10.phx.gbl...
> Hi,
>
> I am developing a Windows Form app, that has graphical buttons.
> Obviously I use the same button more than once throuout the application,
> but Visual Studio would appear to embed a set of images for each button
> into the program resources, instead of using a commen one.
>
> If I can make it use a common copy, I could reduce the size of my final
> exe file quite considerably.
>
> Is there a way I can edit this, and what is the best way to do it?
>
> Thanks.
>
> Paul



Re: Resources by Paul

Paul
Fri Jul 15 17:15:12 CDT 2005

Thanks Bob.

I'm not sure how to edit the resources in a .net project though. (Mine
is in VB.Net) - Good old fashioned Win32 apps were fine, but does VS.Net
have a resource editor?

Thankyou.

Paul


Bob Powell [MVP] wrote:
> You can embed one copy of the button and then get that from the resources
> using GetManifestResourceStream.
>

Re: Resources by Bob

Bob
Sat Jul 16 04:29:48 CDT 2005

Resources come in two flavours. Either stored in a resx file or just added
to the solution and set as "embedded resource" in the build action
properties.

For your application it's probably just as easy to do the latter.

Add a resource to the solution, change the build action setting, retrieve it
useing the following:

Image.FromStream(me.GetType().Assembly.GetManifestResourceStream("myapp.Bitmap1.bmp"))

Note that the actual name you use depends upon the root namespace, whether
the resource is in a folder and other factors. If you can't deduce the fully
qualified name to use from your solution structure and namespace etc you can
put a bit of debug code in to help you. This can be removed later but it
lists all the resources for you so you can pick up the right one:

Dim resname As String
For Each resname in me.GetType().Assembly.GetManifestResourceNames
System.Disagnostics.Trace.WriteLine(resname)
Next

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





"Paul Cheetham" <PAC.News@dsl.pipex.com> wrote in message
news:ex9G9pYiFHA.2484@TK2MSFTNGP15.phx.gbl...
> Thanks Bob.
>
> I'm not sure how to edit the resources in a .net project though. (Mine is
> in VB.Net) - Good old fashioned Win32 apps were fine, but does VS.Net have
> a resource editor?
>
> Thankyou.
>
> Paul
>
>
> Bob Powell [MVP] wrote:
>> You can embed one copy of the button and then get that from the resources
>> using GetManifestResourceStream.
>>



Re: Resources by Paul

Paul
Mon Jul 18 06:12:44 CDT 2005


Thanks Bob,

That's a great help.


Paul


Bob Powell [MVP] wrote:
> Resources come in two flavours. Either stored in a resx file or just added
> to the solution and set as "embedded resource" in the build action
> properties.
>
> For your application it's probably just as easy to do the latter.
>
> Add a resource to the solution, change the build action setting, retrieve it
> useing the following:
>
> Image.FromStream(me.GetType().Assembly.GetManifestResourceStream("myapp.Bitmap1.bmp"))
>
> Note that the actual name you use depends upon the root namespace, whether
> the resource is in a folder and other factors. If you can't deduce the fully
> qualified name to use from your solution structure and namespace etc you can
> put a bit of debug code in to help you. This can be removed later but it
> lists all the resources for you so you can pick up the right one:
>
> Dim resname As String
> For Each resname in me.GetType().Assembly.GetManifestResourceNames
> System.Disagnostics.Trace.WriteLine(resname)
> Next
>