Phidget Examples for Delphi 2005
Instructions for Delphi 7 (see end of document)
(May 26, 2005)

To run these examples, you first need to install the component package PHIDGET.bpl in the Events folder.

goto "Component->Install Packages..." and select the package.

Then you can open up the example projects and they should run.


----------------------------------------------------------------------------------------

Controlling Phidgets from Delphi is best done though the Phidgets COM. To import the COM, choose: "Component->import Component..." Then "Import a Type Library". From the list choose "Phidget Library 2.0".

This creates the file PHIDGET_TLB.pas which contains all of the CoClasses and interfaces for the COM.

To control something, create an instantiantion of it's class, and open the device:

var
	Servo : IPhidgetServo;

...

begin
	Servo:=CoPhidgetServo.Create;
	servo.Open(false,-1);
end;

Dealing with events is a little more complicated. We have included event sink code which was automatically generated from the Phidgets Library using the utility "EventSinkImp" Which can be found here: http://www.techvanguards.com/products/eventsinkimp/

This can be added to the tool palette as components. In Delphi 2005 components have to be added from packages rather then from source files. We've also included the component package for the events. Importing this component package allows you to drag event handling code into your form, and defining event handlers from there is automatic (from the object inspector's Events tab). You can make your own package by Creating a new Delphi Package project and adding the PHIDGETEvents.pas source file, then compiling.

The component package is: PHIDGET.bpl
Add by: "Component->Install Packages..."

This puts the Components in the Tool Palette in the ActiveX category. Just drag one of these into your form. TPHIDGETIPhidgetManagerEvents is quite usefull for detecting phidget attach and detach.

To use the events, you need to attach the event manager to a PhidgetMonitor:

var
	MyManager : IPhidgetManager;

...

begin
	MyManager:=CoPhidgetManager.Create;
	EventManager.Connect(MyManager);
end;

Where EventManager is for example a TPHIDGETIPhidgetManagerEvents component added to the form.

Also, you need to add: PHIDGETEvents, PHIDGET_TLB to your uses statement and make sure the two files are on the search path or part of your project.


See the examples for more information.

----------------------------------------------------------------------------------------
Delphi 7
As we don't have a copy of Delphi 7, these instructions are courtesy of Douglas Tietjen
http://www.delphipages.com/

1) In Delphi 7, choose "Project > Import Type Library", and in the list,
 choose "Phidget Library 2.0 (Version 2.0)".  Then you will click on"Create Unit",
 which should create a new "phidget_TLB.pas" file that is correct tothe phidget.dll
 and for Delphi 7.

2) In Delphi 7 I created a new package and added "phidget_TLB.pas" and "PhidgetEvents.pas"
 into the project.  The .BPL file was created in Delphi 2005 so itdoesn't work the same,
 anyway, I installed my new package that I named "Phidgets.dpk".

3) In the PhidgetEvents.pas I had to remove a couple of events thatare no longer applicable,
 the MarmotEvents and PowerEvents.  Anyway, after that is removed thenit should compile
 the package and everything should work just fine.


PhidgetEvents.pas is created using the included EventSinkImp utility.
