[fpc-pascal]Links in Windows

Gabor DEAK JAHN djg at tramontana.co.hu
Tue Oct 16 12:32:02 CEST 2001


At 10/15/01 06:42 PM, you wrote:

Andreas,

 > how can i create Links in Windows?
 > And more special: how can i create enties in the Windows start-menu?

It depends on the version of Windows as well. Basically, the Start Menu is a
directory somewhere. .LNK files inside this directory will appear as items
on the menu, directories as submenus. You can query the Start Menu directory
using SHGetSpecialFolderPath but you have to be careful because on NT
there are two such directories, one for the current user and one for all
users. On 9x, there is only one such directory but it you use the same
without thinking on NT, the entry will go into the current user part of the
Start Menu and this might not be what the user wants. You have to provide a
way for them to select which part they want to put the menu item into (and
this selection, of course, will have to be grayed out if your setup program
runs on 9x). A very common mistake made by people developing on 9x, I should
say...

The same procedure applies if you want to put an icon onto the desktop as well.

To create the actual links, you have to use a couple of COM interfaces but
it's not that complicated. I have source code for all this in C which can be
converted relatively easily to FPC. You *don't* have to use the 1.1 version of
the compiler to use these COM interfaces, it requires a couple of lines more
and may be slightly less elegant but it works, I do COM/OLE quite often that
way.

 > Is it possible to put icons into fpc programs?
 > What do i need for that?

You probably use dialogs and menus in your programs, the icon goes into the
same resource file. You can reference your .ICO file here (which you can 
create
with a large number of icon editors available from the web):

   #define IDAPPLICON 710
   IDAPPLICON ICON Program.ico

In your program you simply register it where you register your window class:

   ...
   wc.lpszClassName := 'tramfontWndClass';
   wc.lpszMenuName := MAKEINTRESOURCE(IDMAINMENU);
   wc.hCursor := LoadCursor (0, IDC_ARROW);
   wc.hIcon := LoadIcon (0, MAKEINTRESOURCE(IDAPPLICON));
   RegisterClass (wc);


Regards,

   Gabor DEAK JAHN

-------------------------------------------------------------------
Gabor DEAK JAHN -- Budapest, Hungary.
WWW: www.tramontana.co.hu
E-mail: djg at tramontana.co.hu





More information about the fpc-pascal mailing list