By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,996 Members | 884 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,996 IT Pros & Developers. It's quick & easy.

Saving an image in a WebBrowser in VB6

Robbie
100+
P: 180
Hi yet again!
I'm trying to save an image in a webbrowser in VB6. The image is the only thing on the webbrowser (because I gave the image URL to WebBrowser.Navigate()).

I can not use the Inet control because the site, as many do, blocks that and says that the client I'm using is not authorized to download from the site.
If using Inet you download a page from Google e.g. http://www.google.co.uk/search?hl=en...e+Search&meta= and then look at what you've downloaded, you'll see it says it's not authorized either.

So I have to use the WebBrowser control (or somehow fake another client with the Inet control...?). I'm thinking something along the lines of resizing the control to the width and height of the image which is loaded in it, then blitting the content of the webbrowser to a picturebox. Basically, once it's in a picturebox, I know what to do and can do whatever I like to it.

I know how to blit stuff between pictureboxes:
Expand|Select|Wrap|Line Numbers
  1.         BitBlt PicDest.hDC, _
  2.             0, 0, _
  3.             CurrentWidth, CurrentHeight, _
  4.             PicOrig.hDC, _
  5.             TempX, TempY, _
  6.             vbSrcCopy
  7.  
So my real questions are:
- How do I get the width and height of an image in a WebBrowser?
- Can I blit from a WebBrowser control, and how?
May 1 '07 #1
Share this Question
Share on Google+
3 Replies


Robbie
100+
P: 180
*Many hours later*
Okay... Blitting from a WebBrowser is not possible, and from a form is not an option because the form must always stay perfectly in view fully in the screen and with no other windows on top otherwise you get them.

So! When a web browser views a page, it puts all the downloaded files for a page into a temporary folder. Surely this is the same for WebBrowser? In an HTMLImg object, is there a way to see the filename of this image on this computer (in the temporary download folder), so I can simply copy the file?

Or just to find the temporary download folder, if the temporary image will have the same filename as the original one on the site then I can just look for an image with a certain name and copy it, that would be okay too...

Please help, somebody...
May 2 '07 #2

Dököll
Expert 100+
P: 2,364
*Many hours later*
Okay... Blitting from a WebBrowser is not possible, and from a form is not an option because the form must always stay perfectly in view fully in the screen and with no other windows on top otherwise you get them.

So! When a web browser views a page, it puts all the downloaded files for a page into a temporary folder. Surely this is the same for WebBrowser? In an HTMLImg object, is there a way to see the filename of this image on this computer (in the temporary download folder), so I can simply copy the file?

Or just to find the temporary download folder, if the temporary image will have the same filename as the original one on the site then I can just look for an image with a certain name and copy it, that would be okay too...

Please help, somebody...
Hello, Robbie!

If you already downloaded the image, saved it in a different location, why not load it through Form_Load:

(1) Add a new form
(2) Add this code to Form_Load
(3) Change the image name

Note: you can set up width and height somewhere in the code.
Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Form_Load()
  3. Dim loc As String
  4. Dim Source As String
  5. loc = App.Path & "\image.gif"
  6. Picture1.Visible = False
  7. Picture1.AutoSize = True
  8. Picture1.Picture = LoadPicture(loc)
  9. Animation.Width = Picture1.Width
  10. Animation.Height = Picture1.Height
  11. Source = "about:" & "<html>" & "<body leftMargin=0 topMargin=0 marginheight=0 marginwidth=0 scroll=no>" & "<img src=""" & loc & """></img></body></html>"
  12. Animation.Navigate Source
  13. End Sub
  14.  
  15.  
Also, you can set it to say:

Expand|Select|Wrap|Line Numbers
  1.  
  2. App.Path & "\.gif"
  3.  
  4.  
or any file type you hope will be included in your dowloaded folder or path.

Hopefully this is what you're looking for.

Dököll
May 2 '07 #3

Robbie
100+
P: 180
Thanks Dököll but that's not quite what I was after... >_<
I'm looking for a way to find out the filename of the 'temporary internet file' of any image in a webbrowser control.
Maybe instead I'll try to find some other way round the problem but thanks for trying! ^^;
May 3 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.