Sunday, December 18, 2005

DeskBands with Delphi

Last week, Borland Germany has published my article on Creating DeskBands with Borland Delphi. The source code is available at Borland CodeCentral. Since all, comments in the sources as well as the article is in German I want to give you a few points here. Please forgive me for not translating the article in whole, yet.

What are DeskBands anyway
Well, most of you probably know the quick start bar which comes with Windows XP and/or Internet Explorer 5 to your older versions of Windows. Many of you will even know the way Media Player docks into that very same Windows task bar, or the Google Desktop Bar. All those are built using the same technology: DeskBands.

What do you need
Basically Delphi 4 would help for starting a project. The sample at CodeCentral us built with Delphi 2005. Further I do strongly recommend some virtual environment such as Virtual Machine or MS Virtual PC for testing. This is much faster than doing it on your development machine.

Frist Steps
Start a new ActiveX Project and add a Type Library to it. Now, we need to import the SHDocVw.dll into the project using the ActiveX Import Wizard. Our desk band needs to implement different interfaces, from the imported library as well as from the ActiveX unit.

IDeskBand
This interface is our main candidate. The implemented methods allow us to define our deskband, its title, size, kind, etc.

IPersist, IPersistStream
Those interfaces help us to save the state of the deskband between user sessions. Further does Windows only persist global information (like position, size) of the deskband when tohse interface are declared in our deskband.

IObjectWithSite
A lightweight protocol that allows us to integrate with a host container such as the Windows taskbar.

IContextMenu
I guess the name speaks for itself. It allows us to extend the default context menu.

IInputObject
Some user action, like using the tab key, we want to be handled just as other Windows deskbars do, therefore we need to override some default container behaviuor using the methods of IInputObject.

Installation and Removal
Deskbands are installed using the MS Windows regsvr32-Tool.
regsvr32.exe {Path to DLL}\DemoDeskBar.dll
Uninstalling goes similar using the /u switch.
regsvr32.exe /u {Path to DLL}\DemoDeskBar.dll

Usually you will have to reboot after uninstalling the DLL before you can delete/replace it.

Well, as said above, this will be a short overview only, but most of you will do fine looking at the sources ;-) So have fun and drop me a line if you feel like it.

2 Comments:

Anonymous Anonymous said...

GREAT WORK!!! Sources is very helpful!

3:00 PM  
Anonymous Anonymous said...

Thanks.

I added a form to the example then on the button1click action I added Form1.Show; However it causes an access violation. It it possible to store another form in the deskband?

Thanks for any advice.

7:16 PM  

Post a Comment

<< Home

Google
Search WWW Search delphi-notes.blogspot.com