Thanks taazz,
I'm new to pascal so I'm sure your code was very self-explanatory, but just consider me ignorant on most things. My C++ Builder experience was years ago as well so I'm trying to get myself back up to speed while handling different ways of doing things.
I've made some progress as follows.
- Created an lrs file with lazres.
- Added LResources to the uses clause.
- Added an initialization clause just before the end. at the end of the Unit1.pas file with {$I myResourceFile.lrs}.
That all seems to compile OK so I assume that the resource is being included in the exe (when I compile without the {$I clause the exe created is 19kB smaller - though the resource file is 59kB on disk).
I've then added your code but am not sure I've put things in the correct place.
- The const clause I have added after the uses clause but before the type clause in Unit1.pas.
- The type declarations I have added to the end; of the TFor1 class declaration in the existing type clause in Unit1.pas.
- The two function declarations I've added right after that.
- The procedure I've added after my other procedures and before the new initialization clause that's including my resource.
When I tried to compile I got an error that seemed to imply that an end; was needed to match the record of TDesignVector so I added that and the compile gets further than that line now.
I'm now getting another two errors though:
unit1.pas(41,87) Error: Identifier not found "LPDWORD"
unit1.pas(41,149) Error: Procedure directive "STDCALL" has conflicts with other directives
unit1.pas(41,149) Fatal: There were 2 errors compiling module, stopping
Looking back at my explanation it's probably worth me pasting that whole definition bit from the top of my Unit1.pas:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
StdCtrls, Unit2, LResources;
const
MM_MAX_NUMAXES = 16; // font embed
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Image1: TImage;
Label1: TLabel;
procedure CloseDialog(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure showImage(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
PDesignVector = ^TDesignVector; // font embed
TDesignVector = packed record // font embed
dvReserved: DWORD; // font embed
dvNumAxes: DWORD; // font embed
dvValues: array[0..MM_MAX_NUMAXES-1] of Longint; // font embed
end;
function AddFontMemResourceEx(p1: Pointer; p2: DWORD; p3: PDesignVector; p4: LPDWORD): THandle; external 'gdi32.dll' name 'AddFontMemResourceEx'; stdcall; // font embed
function RemoveFontMemResourceEx(p1: THandle): BOOL; external 'gdi32.dll' name 'RemoveFontMemResourceEx'; stdcall; // font embed
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
and then my procedures etc follow.
I hope that's not too much of a bombardment.
Oh, and the stupid question... how do I specify the font and resource to load/use? I assume I make it available using LoadFontFromRes('myResourceFile') or is it by font name as in LoadFontFromRes('myFontName')? And do I need to then set that for the controls that use it or will it use the font of the correct name was specified at design time?
Finally, stupid question 2: How do I know the parameter to pass to RemoveFontMemResourceEx?
(I'm really feeling the newbie in me with this one - but all good learning).
Thanks,
FM