The Unofficial Newsletter of
Delphi Users - by Robert Vivrette
Fixing a Menu Drawing Glitch in Delphi 4
by David Yowell - yowelld@hotmail.com
You may have noticed that the images for certain disabled menu items
in the Delphi 4 look like indistinguishable gray blobs as seen in the following
figure.
The glitch is in the VCL so it affects both the Delphi IDE and user
applications created with Delphi. However, there is an easy fix that involves
changing a few lines of code in the ImgList unit. In the TCustomImageList.DoDraw
method eliminate line 583:
ImageList_DrawEx(Handle, Index, FMonoBitmap.Canvas.Handle,
0,0,0,0, 0,0,
ILD_MASK);
and in its place put
FMonoBitmap.Canvas.Brush.Color := BkColor;
FMonoBitmap.Canvas.FillRect(Rect(0, 0, Self.Width,
Self.Height));
ImageList_DrawEx(Handle, Index, FMonoBitmap.Canvas.Handle,
0,0,0,0, 0,0,
ILD_TRANSPARENT);
With that change, your menus will now look like this!
Note: Modifying the code
for your Delphi 4 VCL has a few pitfalls. You may want to make sure you
understand what you are doing before changing code shipped from Borland/Inprise.
If you need a little hand-holding, here is the key points you need to look
out for:
Instructions for modifying the VCL:
-
Create a directory called [DelphiPath]\MyVCL where [DelphiPath] is the
directory in which Delphi is installed.
-
Add [DelphiPath]\MyVCL as the first entry in the Library Path in the Environment
Options dialog box.
-
Copy the source code of the unit you wish to modify to the [DelphiPath]\MyVCL
directory.
-
Modify the VCL unit and recompile your application.
A few considerations:
-
Sometimes it is necessary to exit and restart Delphi before it will detect
and compile your modified VCL code.
-
Never modify the interface section in a VCL unit.
-
In Delphi 3 & 4, your modifications will only appear at runtime since
the IDE continues to make use of the standard VCL design package libraries.
Also, this method will not work with runtime packages.