<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									Delphi, Lazarus, Free Pascal - Forum				            </title>
            <link>https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/</link>
            <description>Tweaking4All.com Discussion Board</description>
            <language>en-US</language>
            <lastBuildDate>Tue, 21 Jul 2026 00:45:10 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>Lazarus Pascal - Git - How to make a clean patch file (Diff) by excluding certain files</title>
                        <link>https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-git-how-to-make-a-clean-patch-file-diff-by-excluding-certain-files/</link>
                        <pubDate>Tue, 19 May 2026 17:13:05 +0000</pubDate>
                        <description><![CDATA[Making a modification I learned how to exclude certain files when making a patch file (thanks n7800!).
Normally one would use
git diff &gt; todo.patch
But with Lazarus Pascal this would c...]]></description>
                        <content:encoded><![CDATA[<p>Making a modification I learned how to exclude certain files when making a patch file (thanks n7800!).</p>
<p>Normally one would use</p>
<pre contenteditable="false">git diff &gt; todo.patch</pre>
<p>But with Lazarus Pascal this would come with unwanted <strong>PO</strong> and <strong>POT</strong> (translation) files, and (under macOS anyway) <strong>lazarus.app</strong> and <strong>startlazarus.app</strong> (<span style="color: #0000ff">exclude</span> sections).<br />Sometimes it also coms with unwanted white space which we'd like to exclude as well (<span style="color: #0000ff">-w</span> option).</p>
<p>All options together this would make</p>
<pre contenteditable="false">git diff -- . ':(exclude)*.po' ':(exclude)*.pot' ':(exclude)lazarus.app' ':(exclude)startlazarus.app' -w &gt; mychanges.patch</pre>
<p>Running this in the Lazarus directory will create a nice and clean Diff file (for small changes).</p>
<p>Hope this is useful for others, at least a nice reminder for myself.</p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/">Delphi, Lazarus, Free Pascal</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-git-how-to-make-a-clean-patch-file-diff-by-excluding-certain-files/</guid>
                    </item>
				                    <item>
                        <title>Lazarus Pascal - macOS - Determine if the screen is locked or not</title>
                        <link>https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-macos-determine-if-the-screen-is-locked-or-not/</link>
                        <pubDate>Fri, 30 Jan 2026 11:43:50 +0000</pubDate>
                        <description><![CDATA[Based on a user request, I had to figure out if a screen is locked or not.So with some tinkering (thank you StackExchange!) I found 2 ways to handle this.

Check if the screen is locked or...]]></description>
                        <content:encoded><![CDATA[<p>Based on a user request, I had to figure out if a screen is locked or not.<br />So with some tinkering (thank you StackExchange!) I found 2 ways to handle this.</p>
<ol>
<li>Check if the screen is locked or not with a simple one time call</li>
<li>With the system notifying my application that the lock state changed (so we do not have to poll if a screen is locked or not)</li>
</ol>
<p>So for this I made a little unit - feel free to use/modify/etc:</p>
<pre contenteditable="false">unit t4a_macOS_ScreenLocked;

{$mode ObjFPC}{$H+}
{$modeswitch objectivec1}

interface

uses
  Classes, SysUtils, MacOSAll, Forms, process, CocoaAll, CocoaUtils;


type
  TScreenLockUnlockCallback = procedure(isScreenLocked:boolean) of object;

{ T4ALIB - Check if the screen is locked or not (eg. Login screen shows). }
function CheckIfScreenLocked: Boolean;


{ Use Notifications by system}
procedure ScreenLockCallback(Center: CFNotificationCenterRef;
                             Observer: Pointer;
                             Name: CFStringRef;
                             Object_: Pointer;
                             UserInfo: CFDictionaryRef); mwpascal;
procedure RegisterScreenLockNotifications(OptionalCallbackProcedure:TScreenLockUnlockCallback = nil);
procedure UnregisterScreenLockNotifications;

var
  ScreenIsLocked    : boolean; // used for notifications
  CallbackProcedure : TScreenLockUnlockCallback;

implementation

// Onetime call/check
function CheckIfScreenLocked: Boolean;
var
  SessionDict: CFDictionaryRef;
  ValueRef: CFTypeRef;
begin
  Result := False;

  SessionDict := CGSessionCopyCurrentDictionary;
  if SessionDict &lt;&gt; nil then
  begin
    if CFDictionaryGetValueIfPresent(
         SessionDict,
         CFSTR('CGSSessionScreenIsLocked'),
         @ValueRef
       ) then
    begin
      if CFGetTypeID(ValueRef) = CFBooleanGetTypeID then
        Result := CFBooleanGetValue(CFBooleanRef(ValueRef));
    end;

    CFRelease(SessionDict);
  end;

  ScreenIsLocked := Result;
end;

// Notification by system
procedure ScreenLockCallback(Center: CFNotificationCenterRef;
                             Observer: Pointer;
                             Name: CFStringRef;
                             Object_: Pointer;
                             UserInfo: CFDictionaryRef); mwpascal;
var
  NotificationName: String;
begin
  NotificationName := CFStringToString(Name);

  ScreenIsLocked := (NotificationName =  'com.apple.screenIsLocked') and
                    (NotificationName &lt;&gt; 'com.apple.screenIsUnlocked');

  if Assigned(CallbackProcedure) then CallbackProcedure(ScreenIsLocked);
end;

procedure RegisterScreenLockNotifications(OptionalCallbackProcedure:TScreenLockUnlockCallback = nil);
var
  Center: CFNotificationCenterRef;
begin
  CallbackProcedure := OptionalCallbackProcedure;

  Center := CFNotificationCenterGetDistributedCenter;

  CFNotificationCenterAddObserver(
    Center,
    nil, // observer
    @ScreenLockCallback,
    CFSTR('com.apple.screenIsLocked'),
    nil,
    CFNotificationSuspensionBehaviorDeliverImmediately
  );

  CFNotificationCenterAddObserver(
    Center,
    nil,
    @ScreenLockCallback,
    CFSTR('com.apple.screenIsUnlocked'),
    nil,
    CFNotificationSuspensionBehaviorDeliverImmediately
  );
end;

procedure UnregisterScreenLockNotifications;
var
  Center: CFNotificationCenterRef;
begin
  Center := CFNotificationCenterGetDistributedCenter;
  CFNotificationCenterRemoveObserver(Center, nil, nil, nil);
end;

finalization

  UnregisterScreenLockNotifications;

end.</pre>
<p>&nbsp;</p>
<p>Use:</p>
<p>1. One time check:</p>
<p>Just call "<strong>CheckIfScreenLocked</strong>", which returns TRUE if the screen is locked.</p>
<p>2. Using notifications:</p>
<p>- define a <strong>public</strong> function that can be called when the screen locked state changes:</p>
<pre contenteditable="false">// your own procedure
procdure TForm1.ScreenLockChanged(locked:boolean);   { public! }
begin
  if locked the writeln('locked');
end;  </pre>
<p>- In the onCreate event of your form, activate the notification observer</p>
<pre contenteditable="false">procedure TForm1.FormCreate(Sender: TObject);
begin
   RegisterScreenLockNotifications(@ScreenLockChanged);
end;</pre>
<p>(the observer will be unregistered automatically when your application closes, or you can call "<strong>UnregisterScreenLockNotifications</strong>")</p>
<p>&nbsp;</p>
<p>Hope this is of use to someone out there &#x1f609; </p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/">Delphi, Lazarus, Free Pascal</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-macos-determine-if-the-screen-is-locked-or-not/</guid>
                    </item>
				                    <item>
                        <title>Lazarus Pascal - Better image scaling for TImage</title>
                        <link>https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-better-image-scaling-for-timage/</link>
                        <pubDate>Fri, 09 Jan 2026 12:44:49 +0000</pubDate>
                        <description><![CDATA[Specifically with Windows, I noticed how poorly a TImage scales.With a little trick you can redraw the image using a different type of interpolation like so:
procedure BetterScaleImage(AWid...]]></description>
                        <content:encoded><![CDATA[<p>Specifically with Windows, I noticed how poorly a TImage scales.<br />With a little trick you can redraw the image using a different type of interpolation like so:</p>
<pre contenteditable="false">procedure BetterScaleImage(AWidth, AHeight: Integer; sourceImage:Timage);
var
  srcImg, destImg: TLazIntfImage;
  cnv: TLazCanvas;
  interp: TFPBaseInterpolation;
begin
  if sourceImage.Picture.Bitmap = nil then Exit;

  srcImg := sourceImage.Picture.Bitmap.CreateIntfImage;
  destImg := TLazIntfImage.CreateCompatible(srcImg, AWidth, AHeight);

  try
    cnv := TLazCanvas.Create(destImg);
    try
      interp := TFPBaseInterpolation.Create;
      try
        cnv.Interpolation := interp;
        cnv.StretchDraw(0, 0, AWidth, AHeight, srcImg);

        sourceImage.Picture.Bitmap.LoadFromIntfImage(destImg);

      finally
        interp.Free;
      end;
    finally
      cnv.Free;
    end;
  finally
    destImg.Free;
    srcImg.Free;
  end;
end;                        </pre>
<p>After loading an image in your TImage, simply call BetterScaleImage(width,height,TImage) to scale it better.<br />Under Windows this will be a world of difference. </p>
<p>Enjoy!</p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/">Delphi, Lazarus, Free Pascal</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-better-image-scaling-for-timage/</guid>
                    </item>
				                    <item>
                        <title>Lazarus Pascal - How to load the application icon into a TImage from resources</title>
                        <link>https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-how-to-load-the-application-icon-into-a-timage-from-resources/</link>
                        <pubDate>Fri, 09 Jan 2026 12:40:39 +0000</pubDate>
                        <description><![CDATA[To build an About box, I wanted to grab the application cion as I had set it in project options, just so I could make this universal and without the need of extra files.Took me a minute to f...]]></description>
                        <content:encoded><![CDATA[<p>To build an About box, I wanted to grab the application cion as I had set it in project options, just so I could make this universal and without the need of extra files.<br />Took me a minute to figure this out, so I'm posting it here in hopes it will save someone a headache &#x1f609; </p>
<p>Preconditions:<br />Make sure you have assigned an icon to your application, in Project Options!<br />As a target I used a regular Timage, and the unit I'm working in does not need to be the main unit.</p>
<p>Code:</p>
<pre contenteditable="false">Image1.Picture.LoadFromResourceName(HINSTANCE, 'MAINICON'); // Grab icon from Application</pre>
<p>This will load the main icon into "Image1".</p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/">Delphi, Lazarus, Free Pascal</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-how-to-load-the-application-icon-into-a-timage-from-resources/</guid>
                    </item>
				                    <item>
                        <title>Lazarus Pascal - Possible fix for a corrupted LPI</title>
                        <link>https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-possible-fix-for-a-corrupted-lpi/</link>
                        <pubDate>Fri, 09 Jan 2026 11:41:43 +0000</pubDate>
                        <description><![CDATA[So I had this the other day: I had a project developed under macOS and opened it under Windows to compile it there.Oddly enough, opening the project under macOS would crash the IDE, which co...]]></description>
                        <content:encoded><![CDATA[<p>So I had this the other day: I had a project developed under macOS and opened it under Windows to compile it there.<br />Oddly enough, opening the project under macOS would crash the IDE, which comes with that nervous feeling you just ruined your entire project.</p>
<p>So the project would still open under Windows correctly.<br />Opening it under macOS (not simultaneously of course) would give an error and the option to retry which then would crash the IDE.</p>
<p>In an attempt to debug this I used the Lazarus debug option:</p>
<pre contenteditable="false">./lazarus --debug-log=~/lazaruslog.txt</pre>
<p>Note that I'm starting Lazarus from Terminal, and am using the "lazarus" binary - <span style="color: #ff0000">not</span> the <strong>lazarus.app</strong>, and <span style="color: #ff0000">not</span> <strong>startlazarus</strong>!</p>
<p>The resulting log file was rather useless, but ... Lazarus did open and fixed the LPI file once I saved and closed Lazarus again.</p>
<p>Now this is obviously not what the debug function is for, but it saved my project.<br />Just posting it here in case it is of use to anyone.</p>
<p>Note: this does not always work of course!</p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/">Delphi, Lazarus, Free Pascal</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-possible-fix-for-a-corrupted-lpi/</guid>
                    </item>
				                    <item>
                        <title>Lazarus Pascal - Natural Sort string compare function</title>
                        <link>https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-natural-sort-string-compare-function/</link>
                        <pubDate>Mon, 22 Dec 2025 13:15:47 +0000</pubDate>
                        <description><![CDATA[The biggest issue with sorting text strings is that simple string comparison won&#039;t cut it for us humans. (Wiki)
For example, let&#039;s say we have this list:
file 3.txt
file 2.txt
file 10.tx...]]></description>
                        <content:encoded><![CDATA[<p>The biggest issue with sorting text strings is that simple string comparison won't cut it for us humans. (<a href="https://en.wikipedia.org/wiki/Natural_sort_order" target="_blank" rel="noopener">Wiki</a>)</p>
<p>For example, let's say we have this list:</p>
<pre contenteditable="false">file 3.txt
file 2.txt
file 10.txt
file 9.txt
file 1.txt
</pre>
<p>Regular sorting would produce this:</p>
<pre contenteditable="false">file 1.txt
file 10.txt
file 2.txt
file 3.txt
file 9.txt
</pre>
<p>But that is not how we humans sort, we'd like to see (called "natural sort"):</p>
<pre contenteditable="false">file 1.txt
file 2.txt
file 3.txt
file 9.txt
file 10.txt</pre>
<p>In case you have seen my QuickSort examples (for example <a href="https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-quicksort-tstringlist-to-quicksort-array-of-records/" target="_blank" rel="noopener">this one</a> - I'll add the code below), you'll see that we often use "<a href="https://www.freepascal.org/docs-html/3.2.0/rtl/sysutils/stricomp.html" target="_blank" rel="noopener">StrIcomp</a>" to compare 2 strings to see which one goes first. Unfortunately results in the wrong output I just showed. So I wrote a "drop in" replacement for this "NaturalCompare". Simply replace the StrIcomp with NaturalCompare and the QuickSort will now produce a natural sorted list.</p>
<pre contenteditable="false">function NaturalCompare(const S1, S2: string): Integer;
var
  I, J: Integer;
  N1, N2: Int64;
  C1, C2: Char;
begin
  I := 1;
  J := 1;

  while (I &lt;= Length(S1)) and (J &lt;= Length(S2)) do
  begin
    C1 := S1;
    C2 := S2;

    // If both characters are digits, compare numbers
    if (C1 in ) and (C2 in ) then
    begin
      N1 := 0;
      while (I &lt;= Length(S1)) and (S1 in ) do
      begin
        N1 := N1 * 10 + Ord(S1) - Ord('0');
        Inc(I);
      end;

      N2 := 0;
      while (J &lt;= Length(S2)) and (S2 in ) do
      begin
        N2 := N2 * 10 + Ord(S2) - Ord('0');
        Inc(J);
      end;

      if N1 &lt;&gt; N2 then
        Exit(N1 - N2);
    end
    else
    begin
      // Case-insensitive character compare
      C1 := UpCase(C1);
      C2 := UpCase(C2);

      if C1 &lt;&gt; C2 then
        Exit(Ord(C1) - Ord(C2));

      Inc(I);
      Inc(J);
    end;
  end;

  // If all equal so far, shorter string comes first
  Result := Length(S1) - Length(S2);
end;                                                           </pre>
<p>&nbsp;</p>
<p>Example QuickStort procedure:</p>
<pre contenteditable="false">procedure QuickSort(var A: TStringList);
  procedure Sort(L, R: Integer);
  var
    I, J: Integer;
    Y, X:string;
  begin
    I:= L; J:= R; X:= A;

    repeat
      // was:  while StrIcomp(pchar(A),pchar(X))&lt;0 do inc(I);
      // was:  while StrIComp(pchar(X),pchar(A))&lt;0 do dec(J); 

      while NaturalCompare(pchar(A),pchar(X))&lt;0 do inc(I);
      while NaturalCompare(pchar(X),pchar(A))&lt;0 do dec(J); 

      if I &lt;= J then
        begin
          Y:= A; A:= A; A:= Y;
          inc(I); dec(J);
        end;
    until I &gt; J;

    if L &lt; J then Sort(L,J);
    if I &lt; R then Sort(I,R);
  end;
begin
  Sort(0,A.Count-1);
end;</pre>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/">Delphi, Lazarus, Free Pascal</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-natural-sort-string-compare-function/</guid>
                    </item>
				                    <item>
                        <title>Lazarus Pascal - How to get a Transparent TPanel</title>
                        <link>https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-how-to-get-a-transparent-tpanel/</link>
                        <pubDate>Thu, 18 Dec 2025 13:32:16 +0000</pubDate>
                        <description><![CDATA[Sometimes we use a TPanel for layout purposes, and in those cases the Panel should sometimes be transparent.
After having gone through numerous options, I found this to work under macOS/Coc...]]></description>
                        <content:encoded><![CDATA[<p>Sometimes we use a TPanel for layout purposes, and in those cases the Panel should sometimes be transparent.</p>
<p>After having gone through numerous options, I found this to work under macOS/Cocoa (using FPC Trunk);</p>
<p>Originally this only worked under Windows, but it seems to work with Cocoa (with Lazarus 4.99 or newer - I am using trunk)</p>
<pre contenteditable="false">YourPanel.ControlStyle := YourPanel.ControlStyle -  + ;</pre>
<p>&nbsp;</p>
<p>As it took me quite a while to figure this one out: I hope this is helpful to someone &#x1f60a; </p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/">Delphi, Lazarus, Free Pascal</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-how-to-get-a-transparent-tpanel/</guid>
                    </item>
				                    <item>
                        <title>Lazarus Pascal - macOS - How to use the standard &quot;About&quot; dialog box that comes with Cocoa</title>
                        <link>https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-macos-how-to-use-the-standard-about-dialog-box-that-comes-with-cocoa/</link>
                        <pubDate>Mon, 17 Nov 2025 16:13:19 +0000</pubDate>
                        <description><![CDATA[Cocoa has a build in function that automatically generates an About dialog box (documentation) and is super easy to use and implement.
An About dialog is generated on the fly and called lik...]]></description>
                        <content:encoded><![CDATA[<p>Cocoa has a build in function that automatically generates an About dialog box (<a href="https://developer.apple.com/documentation/AppKit/NSApplication/orderFrontStandardAboutPanel(_:)" target="_blank" rel="noopener">documentation</a>) and is super easy to use and implement.</p>
<p>An About dialog is generated on the fly and called like so (assuming your application has Info.plist file in the .app bundle);</p>
<pre contenteditable="false">...
{$modeswitch objectivec1}
...
Uses ..., CocoaAll, ... ;
...

// Opendialog like so:
NSApp.orderFrontStandardAboutPanel(Nil);

...</pre>
<p>Example:</p>
796
<p>There are a few requirements and options to make it work nice which require a proper Info.plist file in your App bundle (myapplication.app/Contents/Info.plist)</p>
<p>&nbsp;</p>
<p><span style="color: #0000ff"><strong>Things that go in the Info.plist file:</strong></span></p>
<p><strong>CFBundleIconFile</strong> - defines the Icon you'll see in the About dialog. This is also the icon used by your application, typically located in the Resources dir (something like: myapplication.app/Contents/Resources/myapplication.icns -&gt; use "myapplication.icns"). If not defined, a generic icon will be displayed.</p>
<p><strong>CFBundleName</strong> - which represents the Application Name as shown in the About dialof.</p>
<p><strong>CFBundleShortVersionString</strong> - holds the version number (Version 1.2.3), and if missing it will probably display something generic like "1.0".</p>
<p><strong>CFBundleVersion</strong> - Displays the build number between parentheses.</p>
<p><strong>NSHumanReadableCopyright</strong> - holds the copyright name, eg. John Doe.</p>
<p>Something like this</p>
<pre contenteditable="false">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
  ...
  &lt;key&gt;CFBundleIconFile&lt;/key&gt;
  &lt;string&gt;TinyHTMLEditor.icns&lt;/string&gt;
  &lt;key&gt;CFBundleName&lt;/key&gt;
  &lt;string&gt;TinyHTMLEditor&lt;/string&gt;
  &lt;key&gt;CFBundleShortVersionString&lt;/key&gt;
  &lt;string&gt;1.0.0&lt;/string&gt;
  &lt;key&gt;CFBundleVersion&lt;/key&gt;
  &lt;string&gt;1&lt;/string&gt;
  &lt;key&gt;NSHumanReadableCopyright&lt;/key&gt;
  &lt;string&gt;Copyright 2025, Hans Luijten&lt;/string&gt;
  ...
&lt;/dict&gt;
&lt;/plist&gt;</pre>
<p>&nbsp;</p>
<p><span style="color: #0000ff"><strong>Optional Credits text:</strong></span></p>
<p>Optionally you can create a Credits file in myapplication.app/Contents/Resources/.<br />This can be html (<strong>Credits.html</strong>), or RichText (<strong>Credits.rtf</strong> or <strong>Credits.rtfd</strong> - see <a href="https://developer.apple.com/documentation/appkit/nsapplication/aboutpaneloptionkey/credits" target="_blank" rel="noopener">documentation</a>).</p>
<p>The file needs to sit in the <strong>Resources directory</strong> and this file can be capital sensitive (depending on the filesystem your Mac uses).</p>
<p>The Credits.html file can even hold links (unlike RichText files), something simple like this:</p>
<pre contenteditable="false">&lt;center&gt;
&lt;p&gt;
Developed with &lt;a href="https://www.lazarus-ide.org/"&gt;Lazarus Pascal&lt;/a&gt;
&lt;/p&gt;
&lt;strong&gt;Support&lt;/strong&gt;
&lt;p&gt;
Contact us for support at&lt;br&gt;
&lt;a href="https://www.tweaking4all.com"&gt;www.Tweaking4All.com&lt;/a&gt;
&lt;/p&gt;
&lt;/center&gt;</pre>
<p>Note that at runtime, you can close the dialog, change the HTML and re-open the dialog again to see the changes.<br />No need to recompile or restart your Lazarus application &#x1f60a; </p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/">Delphi, Lazarus, Free Pascal</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-macos-how-to-use-the-standard-about-dialog-box-that-comes-with-cocoa/</guid>
                    </item>
				                    <item>
                        <title>Lazarus Pascal - macOS - How to read or write extended attributes of files or directories</title>
                        <link>https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-macos-how-to-read-or-write-extended-attributes-of-files-or-directories/</link>
                        <pubDate>Wed, 22 Oct 2025 17:09:53 +0000</pubDate>
                        <description><![CDATA[Took me some time to do this in Lazarus Pascal, but here an example how to add an attribute to the extended attributes of a file or directory under macOS (most likely works under Linux as we...]]></description>
                        <content:encoded><![CDATA[<p>Took me some time to do this in Lazarus Pascal, but here an example how to add an attribute to the extended attributes of a file or directory under macOS (most likely works under Linux as well). It uses the Lib C functions <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getxattr.2.html" target="_blank" rel="noopener">getxattr</a> and <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setxattr.2.html" target="_blank" rel="noopener">setxattr</a>. There is also <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/removexattr.2.html" target="_blank" rel="noopener">removeattr</a> for those interested.</p>
<p>A simple unit I created for my own purposes, but maybe someone can use it as well:</p>
<pre contenteditable="false">unit t4a_macOS_XAttr;

{$mode ObjFPC}{$H+}

interface

uses
  SysUtils, ctypes, unixtype;

const
  // macOS extended attribute functions are in libc
  libc = 'c';

  function ReadXAttrInt(const FileName, AttrName: String): Integer;
  function WriteXAttrInt(const FileName, AttrName: String; const Value: Integer): Boolean;

function getxattr(path: PChar; name: PChar; value: Pointer; size: size_t; position: cuint; options: cint): ssize_t; cdecl; external libc name 'getxattr';
function setxattr(path: PChar; name: PChar; value: Pointer; size: size_t; position: cuint; options: cint): cint; cdecl; external libc name 'setxattr';

implementation

// Reads an integer extended attribute. Returns 0 if not found.
function ReadXAttrInt(const FileName, AttrName: String): Integer;
var
  Value: Integer;
  BytesRead: ssize_t;
begin
  FillChar(Value, SizeOf(Value), 0);
  BytesRead := getxattr(PChar(FileName), PChar(AttrName), @Value, SizeOf(Value), 0, 0);
  if BytesRead = -1 then
    Result := 0 // Attribute missing or error
  else
    Result := Value;
end;

// Writes an integer extended attribute.
function WriteXAttrInt(const FileName, AttrName: String; const Value: Integer): Boolean;
var
  Ret: cint;
begin
  Ret := setxattr(PChar(FileName), PChar(AttrName), @Value, SizeOf(Value), 0, 0);
  Result := (Ret = 0);
end;

end.  </pre>
<p>&nbsp;</p>
<p>Example on how to use this:</p>
<pre contenteditable="false">procedure TForm1.Button1Click(Sender: TObject);
var
  AttributeName: string;
  AttributeNumber, ReadBack: integer;
  Filename: string;
begin
  AttributeName := 'user.myattributename'; // usually starts with "user."
  AttributeNumber := 100;
  Filename := '/path/to/mydirectory'; // can be a directory or a file

  if WriteXAttrInt(Filename, AttributeName, AttributeNumber) then
    ShowMessage('Wrote attribute '+ AttributeName+ ' = '+ IntToStr(AttributeNumber))
  else
    ShowMessage('Failed to write attribute');

  ReadBack := ReadXAttrInt(Filename, AttributeName);
  ShowMessage('Read attribute '+ AttributeName+ ' = '+ IntToStr(ReadBack));
end;</pre>
<p>Enjoy ....</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/">Delphi, Lazarus, Free Pascal</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-macos-how-to-read-or-write-extended-attributes-of-files-or-directories/</guid>
                    </item>
				                    <item>
                        <title>Lazarus Pascal - Quicksort an Array of string, by the length of the strings</title>
                        <link>https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-quicksort-an-array-of-string-by-the-length-of-the-strings/</link>
                        <pubDate>Fri, 10 Oct 2025 16:46:51 +0000</pubDate>
                        <description><![CDATA[Had to write a procedure that sorts an array of strings (dynamic) by the length of the individual strings.Thought someone may find this useful:
// QuickSort array of string by string length...]]></description>
                        <content:encoded><![CDATA[<p>Had to write a procedure that sorts an array of strings (dynamic) by the length of the individual strings.<br />Thought someone may find this useful:</p>
<pre contenteditable="false">// QuickSort array of string by string length
procedure QuickSortByLength(ListOfStrings: array of string; Start: integer = -1; Stop: Integer = -1);
var
  i, j, PivotLen: Integer;
  Pivot: string;
  Temp: string;
begin
  if (Start=-1) or (Stop=-1) then
    begin
      Start := 0;
      Stop  := Length(ListOfStrings)-1;
    end;

  i := Start;
  j := Stop;
  Pivot := ListOfStrings;
  PivotLen := Length(Pivot);

  repeat
    while Length(ListOfStrings) &lt; PivotLen do Inc(i);
    while Length(ListOfStrings) &gt; PivotLen do Dec(j);

    if i &lt;= j then
      begin
        Temp := ListOfStrings;
        ListOfStrings := ListOfStrings;
        ListOfStrings := Temp;
        Inc(i);
        Dec(j);
      end;
  until i &gt; j;

  if Start &lt; j then QuickSortByLength(ListOfStrings, Start, j);
  if i &lt; Stop then QuickSortByLength(ListOfStrings, i, Stop);
end;    </pre>
<p>I did write it so that when you pass only an array, it will sort the entire array.</p>
<p>Calling this function:</p>
<pre contenteditable="false">...
var
   MyStrings : array of string;
...

// sort entire list automatically
QuickSortByLength(MyStrings);
...

// sort entire list manually
QuickSortByLength(MyStrings, 0, length(MyStrings)-1);
...

// sort only a section
QuickSortByLength(MyStrings, 5, 10);
...</pre>
<p>&nbsp;</p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/">Delphi, Lazarus, Free Pascal</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-quicksort-an-array-of-string-by-the-length-of-the-strings/</guid>
                    </item>
							        </channel>
        </rss>
		