Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/VCL/Graphics    [ Add a report in this area ]  
Report #:  83992   Status: Closed
TImageList is always copied on form/frame inheritance even when no changes are made.
Project:  Delphi Build #:  3593
Version:    16.0 Submitted By:   Mason Wheeler
Report Type:  Minor failure / Design problem Date Reported:  4/19/2010 2:13:06 PM
Severity:    Serious / Highly visible problem Last Updated: 3/16/2014 5:49:27 PM
Platform:    All platforms Internal Tracking #:   276050
Resolution: Duplicate (Resolution Comments) Resolved in Build: : None
Duplicate of:  92769
Voting and Rating
Overall Rating: (2 Total Ratings)
4.50 out of 5
Total Votes: 11
Description
When a TImageList is used in a form or frame, and the form or frame is later used on another form, (either through placing the frame on a form or through form inheritance,) the entire TImageList's image data gets copied to the new DFM, even if no changes have been made.

This was not the case in D2007.  Haven't checked in D2009.
Steps to Reproduce:
Create a frame.
Place a TImageList on the frame.
Put an image in the TImageList.
Save the TImageList.
Create a form.
Place the frame on the form, unchanged.
Save the form.
Examine the DFM for the form, and see that the image data is there for no good reason.


Alternative steps and information by USc:
- save the attachment
- start Delphi
- open QC83992.dpr
- open QC83992ImageListFrame.pas and add it to the palette (Form Designer popup menu "Add To Palette")
- open QC83992Main.pas in the Form Designer
- add QC83992ImageListFrame.pas from the palette to QC83992Main
- ALT + F12

expected: the is no Bitmap property for ImageList1 or no ImageList1 at all

  object fmQC83992: TfmQC83992
    ...
    inline TfrmQC83992ImageList1: TfrmQC83992ImageList
      ...
    end
  end

actual: the is a ImageList1 with a Bitmap property

  object fmQC83992: TfmQC83992
    ...
    inline TfrmQC83992ImageList1: TfrmQC83992ImageList
      ...
      inherited ImageList1: TImageList
        Bitmap = {
          ...
          }
      end
    end
  end
    
Additional notes:
It seems that the reason is something in the streaming of the imagelist content, because the only difference between the bitmap in the frame and in the form is the 9th byte.
The value of 9th byte in the form is the value of the frame + 4
Form:
      Bitmap = {
        494C01010100080040

Frame:
    Bitmap = {
      494C0101010008003C

When you repeatedly switch between the Form Designer and the form text you see that the value of the 9th byte gets always higher and higher and is last value + 4.
The issue does NOT occur because of looking with ALT + F12 into the form text! (It is enough to put the frame onto the form, save the form and look on the disk and see that the file is to big...)

This issue is probably related to the ComCtrls version and the ImageList_Write/ImageList_WriteEx function, because the issue repeats also with D2007 on W2k (IE 6) and Win 7 although the reporter claims that it wouldn't occur with D2007.
Workarounds
Manually culling the DFM files will work, until the next time you edit the form at least...
Attachment
QC83992.zip
Comments

Mason Wheeler at 4/19/2010 2:15:51 PM -
It's worth noting that if you go back later and edit the original list, the changes don't get propagated to the form that uses it because the image data that's already there will override it.  This can lead to unpredictable behavior.

Steven Kamradt at 4/19/2010 2:21:23 PM -
I also noticed that if there are no changes to an image list, just loading the form and saving it will change the order of a byte or two which will show up when a diff against a previous version is performed.  I believe this may be related to why it brings in the entire imagelist.

Tomohiro Takahashi at 3/16/2014 6:09:38 PM -
Please take a look at my comment of QC#92769.

Server Response from: ETNACODE01