We Won’t Overwrite Your Changes
Delphi 2009 Update 3 is out, and you all seem to have successfully downloaded it and are enjoying the new fixes and improvements. But some of you are reporting that there are some discrepancies between your PAS files and your DCU files.
This is happening almost certainly as a result of you making changes to the VCL source code. The installer is very careful not to overwrite your files – if you’ve changed a file in the \source\vcl directory, the update installer will see that and not make the change. Same with any DCU files that you may have produced as a result. Again, we won’t overwrite and thus delete your changes.
So, if that is happening to you, then you merely need to run a repair, and the installer should at that point see the differences and correct them. When you run a repair, you are telling the installer “Go ahead and make my install like it is supposed to be, and you have permission to overwrite my changes”. Doing that will get everything back in sync.
Following on to that, we strongly recommend that you never make any changes to the files in:
C:\Program Files\CodeGear\RAD Studio\<version>\source
and instead treat the files in that directory as a reference only. In addition, we strongly recommend that you never put that path (or any of its subdirectories) on any of your IDE paths that can result in that code being compiled. (You can put it on your browsing paths if you want….) If you want to debug into the VCL source code, you should set “Use Debug DCUs” in your project options. That will enable you to step into the VCL/RTL code with the debugger in one easy step without having to muck with the source itself.
Now, if you want to make change to the VCL source code and include that in your projects, we strongly recommend that you take a copy of the PAS file in question and either include it directly in your project or put it in a path where your project will see it.
Again, we strongly discourage you from compiling or altering the source code in place in the default install directory. Use it a reference, but leave it in place. If you need to mess around with it, make copies and mess around on your copy.



Yeah, a very needed post. Perhaps it should included in the Main Help with a short description of each directory.
May 29th, 2009 at 8:47 pm> The installer is very careful not to overwrite your files –
> if you’ve changed a file in the \source\vcl directory
Sound like an installer feature. But why is the installer also very careful about updating IDE packages like coreide120.bpl ? The only difference between the original file and the file on my disk was the FileTime.
May 31st, 2009 at 12:30 amThat’s good to know. But it would be really nice if the installer itself would tell you that. For example, at the end of the installation:
"The following files were not updated because they have been modified from their original versions:
(list of files here)
The updated versions have been placed in the (folder name here) folder instead."
May 31st, 2009 at 4:32 amWho is changing the sources in VCL? If you like to change something in the VCL you create in OOP thinking a new class with the "old" VCL class as a parent or create a class helper. That’s the way to do it! Do not change any sources in VCL sources.
Perhaps the idea form Mason (Message 3) is a good idea.
regards Daniel Magin
June 2nd, 2009 at 9:28 pmThat assumes that what you need to change is something that can be changed in a derived class. Sometimes it isn’t. For example, in our Delphi 6 project we make the following changes to the VCL source to fix various problems:
1. Workaround a Windows bug in the GetCursorPos API which doesn’t like receiving pointers >2GB (can happen if you have a LARGEADDRESSAWARE app.) The workaround is to call a different API (GetCursorInfo) to get the same info. Because lots of VCL code links to Windows.pas and calls the buggy API function this is the simplest way to replace it.
2. Change ComCtrls.pas to make multi-select tree views work more normally. The Delphi TTreeView component behaves strangely if you have multiple nodes selected and then click on one node. I would expect this action to change the selection to just the node that you clicked on. In fact it doesn’t change the selection at all (it does change the focus node). What’s especially bad about this behaviour is that if all nodes are selected then you can’t change the selection very easily at all!
3. Fix a bug in ComCtrls.pas for pre-Vista Windows which manifests as a missing refresh when a drag operation is cancelled. Again this can’t easily be done without changing the source.
4. Make various changes to Menus.pas to properly support native themed menus on Vista. Delphi menus which display icons in the menus are owner draw. And owner draw menus don’t look right in Vista unless you use native themeing API which is hard and in any case old versions of Delphi (possibly even new versions) don’t. Presumably the latest version of Delphi gets this right but by making the change ourselves we were able to have fully native Vista menus as soon as Vista was released.
Of course it’s always possible to make changes at runtime using fixups (madExcept is a good example). Another good example in a similar vein is Mike Lischke’s theme API code.
What’s true is that you don’t want to change the VCL source code files inside the Delphi installation directory. What we do is to include them in our project source tree and then link the VCL statically. This results in the DCUs produced from the modified source files being chosen in preference to the ones from the Delphi Lib directory. This is the best way that I have found so far to customise the VCL. You have to be careful not to modify anything in the interface section of the unit but otherwise it’s pretty straightforward.
June 2nd, 2009 at 11:32 pmIt occurs to me that perhaps the installer should mark the files in the source directory as read-only to help further encourage the proper behavior.
June 3rd, 2009 at 6:24 pm