Platforms to show: All Mac Windows Linux Cross-Platform

/Phidgets/Old Phidget Classes/Phidget Manager


Required plugins for this example: MBS Phidgets Plugin, MBS Util Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Phidgets/Old Phidget Classes/Phidget Manager

This example is the version from Sun, 22th Jan 2022.

Project "Phidget Manager.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open() dim f as FolderItem if TargetMachO then f=FindFile("Phidget21.framework") if LoadPhidgetFrameworkMBS(f) then ' MsgBox "Framework loaded" else MsgBox "Failed to load framework" end if elseif TargetWin32 then if LoadPhidgetWindowsDLLMBS("Phidget21.dll") then ' MsgBox "DLL loaded" else MsgBox "Failed to load DLL" end if end if // use LoadPhidgetWindowsDLLMBS on Windows // use LoadPhidgetLinuxLibraryMBS on Linux End EventHandler
Function FindFile(name as string) As FolderItem // Look for file in parent folders from executable on dim parent as FolderItem = app.ExecutableFile.Parent while parent<>Nil dim file as FolderItem = parent.Child(name) if file<>Nil and file.Exists then Return file end if parent = parent.Parent wend End Function
End Class
Class MainWindow Inherits Window
Control list Inherits Listbox
ControlInstance list Inherits Listbox
End Control
EventHandler Sub Open() ' call loadPhidgetFrameworkMBS, LoadPhidgetWindowsDLLMBS or LoadPhidgetLinuxLibraryMBS p=new MyPhidgetManager if p.Handle=0 then MsgBox "Failed to create object." end if if p.Lasterror<>0 then MsgBox "Constructor lasterror: "+str(p.Lasterror) end if p.Open if p.Handle=0 then MsgBox "Failed to create object." end if if p.Lasterror<>0 then MsgBox "Open lasterror: "+str(p.Lasterror) end if DelayMBS 1.0 // wait a second p.getAttachedDevices dim i,c as integer dim d as OldPhidgetMBS c=p.Count-1 for i=0 to c d=p.Device(i) MainWindow.list.AddRow "Device "+str(i+1)+":" MainWindow.list.AddRow " Name: "+d.GetDeviceName MainWindow.list.AddRow " Serialnumber: "+str(d.GetSerialNumber) MainWindow.list.AddRow " Device type: "+str(d.GetDeviceType) MainWindow.list.AddRow " Device label: "+d.GetDeviceLabel MainWindow.list.AddRow "" next End EventHandler
Property p As MyPhidgetManager
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
Class MyPhidgetManager Inherits OldPhidgetManagerMBS
EventHandler Sub Attach(devicehandle as integer) dim p as new OldPhidgetMBS p.Handle=devicehandle MainWindow.list.AddRow "Device attached" MainWindow.list.AddRow " Name: "+p.GetDeviceName MainWindow.list.AddRow " Serialnumber: "+str(p.GetSerialNumber) MainWindow.list.AddRow " Device type: "+str(p.GetDeviceType) MainWindow.list.AddRow " Device label: "+p.GetDeviceLabel MainWindow.list.AddRow "" End EventHandler
EventHandler Sub Detach(devicehandle as integer) dim p as new OldPhidgetMBS p.Handle=devicehandle MainWindow.list.AddRow "Device detached" MainWindow.list.AddRow " Name: "+p.GetDeviceName MainWindow.list.AddRow " Serialnumber: "+str(p.GetSerialNumber) MainWindow.list.AddRow " Device type: "+str(p.GetDeviceType) MainWindow.list.AddRow " Device label: "+p.GetDeviceLabel MainWindow.list.AddRow "" End EventHandler
EventHandler Sub Error(errorCode as integer, errorDescription as string) MainWindow.list.AddRow "Error "+str(errorCode)+": "+errorDescription MainWindow.list.AddRow "" End EventHandler
End Class
End Project

See also:

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


The biggest plugin in space...