Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/USB/Phidget/Phidget Manager
Function:
Required plugins for this example: MBS USB Plugin, MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /USB/Phidget/Phidget Manager
This example is the version from Thu, 6th Apr 2016.
Project "Phidget Manager.rbp"
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 PhidgetMBS 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 PhidgetManagerMBS
EventHandler Sub Attach(devicehandle as integer) dim p as new PhidgetMBS 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 PhidgetMBS 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:

Feedback, Comments & Corrections

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





Links
MBS FileMaker blog