Compile resource files for a WINAPI window by means of Lazres lazarus / 67-Windows ---------------------------------------------------------------------- Pieter · 2022-08-02 14:57 For Windows 11, on a 64-bit laptop, I used Lazres to recompile the resource files for the WINAPI application in GetClientRect in: https://forum.lazarus.freepascal.org/index.php/topic,52902.msg390865.h tml#msg390865, see also the attachment I called Lazres in the following way (compilation of the resources in Lazarus did not work, input file could not be found) Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i lazres GetClientRect.RES GetClientRect.rc APPICON.ICO with GetClientRectangle.rc: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i #include "resource.pas" APPICON                 ICON                        "APPICON.ICO" APPMENU                 MENU  BEGIN    POPUP "&File"    BEGIN         MENUITEM "E&xit"                        ,   IDM_EXIT    END     POPUP "&Help    "      BEGIN         MENUITEM "&About  GetClientRect ..."    ,   IDM_ABOUT      END  END ABOUTBOX DIALOG 42, 20, 170, 90STYLE DS_MODALFRAME | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENUCAPTION "About GetClientRect"FONT 8, "MS Sans Serif"BEGIN  ICON              "APPICON", -1, 10, 10, 32, 32  LTEXT             "Win32 API Example - Functions", -1, 35, 10, 170, 10  LTEXT           "GetClientRect", -1, 35, 20, 170, 10  CTEXT             "Copyright \251 1997  440bx",-1, 1, 40, 170, 10  CTEXT             "All rights reserved.", -1, 1, 48, 170, 10  DEFPUSHBUTTON     "OK", IDOK, 60, 67, 50, 14END and the implied Resource.pas file Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit resource;  { resource IDs for the GetClientRect example                              } {--------------------------------------------------- --------------------------}INTERFACE{--------------------------------- --------------------------------------------} const IDM_EXIT        = 900;  IDM_ABOUT       = 990; {---------------------------------------- -------------------------------------}IMPLEMENTATION{----------------- ------------------------------------------------------------} end. To my surprise, the icon is incorporated in the program but the menus are not. What is is happening here? I'd be happy to know so I can use the procedure for other applications requiring resource compilation ---------------------------------------------------------------------- 440bx · 2022-08-02 16:18 I've seen that problem before.  It's related to the fact that Lazarus manages resource and resource files a bit differently. Have a look at this thread: https://forum.lazarus.freepascal.org/index .php/topic,40830.msg282333.html#msg282333 the solution/explanation is quite likely there. ---------------------------------------------------------------------- Thaddy · 2022-08-02 19:48 You should not even need to call LazRes. The compiler will do that for you..... Only if you change the rc file you will need a rebuild for the whole program. ---------------------------------------------------------------------- Pieter · 2022-08-03 11:04 Quote from: Thaddy on August 02, 2022, 09:48:44 pmYou should not even need to call LazRes. The compiler will do that for you..... Only if you change the rc file you will need a rebuild for the whole program. This was what I expected but I get the following error message, in addition to two warnings Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Error while compiling resources -> Compile with -vd for more details. Check for duplicatesWarning: windres [option(s)] [input-file] [output- file]windres: supported targets: pe-i386 pei-i386 elf32-i386 elf32-iamcu elf32-little elf32-big pe-x86-64 pei-x86-64 pe- bigobj-x86-64 elf64-x86-64 elf64-l1om elf64-k1om elf64-little elf64-big plugin srec symbolsrec verilog tekhex binary ihex  That's why I used the Lazres separate compilation but with the problem mentioned above. ---------------------------------------------------------------------- Pieter · 2022-08-03 11:10 Quote from: 440bx on August 02, 2022, 06:18:48 pmI've seen that problem before.  It's related to the fact that Lazarus manages resource and resource files a bit differently. Have a look at this thread: https://forum.lazarus.freepascal.org/index .php/topic,40830.msg282333.html#msg282333 the solution/explanation is quite likely there. I did have a look a the thread but renaming the resource file with a name different from the program does not have an effect. That is, if I do: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i lazres JustAResource.RES GetClientRect.rc APPICON.ICOand include the RES file in the source program, the implied resources (i.e. the menu's) do not show up. I wonder if I did apply Lazres correctly. What could be the matter? ---------------------------------------------------------------------- 440bx · 2022-08-03 17:56 Quote from: Pieter on August 03, 2022, 01:10:41 pmCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i lazres JustAResource.RES GetClientRect.rc APPICON.ICOand include the RES file in the source program, the implied resources (i.e. the menu's) do not show up. I wonder if I did apply Lazres correctly. What could be the matter? The problem is that the "lazres" command you showed above does NOT include the menu nor the dialog in the resource file as menu and dialog resources. It includes the entire "GetClientRect.rc" as raw resource data.  IOW, it is not parsing and compiling that resource script.  If you want to see what it does, use ResourceHacker (nice little utility, I highly recommend it.) I don't know exactly what Lazres is supposed to do but, it doesn't seem to be a resource compiler. Just FYI, I use the resource compiler that was included with Delphi (BRCC32.exe) ---------------------------------------------------------------------- Pieter · 2022-08-04 15:59 @440bx: QuoteI don't know exactly what Lazres is supposed to do but, it doesn't seem to be a resource compiler. I agree, given the error and warning messages I mentioned above it seems that windres is used by Lazarus. However, it does not work, as far as I know. Maybe somebody else can shed some light on this issue? @440bx: QuoteJust FYI, I use the resource compiler that was included with Delphi (BRCC32.exe) Thanks for this information. This does work. ---------------------------------------------------------------------- 440bx · 2022-08-04 16:11 Quote from: Pieter on August 04, 2022, 05:59:59 pmThanks for this information. This does work.  You're welcome. ---------------------------------------------------------------------- marcov · 2022-08-04 20:46 Quote from: 440bx on August 03, 2022, 07:56:32 pmJust FYI, I use the resource compiler that was included with Delphi (BRCC32.exe) Note that trunk has a native resource compiler (fpcres) ---------------------------------------------------------------------- 440bx · 2022-08-04 20:53 Quote from: marcov on August 04, 2022, 10:46:35 pmNote that trunk has a native resource compiler (fpcres) Yes, I remember PascalDragon mentioning that. I will eventually start using it.  I also remember he mentioned that, at least at that time, there were some resource types it couldn't handle, I believe (not sure) keyboard accelerators were among them. ---------------------------------------------------------------------- Pieter · 2022-08-06 10:48 Quote from: marcov on August 04, 2022, 10:46:35 pmQuote from: 440bx on August 03, 2022, 07:56:32 pmJust FYI, I use the resource compiler that was included with Delphi (BRCC32.exe) Note that trunk has a native resource compiler (fpcres) As a newbie, I don't understand what is meant by 'trunk' here. ---------------------------------------------------------------------- MarkMLl · 2022-08-06 11:18 Quote from: Pieter on August 06, 2022, 12:48:59 pmAs a newbie, I don't understand what is meant by 'trunk' here. https://www.freepascal.org/develop.var MarkMLl ---------------------------------------------------------------------- marcov · 2022-08-06 11:23 Quote from: Pieter on August 06, 2022, 12:48:59 pmAs a newbie, I don't understand what is meant by 'trunk' here. Nowadays "Main" in git-speak, though many still use SVN era "trunk", is the branch with the newest development. The other significant branch is the branch from which releases are made, which is called FIXES_x_y with x.y the first two digits of the version number of the releases (3.2 now) ---------------------------------------------------------------------- Pieter · 2022-08-06 16:10 Thanks for the update!