Click to See Complete Forum and Search --> : Dynamic html pages with dynamic images


lemurien
October 26th, 2004, 10:40 AM
Hello!

I would like to create an application that displays html pages that contain images with CHtmlView.
But (and this is where my problem is) I want my images to be generated on the fly by the application and *not* stored in temporary files.

Is it possible?

- I cannot use the special protocol "res:" <img src="res:..."> because this is static and this does not seem to work from generated pages. (I think it works only when used from html pages stored in resources);
- Then, I wanted to use the protocol "javascript:" <img src="javascript:'GIF87a ...'"> but it seems the web control available through the mfc object CHtmlView is not able to do that... maybe I don't use it properly...

Does anyone have a hint about that?

Thank you!

kirants
October 26th, 2004, 12:36 PM
What do you mean by creating images on the fly ?

Do you mean to say, you want to change the image on the fly ? Or do you want to insert new images ?
Is the HTML text going to change ?

lemurien
October 26th, 2004, 12:47 PM
My application would create images in memory based on the user's actions (following some links). All the content of the page would be generated by the application itself (html + images).
I can already replace the current html document with the method IHTMLDocument2::write(). This works but I have not found a way to inject images in the html document yet :-(.

kirants
October 26th, 2004, 12:53 PM
Hm.. I am not aware of being able to use images from memory. Is using temporary files totally ruled out for you ?

To insert images ( i.e. referenced to temp files ) I believe you need to insert IMG nodes and then also change the HTML Text which references the image.

lemurien
October 26th, 2004, 01:07 PM
The generated images would be based on copyrighted data, so I would prefer not to create temp files.
Indeed, with temp files, you insert IMG nodes and this works.

I thought the following would work with CHtmlView but it does not :(
<img src="javascript:myimage">
where "myimage" is a global javascript variable that contains the image data.

It works with Mozilla!
Unfortunately CHtmlView is based on the Internet Explorer control...

Thank you!

kirants
October 26th, 2004, 01:13 PM
Am sorry.. I am not familiar with JavaScript. Also, I don;t know of any method to use images from memory..

But, if you are using temp files, IMG SRC="temp file path" should work with IE , right ?

lemurien
October 26th, 2004, 01:17 PM
Yes, from temp files this works as expected.

Amn
October 27th, 2004, 07:17 AM
Maybe you could create a virtual drive in memory (search on google, or ask in the forums), put the data there, open the browser with your file, and when your app quits you just destroy the memory disk.

Wouldn't that be a good solution ?

Otherwise you are posed with numerous issues: 1. IE has a different process space, and it is difficult to make it access your memory from its own process space. 2. THere is no HTML abstraction related to memory, HTML documents are files, and memory is not mentioned at all. 3. You could create an ActiveX control which would display an image from memory, but then you cant make it work in any browser but IE.

lemurien
October 27th, 2004, 08:17 AM
If the virtual drive is not visible to other applications but mine than why not... (hmm this would then require direct communication between my application and the ramdisk driver to activate/deactivate it before/after any io operation to prevent other applications from seeing the content... and even, it does not make the content so secured I think. And would not it require admin rights to install the ramdisk driver?)

... and the architecture of the application would become quite complex for such a simple (well I thought at the beginning...) problem after all...

Thank you for your suggestion!

Amn
October 27th, 2004, 08:32 AM
Indeed you are right. You have to be an administrator to install the ramdisk software, and although you dont have to be admin in order to use it, it poses a serious questions though.. Besides, indeed, other applications will see it. Internet Explorer is one of them ;) You cannot encrypt the files, because IE will not be able to decrypt them.

By the way I think there are utilities for creating ramdisks which do not involve tedious programming,...

kirants
October 27th, 2004, 12:19 PM
Isn't creating temp files and then deleting them not an option at all ?