Introduction
Recently a user asked if I was going to support synching Phoenix Mail addressbooks with Palm devices. The user also provided a lead to a product called Palm Desktop (Thanks Keith!). This chapter will generally discuss creating Palm Desktop add-ons in Delphi and the author's personal findings in creating them.
Ready. Set. Ding.
First of all, you need to install the Palm Desktop and the (accompanying) Palm Desktop SDK. These files you can find here. Make sure that you install the Desktop, since it will register the needed COM/ActiveX DLLs. After installing the Desktop, you can copy the associated TLB files (provided with the SDK) in your Delphi/Lib directory. This is not really needed, Delphi can also generate them automatically. Now is also a good time to read the SDK/CHM file regarding 'add-ons' or to have it handy.
Dirty laundry anyone?
I'm not going into ActiveX or COM, for now: that's something you can read
in the books. Also I won't go in technical details how those add-ons
interact with Palm Desktop. Read the SDK, thank you very much.
Start your Delphi IDE, New Project, select ActiveX and choose to
generate an ActiveX library. Delphi now has created an 'empty COM/ActiveX
DLL'. Recognize the exports?
Create a new Automation object, and you will be prompted with a dialog
that asks for the name of the new object. Call it FirstPlugIn. Don't
worry about the other 'fields'. You won't need them (for now).
What-you-see-is-not-what-is-there
The Type Library Editor has opened and Delphi has generated an ActiveX
framework for your new class. See the Uses tab? Go there, and right-click
in the listview. Select 'Show All Type Libraries'. Look up the Palm
libraries.
Which one to use, you ask? This depends on what kind of plug-in you want
to make of course. We go for an Addressbook plug-in, so you need several
libs (fig 1.).
Plug-in, plug-in, where art thou?
Now, since we're making a Palm Desktop add-on, we need to find out what and how our new DLL will be 'discovered' as an add-on. Click the Class FirstPlugIn. Select Tab 'Implements'. Right-click on the listview and select 'Insert Interface'. Scroll down to 'IDesktopAddin'. Press OK, and voila, it has been added to your Implements lists (fig. 2).
Now press the 'Refresh' button: see how Delphi now adds the framework for the Palm Desktop add-on?
Who's in command, eh?
What you see in front of you is the basic code framework that makes your
ActiveX Library a Desktop add-on. You've read the SDK, so you found out
that the initialization procedure is where you're going to initialize
the plug-in and where you pass the Palm Desktop application handle. This
part is the easiest part so it won't be explained: the VB and C++ code
are clear.
Since this plug-in is going to 'communicate' with the Addressbook, we still
have to add something. If you've registered an add-on in the Init. procedure,
the Palm Desktop has to execute code at the moment a user presses a
menu and/or toolbutton: we have to make a command, so to speak.
Go back to that Active X dialog, and create a new Automation object.
name it AddressCommand or something. Select the class, go to the Implements
tab and 'Insert a new Interface' and look up 'DesktopCommand'. Press the
'Refresh' button and watch in awe. There you go.
I think you've got the idea that this new unit is going to be the part that is going to deal with your mess. You're not wrong. Lets Roll! Do it.
Can you hear me now? Can you hear me now?
Good: you've made a fantastic plug-in. How do we install it?
There are two ways to install a plug-in: using the Registration services,
or doing it the Easy way. Aye for Easy everyone? Good:
Go to the Project options: enable Version Info. Go to the comments key:
and type in 'DLLname.nameofplugin'. (In our case that'll be
'project1.FirstPlugIn': that's because all my executables are called
project1.exe. Why? That's because I can <G>).
Copy the plug-in (sorry for the confusion, it's officially called an add-on in the SDK) to the directory DeskTopAddIns. Open up your command prompt, navigate to the DeskTopAddins directory (Do I need to explain DOS?), and type in 'regsvr32 thenameofyourfunky.dll'. Mind the quotes. Start-up the Palm Desktop, do a prayer and see if your plug-in is there. If not, read the SDK. If you're still confused, get coding!
STOP THE VIOLATIONS! STOP THE VIOLATIONS!
One-Two-Three, the answer is in the I-D-E: but before you start looking into MAP files, you can also debug the DLL from within your IDE. Go to Run | Parameters dialog and point the edit to your Palm Desktop executable. Now set your breakpoint somewhere (where ever) and press Run.
60 GOTO 10
Quick and dirty it was, for sure, but this should give you a jumpstart. It doesn't mean that you know what's going on, but then, that's not really necessary to know for now. You want to be a Plug-In-Master, right? And if it still doesn't work, sorry: I'm busy.
Thank you very much
These findings are based on a couple of days research and approximately 10 liters of sweat: I had no examples available in Delphi, only C++ and VB examples. Most likely, this will be your only source if you typed in 'Delphi+Palm+Desktop+Plug-in' in Google. So, if you use this doc as a reference, I would appreciate that you add a 'Thanks to Arthur H.' credit and a link to the RoundAbout homepage. Suggestions are welcome. Thanks.