9

We have a modified menus.pas.

At

uses ...,Controls,...;

The compiler raised a fatal error:

[DCC Fatal Error] Menus.pas(*): F2051 Unit Controls was compiled with a different version of Menus.TPopupMenu

tried:

deleted all dcu in the project.

build

build all

tried adding the file to library path which leads to add db folder(from vcl too) and then to

[DCC Error] jpeg.pas(872): E2065 Unsatisfied forward or external declaration: 'jpeg_save_markers'

which is a dead end.

deleted the controls.dcu (all 3) and the delphi did not know automaticaly to recompile them, instead reported that controls.dcu is missing.

LU RD
  • 34,438
  • 5
  • 88
  • 296
none
  • 4,669
  • 14
  • 62
  • 102
  • IIRC, if you modify a file from delphi's source, you need to recompile all in a specific order, I've never done it... –  May 06 '12 at 14:34
  • So, you have modified the `Menus.pas` in the Delphi's source folder ? You need to notice, that the debug and runtime `*.dcu` files are stored in the ..\lib directory and optionally subdirectories (I have only Delphi 2009 by hand at this time, so it might be slightly different) – TLama May 06 '12 at 14:37
  • Can you also bring in 'controls.pas'? – Sertac Akyuz May 06 '12 at 14:39
  • @TLama in delphi 2009 and xe2 it worked flawlessly. – none May 06 '12 at 14:52
  • @SertacAkyuz i brought in controls.pas and that lead to add the db search path , which yield the E2065. not the way to handle this. – none May 06 '12 at 14:53
  • 2
    Better do not change any file in any of the default delphi folders. Put all your modified source files in a folder of your own and include this folder in the search path of project options (or in library path in options if you're sure you'll always use the modified files). – Sertac Akyuz May 06 '12 at 15:19
  • 4
    You need to make sure you don't modify the interface section. You may also need to explicitly set the compiler options at the head of the modified Menus.pas file. Set them to the default Delphi options. Find out what they are by creating a new project and press Ctrl+O O – David Heffernan May 06 '12 at 15:26
  • But what you are attempting is perfectly viable. I do exactly this to fix the many bugs in Menus.pas. – David Heffernan May 06 '12 at 15:36
  • 2
    Similar questions, [How to recompile a specific unit from the VCL?](http://stackoverflow.com/q/1055010/576719) and [Can I recompile the .PAS files used by the Delphi IDE?](http://stackoverflow.com/q/1533686/576719) and [How to patch a method in Classes.pas](http://stackoverflow.com/q/1482311/576719). David's answer here is more to the point, hand's on information, though. – LU RD May 06 '12 at 22:58

2 Answers2

15

Here is how I handle modifications to VCL source files:

  • Make a copy of the file in your project structure. Either add the file to your project, or make sure the search path finds your modified file.
  • Make modifications, but only in the implementation section. You are not able to modify the interface section if you use any other units that themselves use the unit you are modifying.
  • Explicitly set the compiler options at the top of the modified source file. Use default Delphi options, as found by pressing CTRL+O O in a default vanilla project.

I'd guess that one of the final two bullet points is what is tripping you up.

Gabriel
  • 20,797
  • 27
  • 159
  • 293
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • a new procedure was added in xe : CloseMenu. – none May 07 '12 at 08:48
  • @David, should I add the `{$MINSTACKSIZE $00004000}`, `{$MAXSTACKSIZE $00100000}`, `{$IMAGEBASE $00400000}` defaults also? or only the default `$A+,B-,C+,D+,E-,F-,G+,H+,I+,J+,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}` (Delphi 5) - which is generated with `CTRL+O O`. – kobik Jun 28 '17 at 09:15
  • 1
    @kobik My units just have `{$R-,T-,H+,X+}`. I suspect that my projects compile options align with all the others. It won't hurt to add a full site, e.g. `{$A+,B-,C+,D+,E-,F-,G+,H+,I+,J+,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-‌​,U-,V+,W-,X+,Y+,Z1}`. But you don't need more than that I think. – David Heffernan Jun 28 '17 at 09:20
  • Well, this is what I got when pressing `CTRL+O O` in a blank project. I was not aware about the default compiler directive at all in a modified VCL. thanks! – kobik Jun 28 '17 at 09:24
  • I guess the corresponding DCUs should be deleted from Delphi\lib\win32\debug (etc). Right? – Gabriel Jan 25 '22 at 20:06
  • @server no, don't delete these. There's no need. You'll want them if ever you want to build other projects that don't require changes to vcl. – David Heffernan Jan 26 '22 at 17:05
  • Since the Forms.pas is bugged, and there is a solution, my guess is that I want to use the patch version forever. – Gabriel Jan 26 '22 at 20:22
  • @server you don't need to overwrite the installation to do that though – David Heffernan Jan 26 '22 at 20:29
1

In Delphi XE7 (and below) themes and styles are totally unusable.

So, I patched the file ( Delphi XE7\source\vcl\Vcl.Themes.pas ) add it to the project file, compiled it and got a DCU. I replaced the old DCU ( Delphi XE7\lib\win32\release\Vcl.Themes.dcu - same for "debug" folder) with the new one. Everything works smooth now. I don't even have to link the PAS file to my projects.

Gabriel
  • 20,797
  • 27
  • 159
  • 293