Platforms to show: All Mac Windows Linux Cross-Platform

/WinFrameworks/Windows Location


Required plugins for this example: MBS WinFrameworks Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /WinFrameworks/Windows Location

This example is the version from Fri, 30th Jul 2020.

Project "Windows Location.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Function UnhandledException(error As RuntimeException) As Boolean msgbox Introspection.GetType(error).name + ": " + error.message return true End EventHandler
End Class
Class MainWindow Inherits Window
Control RequestButton Inherits PushButton
ControlInstance RequestButton Inherits PushButton
EventHandler Sub Action() lm.RequestPermissions(self) End EventHandler
End Control
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
EventHandler Sub Open() lm = new WindowsLocationManager '// check status now 'CheckStatus ' ' '// this may raise as no location is available. '#Pragma BreakOnExceptions false ' 'try 'dim t as WindowsLocationMBS = lm.Report ' 'if t <> nil then 'ShowLocation t 'end if ' 'catch e as WindowsLocationExceptionMBS ' 'end try List.AddRow "Start events..." lm.StartEvents End EventHandler
Sub CheckStatus() dim status as integer = lm.ReportStatus ShowStatus status End Sub
Sub ShowLocation(l as WindowsLocationMBS) dim Latitude as Double dim Longitude as double dim LocationAvailable as Boolean dim Altitude as Double dim AltitudeAvailable as Boolean #Pragma BreakOnExceptions false try Latitude = l.Latitude Longitude = l.Longitude LocationAvailable = true catch e as WindowsLocationExceptionMBS // ignore end try try Altitude = l.Altitude AltitudeAvailable = true catch e as WindowsLocationExceptionMBS // ignore end try #Pragma BreakOnExceptions true // show it dim LocationText as string dim AltitudeText as string if LocationAvailable then LocationText = str(Latitude)+"/"+str(Longitude) end if if AltitudeAvailable then AltitudeText = " at "+str(Altitude)+"m height" end if list.AddRow "Location "+LocationText+AltitudeText End Sub
Sub ShowStatus(status as integer) dim t as string Select case status case lm.kLocationReportStatusNotSupported t = "Not supported" case lm.kLocationReportStatusError t = "Error" case lm.kLocationReportStatusAccessDenied t = "Access Denied" case lm.kLocationReportStatusInitializing t = "Initializing" case lm.kLocationReportStatusRunning t = "Running" else t = "Unknown status "+str(status) end Select list.AddRow "Status: "+t End Sub
Property LM As WindowsLocationManager
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class WindowsLocationManager Inherits WindowsLocationManagerMBS
EventHandler Sub LocationChanged(Report as WindowsLocationMBS) if report = nil then break // bug? return end if MainWindow.ShowLocation report End EventHandler
EventHandler Sub StatusChanged(Status as Integer) MainWindow.ShowStatus status End EventHandler
End Class
End Project

See also:

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


The biggest plugin in space...