UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Web Browser Control In Form With Image Size, Access 2013    
 
   
hhagency
post Jan 4 2015, 09:58 PM
Post#1



Posts: 1
Joined: 4-January 15



Currently I am working on a form that has a Web Browser Control. It gets its web address to display from a field.

The address always points to a .jpg file on a web server but the image is coming in so large you have to scroll up and down, left and right to view it all. Is there a way to make the .jpg resize to the window size like a normal browser would display.

I have tried the no scrolling and all the other options that might help this but the images keep showing fullsize reacquiring scrolling
Attached File(s)
Attached File  Capturedb.JPG ( 30.07K )Number of downloads: 5
 
Go to the top of the page
 
jleach
post Jan 5 2015, 08:53 AM
Post#2


UtterAccess Editor
Posts: 10,003
Joined: 7-December 09
From: St Augustine, FL


The web browser page being displayed should have HTML and CSS that defines the size of the image.

CODE
<html><body>
  <div style="width: 100%"><img src="pathtoyourimage" /></div>
</body></html>


(something like that anyway, you'll want to play around a bit to fine tune, but that's the general idea)

see also: http://www.UtterAccess.com/forum/index.php...t&p=2510138

hth
Go to the top of the page
 
doctor9
post Jan 5 2015, 09:27 AM
Post#3


Remembered
Posts: 18,324
Joined: 29-March 05
From: Wisconsin


hhagency,

> The address always points to a .jpg file on a web server

If this is true, it might be simpler to use an Image control, rather than a web browser control. That way you can set the image control's Size Mode to be Zoom, so the picture will always be scaled down to fit inside the control.

I'd think You could use VBA to set the image control's Picture property to be the address of the JPG file. I'm not familiar with doing this sort of thing over a web server (as opposed to over a network), but I suspect it would be the same.

Hope this helps,

Dennis
Go to the top of the page
 
cheekybuddha
post Jan 5 2015, 12:34 PM
Post#4


UtterAccess VIP
Posts: 11,270
Joined: 6-December 03
From: Telegraph Hill


Hi and welcome to UtterAccess! welcome2UA.gif

If you wish to pursue the webbrowser control you can use the following function to load your control:
(paste the following in to a new module)
CODE
Private Function fLoadImg(xWebCtl As Object, strImgPath As String) As Boolean

  Dim strHTML As String
  
  strHTML = "<html>" & vbNewLine & _
            "  <head>" & vbNewLine & _
            "    <script>" & vbNewLine & _
            "      function set_orientation(imgID){" & vbNewLine & _
            "        var imgPass = document.getElementById('myImg');" & vbNewLine & _
            "        var width = imgPass.width;" & vbNewLine & _
            "        var height = imgPass.height;" & vbNewLine & _
            "        if(width > height) {" & vbNewLine & _
            "          imgPass.style.width = '100%';" & vbNewLine & _
            "        } else {" & vbNewLine & _
            "          imgPass.style.height = '100%';" & vbNewLine & _
            "        }" & vbNewLine & _
            "        return 0;" & vbNewLine & _
            "      }" & vbNewLine & _
            "    </script>" & vbNewLine & _
            "  </head>" & vbNewLine & _
            "  <body>" & vbNewLine & _
            "    <div style='width: 100%'>" & vbNewLine & _
            "      <img id='myImg' onload='set_orientation(" & Chr(34) & "myImg" & Chr(34) & ")' src='" & strImgPath & "' />" & vbNewLine & _
            "    </div>" & vbNewLine & _
            "  </body>" & vbNewLine & _
            "</html>"
  
  With xWebCtl
    .Navigate ABOUT_BLANK
    Call fWaitComplete(.Object)
    If Len(strHTML) Then
      .Document.Write strHTML
      Call fWaitComplete(.Object)
    End If
  End With

End Function

Public Function fWaitComplete(objWB As Object, _
                              Optional iTimeoutSecs As Integer = 20) As Boolean

  Const READYSTATE_COMPLETE As Integer = 4
  Dim dtStart As Date
  
  dtStart = Now
  With objWB
    Do While .ReadyState <> READYSTATE_COMPLETE   '   Or .Busy
      If DateDiff("s", dtStart, Now) > iTimeoutSecs Then Exit Function
      DoEvents
    Loop
    fWaitComplete = .ReadyState = READYSTATE_COMPLETE
  End With

End Function


Then, you can load the control from some event on the form like:
CODE
Private Sub Form_Load()

  Call fLoadImg(Me.xWeb, "C:\Path\To\Your\Image.jpg")

End Sub


No need for an external html file - it wrire the html (and javascript to determine whether your image is portrait/landscape) directly in the the page.

hth,

d
Go to the top of the page
 
cheekybuddha
post Jan 5 2015, 12:36 PM
Post#5


UtterAccess VIP
Posts: 11,270
Joined: 6-December 03
From: Telegraph Hill


wrire = writes blush.gif
Go to the top of the page
 
theDBguy
post Jan 5 2015, 12:46 PM
Post#6


Access Wiki and Forums Moderator
Posts: 75,505
Joined: 19-June 07
From: SunnySandyEggo


Hi,

Welcome to UtterAccess!

If you use an Image Control as Dennis suggested, you won't need VBA to assign the image. You can just bind the control to the field that stores the path of the image. Just a thought...
Go to the top of the page
 
jleach
post Jan 5 2015, 12:47 PM
Post#7


UtterAccess Editor
Posts: 10,003
Joined: 7-December 09
From: St Augustine, FL


We've got two active threads on loading images smile.gif In my previous reply I linked to an ongoing thread where a member was trying to avoid the "loading image" dialog in 2003... and I've since directed him here to have a look at David's function (I never got around to wrapping up a neat little function for it, myself).

:runningincircles:

Cheers,
Go to the top of the page
 
theDBguy
post Jan 5 2015, 12:53 PM
Post#8


Access Wiki and Forums Moderator
Posts: 75,505
Joined: 19-June 07
From: SunnySandyEggo


Hi Jack, it seems to me that both posters might have to swap techniques. This thread is dealing with using a browser control that might be better served using an Image control instead. On the other hand, the other thread may be using an Image control that might be better served using a browser control instead.
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    15th June 2019 - 03:49 PM