dynamic HTML with image inside a CHtmlView

Posted on 2004-04-10
Last Modified: 2013-11-20

I am trying to dynamically display a HTML page inside a static picture window. I am using the IDispatch and IHTMLDocument2 interfaces to load the HTML from memory.

At this point, I can display HTML text, tables, etc. but not image resources. If I send a HTML string like <img src="file:///C|/test.jpg" width="201" height="125">, the page is able to find the image on the disk and displays it correctly.

However, my goal is to have the image as a resource in my project and not as a seperate file because i need to distribute the executable file to many people and dont want to give an extra image file.

Can I make the HTML page display images that are resources in my project ?

Question by:bkfirebird
  • 4
  • 2

Accepted Solution

caner_elci earned 350 total points
ID: 10800176
your URL will be something like this:  res://yourapplication.exe/test.jpg

and you will need to import your jpg as "2110" to your application's resources.. That is:

Go to ResourceView, right click, Import, select your .jpg file.. It will ask you the resource type, enter "2110" there.. and Visual Studio will import your image.. Its resource name will be something like IDR_21101.. change it to your picture's name.. just like "sample.jpg" (be careful, use the quotes or you will not be able to access it by res:// locator)

Caner ELCI

Expert Comment

ID: 10800183
By the way, I forgot to tell you about HTML pages... "2110" for image resources.. HTML for html resources.. it's currently known by Visual Studio.. You'll see that in ResourceView. If you can't see, just import some html file and it will be visible as a group.

But, again, name your html pages with quotes, just like "about.html"

Author Comment

ID: 10800220
Thanks a lot caner_elci .... that worked.

just one thing, the quality of the resource image is much worser than when the image is a outside file ... do you know why ?

where can i read more about these "2110" resources ?

thanks again
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


Expert Comment

ID: 10800233
Well, in fact there is nothing to do with the quality, because it only imports your image as a resource. So, image remains the same, but there may be a difference between res:// and file:// in their implementation.. You can try converting your image to a loseless format such as gif or png...

I also did a google search, this sample may help you : 
download the source and take a look at it..

Author Comment

ID: 10800243
thanks a lot ... you've been a great help
best regards,

Expert Comment

ID: 10800245
you're welcome.. have a nice coding..

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Turn a spreadsheet into a vba executable. 2 96
Expand LInux Boot partition remotly 3 98
Define unique primary key 9 95
unix example issues 18 100
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit If you want to manage em…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question