www.jetdv.com Forum Index Edward Troxel
Vegas Scripting and Newsletters
Home of Excalibur and Montage Magic
 
 FAQ   Search   Memberlist   Usergroups   Register   Profile 
 Log in to check your private messagesLog in to check your private messages   Log inLog in 

How do I load an embedded bitmap into a form in a DLL?

 
Post new topic   Reply to topic    www.jetdv.com Forum Index -> Custom DLL FAQ
View previous topic :: View next topic  
Author Message
Randall Campbell



Joined: 20 Aug 2004
Posts: 127
Location: Durham, NC

PostPosted: Thu Aug 26, 2004 4:53 pm    Post subject: How do I load an embedded bitmap into a form in a DLL? Reply with quote

The normal way to load a bitmap image into a form is to use the form designer and add the image to the property (for example, the BackgroundImage of a form). This works fine if you run the form outside of Vegas, but if you run it under Vegas you get a cast error. This is apparently a bug in the .Net Framework.

The workaround is to add the image to your project, then edit the properties of the image file and set the Build Action to Embedded Resource. The add either of the following code snippets after your Initialize Component(); line in your form constructor:
Code:
this.BackgroundImage = new System.Drawing.Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Namespace.Picture.jpg"));

or

this.BackgroundImage = new System.Drawing.Bitmap(GetType().Module.Assembly.GetManifestResourceStream("Namespace.Picture.jpg"));

For this example, the file "Picture.jpg" was added to the project with a namespace of "Namespace" and assigned as the form's background image.
_________________
Randall Campbell
www.peachrock.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.jetdv.com Forum Index -> Custom DLL FAQ All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2.0.11 © 2001, 2002 phpBB Group