Platforms to show: All Mac Windows Linux Cross-Platform

/MacControls/HTMLViewer Mac/HTMLViewer Image
Function:
Required plugins for this example: MBS MacBase Plugin, MBS Win Plugin, MBS Main Plugin, MBS MacCocoa Plugin, MBS MacControls Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacControls/HTMLViewer Mac/HTMLViewer Image
Project "HTMLViewer Image.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control web Inherits HTMLViewer
ControlInstance web Inherits HTMLViewer
EventHandler Sub Open() me.LoadURL "http://www.monkeybreadsoftware.de/" End EventHandler
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() if not Targetmacho then MsgBox "This button is Mac OS X only." Return end if // Render picture dim n as NSImageMBS = web.RenderWebsiteImageMBS // success? if n=nil then MsgBox "Failed to get image from HTMLViewer." Return end if // make RB picture dim p as Picture = n.CopyPictureWithMask // success? if p = Nil then MsgBox "Failed to get the picture." Return end if // save dim f as FolderItem = GetSaveFolderItem(FileTypes1.Jpeg, "website.jpg") if f<>Nil then f.SaveAsJPEG p end if End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() if not Targetmacho then MsgBox "This button is Mac OS X only." Return end if // set preferences to include background pictures: dim pref as WebPreferencesMBS = web.preferencesMBS dim shouldPrintBackgrounds as Boolean = pref.shouldPrintBackgrounds pref.shouldPrintBackgrounds = true // create PDF dim n as string = web.RenderDocumentToPDFMBS // and restore setting pref.shouldPrintBackgrounds = shouldPrintBackgrounds // success? if len(n)=0 then MsgBox "Failed to get PDF from HTMLViewer." Return end if // save dim f as FolderItem = GetSaveFolderItem(FileTypes1.Pdf, "website.pdf") if f<>Nil then dim b as BinaryStream = f.CreateBinaryFile(FileTypes1.pdf) if b<>Nil then b.Write n end if end if End EventHandler
End Control
Control PushButton3 Inherits PushButton
ControlInstance PushButton3 Inherits PushButton
EventHandler Sub Action() if not TargetWin32 then MsgBox "This button is Windows only." Return end if // save current size dim w as integer = web.Width dim h as integer = web.Height // increase size to web.Width=web.IEScrollWidthMBS+24 web.Height=web.IEScrollHeightMBS+24 // create image dim p as Picture = web.IEImageMBS // and restore size web.Width=w web.Height=h // success? if p = Nil then MsgBox "Failed to get the picture from this website." Return end if // save dim f as FolderItem = GetSaveFolderItem(FileTypes1.Jpeg, "website.jpg") if f<>Nil then f.SaveAsJPEG p end if End EventHandler
End Control
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
FileTypes1
Filetype application/pdf
Filetype image/jpeg
End FileTypes1
End Project

See also:

The items on this page are in the following plugins: MBS MacControls Plugin.

Feedback: Report problem or ask question.

The biggest plugin in space...