A bug in THeaderControl in BDS/Turbo?


2007-03-26 12:52:15 PM
cppbuilder14
I'm converting project from BCB5 to TurboC++ and have discovered that
THeaderControl.OnSectionClick doesn't work properly in TurboC++.
On startup I add some items to THeaderControl.Sections and
OnSectionClick works fine.
Then when I load different set of data I clear Sections and add new list
of items. But now, OnSectionClick is called either with THeaderSection
equal NULL or THeaderSection of different column.
After inspecting the TCustomHeaderControl.CNNotify in ComCtrls.pas it
seems that this procedure is not properly searching for appropriate
THeaderSection.
...
with PHDNotify(Message.NMHdr)^ do
case Hdr.code of
HDN_ITEMCLICK:
SectionClick(THeaderSection(Sections.FindItemID(Item)));
...
Section.FindItemID searches by ID, while Item is the index of the
clicked section. It works initially because IDs and indexes match but
when you cleat Section and then add new items IDs do not match Item index.
Is there a workaround to clear IDs when the new items are added into the
THeaderSections?