Solved

dynamic HTML with image inside a CHtmlView

Posted on 2004-04-10
6
738 Views
Last Modified: 2013-11-20
Hi,

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 ?

Thanks
bk
0
Comment
Question by:bkfirebird
  • 4
  • 2
6 Comments
 
LVL 4

Accepted Solution

by:
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
0
 
LVL 4

Expert Comment

by:caner_elci
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"
0
 
LVL 4

Author Comment

by:bkfirebird
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
bk
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 4

Expert Comment

by:caner_elci
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 : http://www.codeproject.com/tips/res.asp
download the source and take a look at it..
0
 
LVL 4

Author Comment

by:bkfirebird
ID: 10800243
thanks a lot ... you've been a great help
best regards,
bk
0
 
LVL 4

Expert Comment

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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
function returning CString in a regular win32 DLL 8 147
Handling string inputs in C/Linux 23 167
Sed question 2 45
Change to event 1 73
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

707 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now