 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Shawn Lammers Guest
|
Posted: Sun Jun 05, 2005 8:28 pm Post subject: TListView Auto Column Resize |
|
|
In Builder 5 I am using a TListView component to create a report form. This
component allows for multiple coulmns that can be re-sized by draging the
column separetor.
There is a colum resize feature that I want to change. If you double click
on the column separator the column automatically resizes to the size of that
columns longest data item. However, I want it to resize to the longest data
item OR the column header text, which ever is longer.
Can someong explain how I would create a decendant from CustomListView to
add this ability?
In the VCL source for ComCtrls I found this bit of code
procedure TCustomListView.WMNotify(var Message: TWMNotify);
var
Col: TListColumn;
P: TPoint;
hChildWnd: HWND;
WndClass: string;
hdhti: THDHitTestInfo;
begin
inherited;
if ValidHeaderHandle and (Message.NMHdr^.hWndFrom = FHeaderHandle) then
with Message.NMHdr^ do
case code of
HDN_ENDTRACK:
with PHDNotify(Pointer(Message.NMHdr))^, PItem^ do
if (Mask and HDI_WIDTH) <> 0 then
begin
Col := GetColumnFromTag(Item);
if Col.MinWidth >= cxy then
cxy := Col.MinWidth
else if (Col.MaxWidth > 0) and (Col.MaxWidth <= cxy) then
cxy := Col.MaxWidth;
Col.Width := cxy;
end;
HDN_ENDDRAG:
FUpdatingColumnOrder := True;
HDN_DIVIDERDBLCLICK:
with PHDNotify(Pointer(Message.NMHdr))^ do
begin
Col := GetColumnFromTag(Item);
Col.Width := ListView_GetColumnWidth(Handle, Item);
if IsCustomDrawn(dtControl, cdPrePaint) then Invalidate;
end;
I figure the case for HDN_DIVIDERDBLCLICK is what is implementing this
function. But how do you create a new control that overrides this
functionality?
Thanks
Shawn
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|