Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically size image in web broswer control

Status
Not open for further replies.
Sep 17, 2001
673
US
I have been able to successfully pass url's to a web browser control (_webbrowser4) in webview.vcx. However I need a way to automatically size the image to the browser box I set. Currently when I pass an image to the browser it is a very large image which requires using scroll bars. Is there a way to make the image fit in the window I define?
 
Hello,

Yes, there is a way.
The html page should have the link to the image as follows:

<IMG SRC=&quot;imagename_here&quot; WIDTH=&quot;new_width_here&quot; HEIGHT=&quot;new_height_here&quot;>.

It will resize automatically, but you should know that resizing an image is a very complex task and the webbrowser doesn't always do a good job.

Hope this helps Grigore Dolghin
Class Software
Bucharest, Romania
 
Well there is no webpage to put the code suggested. I am pointing directly to a file. So here is a sample

Navigate(Cfilesfndfin.Jpg_path)
the jpg_path returns for ex. : \\server\2333.jpg
So with this info what do you suggest to do the resize?
 
This is the code I used to resize the image. Any better suggestions would be appreciated. I don't like to copy to file if I don't have to.

CREATE CURSOR Chtmlstring(htmlstring c(200))
APPEND BLANK
SCATTER MEMVAR
cImageSource = Cfilesfndfin.Jpg_path

cHtmlString = &quot;<IMG SRC='&quot;+ALLTRIM(cImageSource)+&quot;' WIDTH='350' HEIGHT='432'>&quot;
m.htmlstring = cHtmlString
GATHER MEMVAR
COPY TO c:\imagefile.htm SDF
USE IN Chtmlstring
Thisform._webbrowser41.navigate(&quot;c:\imagefile.htm&quot;)
Chtmlstring = &quot;&quot;
cImageSource = &quot;&quot;
 
I ran into this same issue before, and I was never able to figure it out. My way of setting it up would be this:

Create a form property &quot;htmlfile&quot;. In your form.init generate your file name (use sys(2015)+&quot;.html&quot; to create a unique one if you like) and assign the name to the form property.

In the code that generates the image view, use the file name specified in the form property.

In your form Unload event, delete the file pointed to by the property, checking if it exists first (in case no pictures were viewed.)

I wish there was a way to generate an in-memory web page and display it, but I couldn't figure one out myself for the project I made. I ended up wanting to keep a hard copy anyway, so it turned out for the best. :eek:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top