Hi folks, it's been one of those days.  :(

Found a bug (well, I personally call it a bug) in the TListView
component (but if you're not running Delphi 4 none of this may
apply...).  Try the following:

Add a TListView component to a form, and create some items to place in
it.
In the FormCreate, include a line:
        ListView1.Items.Clear;
(If you run it at this point, everything's fine).
Now on your ListView, set ShowColumnHeaders to false.  Run it again.
You will find that it will display the default items in the list - as if
you never put your .Clear line in!

The problem as I understand it - feel free to enlighten me further - is:
During reading of the component, SetShowColumnHeaders calls RecreateWnd,
which trashes the Handle for the ListView, and you reach FormCreate with
the Handle still zero.  The Items property will be empty, so
ListView1.Items.Clear will do nothing.  This is the bug - HandleNeeded
should have been called internally beforehand.  Later, when the ListView
finally gets around to being shown, HandleNeeded will be called (well,
it has to be called sometime if you want to see the ListView) and the
Items property initialised from that.

And that yields the solution - in your FormCreate:
        ListView1.HandleNeeded;  // Create ListView1.Handle if required
- if so, the Items property will be initialised at this time
        ListView1.Items.Clear;

Such a short end to such a long story, a much longer story than I've
told here.

My dentist tells me that I grind my teeth.  He says I need to cut down
on the stresses in my life...  :(

Cheers,

Carl Reynolds                      Ph: +64-9-4154790
CJN Technologies Ltd.             Fax: +64-9-4154791
[EMAIL PROTECTED]                DDI: +64-9-4154795
PO Box 302-278, North Harbour, Auckland, New Zealand
12 Piermark Drive, North Harbour Estate, Auckland, NZ
Visit our website at http://www.cjntech.co.nz/

application/ms-tnef

Reply via email to