Welcome to the new Friends-of-FPC!

Here you can find all kinds of information about the FreePascal Compiler. We have many tutorials and howtos as well as a selection of tools to help you with your programming. We also have some example codes for you. And if you want to contribute some information/ sources/ tools yourself you can do so.
Also we have finally relaunched the FoFPC forum. It's your chance for some Q&A about everything FreePascal.

Friends-of-FPC

Tutorials: Learn how to code with FreePascal.

Source Codes: A collection of examples, miscellaneous source codes and open source stuff.

Tools and Help Files: Intro- duction of some tools that might help you with FPC.

Community

Forum: Ask or answer questions about the FreePascal Compiler, programming or just babble about coding.

Contribute! Contribute your own Tutorial, Source Codes or Tools and send them to us!

Website

About: Information about Friends-of-FPC.org.

Win32/ FPC - Chapter 10 - by Delax

In the last chapter we used a resource file to link an icon into our application. Right now, only the Windows Explorer uses this icon for anything: it displays the icon next to the name of our executable. Now we use the icon in our application as well.

As you might remember, we defined an icon in our Window Class. Only that we didn't have an icon back then and just choose the default application icon. This time we point to our resource icon.

  WinClass.hIcon := LoadIcon(system.MainInstance, makeintresource(1));

LoadIcon() loads an icon resource and makes it accessible to an application. As first parameter we have to define the handle of the application that has the icon stored. The second parameter is either the name of the icon or a resource can be used. But if you want to use a resource then you have to define it with makeintresource(). Remember that this 1 is the ID of our icon inside the resource file as we defined it in the resource script. So basically we load our icon with the ID 1 from our own application.

Because we are using an extended Window Class, we also have to define the hIconSm. This is the icon associated with the Window Class. It can either be set to nil (in which case it uses the icon from hIcon) or just contain the same icon again.

  WinClass.hIconSm := LoadIcon(system.MainInstance, makeintresource(1));

And that's it. Our application now shows the icon in the icon bar next to start and it shows it in the top left corner of our window. It's that simple to use resources in an application. And the best thing is: it doesn't get real harder. Get the source code here. You also need the resource file from the last chapter.

Delax/ Sundancer Inc.
[delax@sundancerinc.de]

Back to previous page

Useful Links









Link to us