Reputation: 3628
I got a TMainMenu with Icons. All is fine until i place a TMemo on the form. When i run my program the icons were dissappeared. What happened and how can i fixx this problem?
I am using Delphi 2010 as IDE.
Upvotes: 4
Views: 387
Reputation: 612934
The issue is as Sertac described. The streaming of the memo's text is causing the icon to be lost from the menu bar.
So the simplest and most expedient solution is to make sure that the memo does not have text in its .dfm file. Set the text at runtime after the form has been created. For instance in the constructor, or in an OnCreate
event handler.
Upvotes: 3
Reputation: 2121
Debugging the VCL, I tracked the issue to be on the TMenuItem.AppendTo
procedure. The image isn't displayed when the variable IsOwnerDraw
is set to False
, and that happens when GetImageList
returns Nil
, in this case. Maybe this is a bug on the VCL, but setting OwnerDraw = True
in TMainMenu solves the problem.
EDIT: Considering that OwnerDraw = True
creates a problem with overlapping captions, I suggest you set Bitmap property of the parent TMenuItems to any bitmap as a workaround. This Bitmap will be ignored and the image in the TImageList will be read instead. You can then set OwnerDraw = False
and the image will still be displayed.
Upvotes: 1