BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TListView Auto Column Resize

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development)
View previous topic :: View next topic  
Author Message
Shawn Lammers
Guest





PostPosted: Sun Jun 05, 2005 8:28 pm    Post subject: TListView Auto Column Resize Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.