Platforms to show: All Mac Windows Linux Cross-Platform
/Win/HTMLViewer Windows/HTMLViewer Image
Required plugins for this example: MBS Win Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Win/HTMLViewer Windows/HTMLViewer Image
This example is the version from Sun, 16th Jan 2021.
Project "HTMLViewer Image.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open()
End EventHandler
End Class
Class MainWindow Inherits Window
Control Image1Button Inherits PushButton
ControlInstance Image1Button Inherits PushButton
EventHandler Sub Action()
// resize web viewer to show full website without scrolling
Dim doc As IEDocumentMBS = web.IEDocumentMBS
If doc <> Nil Then
Dim w As Integer = web.Width
Dim h As Integer = web.Height
web.Width = doc.ScrollWidth + 24
web.Height = doc.ScrollHeight + 24
// now get picture
pic = doc.Image
// restore size
web.Width = w
web.Height = h
out.Invalidate
Else
MsgBox "No website loaded?"
End If
End EventHandler
End Control
Control web Inherits HTMLViewer
ControlInstance web Inherits HTMLViewer
End Control
Control out Inherits Canvas
ControlInstance out Inherits Canvas
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect)
#Pragma unused areas
If pic <> Nil Then
Dim faktor As Double = Min( g.Height / Pic.Height, g.Width / Pic.Width)
// Calculate new size
Dim w As Integer = Pic.Width * faktor
Dim h As Integer = Pic.Height * faktor
// draw picture in the new size
g.DrawPicture Pic, 0, 0, w, h, 0, 0, Pic.Width, Pic.Height
End If
End EventHandler
End Control
Control SaveButton Inherits PushButton
ControlInstance SaveButton Inherits PushButton
EventHandler Sub Action()
If out.Backdrop = Nil Then
Beep
Else
Call ExportPicture(out.Backdrop)
End If
End EventHandler
End Control
Control PrintButton Inherits PushButton
ControlInstance PrintButton Inherits PushButton
EventHandler Sub Action()
// show print dialog
Dim win As IEWindowMBS = web.IEWindowMBS
if win <> nil then
Call win.Print
Else
MsgBox "No website loaded?"
End If
End EventHandler
End Control
Control Image2Button Inherits PushButton
ControlInstance Image2Button Inherits PushButton
EventHandler Sub Action()
// get picture as shown
Dim doc As IEDocumentMBS = web.IEDocumentMBS
If doc <> Nil Then
pic = doc.Image
out.Invalidate
Else
MsgBox "No website loaded?"
End If
End EventHandler
End Control
EventHandler Sub Open()
web.LoadURL "http://www.monkeybreadsoftware.de"
End EventHandler
Property Protected pic As Picture
End Class
MenuBar MenuBar1
MenuItem FileMenu = "File"
MenuItem FileQuit = "Exit"
End MenuBar
End Project
See also:
- /Win/HTMLViewer Windows/Eval Javascript Win
- /Win/HTMLViewer Windows/HTMLViewer execCommand
- /Win/HTMLViewer Windows/HTMLViewer Post and Headers
- /Win/HTMLViewer Windows/IE Properties
- /Win/HTMLViewer Windows/Load HTML Test
- /Win/HTMLViewer Windows/More HTMLViewer Printing
- /Win/HTMLViewer Windows/Reload htmlviewer
- /Win/HTMLViewer Windows/textArea Test/textArea Test
- /Win/HTMLViewer Windows/WebKit - Chromium/Windows WebKit Cookies
- /Win/HTMLViewer Windows/Zoom HMTLViewer
The items on this page are in the following plugins: MBS Win Plugin.