Windows Develop Bookmark and Share   
 index > Windows Forms General > Win32 resources and res://
 

Win32 resources and res://

Hi

I'm trying to figure out the best way to embed some resources within an application. The goal is to create an HTML start page for the application, that will have images and maybe some external CSS/Javascript it uses, that will be displayed when the application loads.

The application, when used, will definitely not have Internet access all the time, therefore the start page needs to be within the application itself. I foundan article which outlines a method of achieving exactly what I'm after here. It's a good way of achieving it because I could embed images etc. in the application itself.

Is there a better way to do this?

If not, I'm not clear on how to implement this. I'm using C# and from what I can tell a ".rc" file is associated with C++, not a C# project. Also, the ".res" file is associated with a resource file but if I create a resource file in VS I get a ".resx" file. So, I'm lost on how to go about achieving the result.

If you can help with this I'd appreciated it very much.

Thanks!

grahowler  Sunday, October 26, 2008 11:17 PM
The res:// protocol retrieves a string from an unmanaged resource. Although it is technically possible to add unmanaged resources to a .NET program, the procedure is quite unpratical. The easiest way to do it is to embed a .html file.

Project + Properties, Resources tab, click on arrow of Add Resource button, Add Existing File, navigate to your .html file. Then it is just one line of code to show that in a WB:

webBrowser1.DocumentText = Properties.Resources.SamplePage; // Change the resource name

nobugz  Monday, October 27, 2008 3:20 PM
The res:// protocol retrieves a string from an unmanaged resource. Although it is technically possible to add unmanaged resources to a .NET program, the procedure is quite unpratical. The easiest way to do it is to embed a .html file.

Project + Properties, Resources tab, click on arrow of Add Resource button, Add Existing File, navigate to your .html file. Then it is just one line of code to show that in a WB:

webBrowser1.DocumentText = Properties.Resources.SamplePage; // Change the resource name

nobugz  Monday, October 27, 2008 3:20 PM

Thanks nobugz, that works just fine.

One last question. If I create an HTML file in the project under a folder /StartPage/, which has a nested directory /Images, how do I reference the images in the HTML file? E.g....

I've got the HTML file /StartPage/StartPage.html set as a resource. Then I have an image in a directory /StartPage/Images/MyImage.jpg to add into StartPage.html. When I add the following

<img alt="" src="Images/MyImage.jpg />

to the HTML file it's fine when editing it I can see the image in VS but when I run the application the image does not show and the properties in the browser window show "about:Images/MyImage.jpg".

So how do I reference that image correctly?

Thanks!

grahowler  Monday, October 27, 2008 11:30 PM
Hmya, I expected this. You'll have to store the images in a subdirectory of your bin\debug folder.
nobugz  Tuesday, October 28, 2008 7:15 AM

You can use google to search for other answers

Custom Search

More Threads

• TreeNode HildeSelection Color
• How can I add menu and form into resource as satellite like VC project ?
• TreeView nodes --> Right to left
• Keep two forms both visible!
• How to make a form derived class that can be used as a base class for other forms?
• 'Fastest' or efficient way of checking/comparion for duplication records in listview
• How to read the entire barcode?
• WinForms query
• Mouse Clicked on what?!?!?
• Right-To-Left /Arabic Menu Bug!!!!