Question posted the other day:
-------------------------------
Does anybody have an example on how to put multiple lines in the header of a
ListViewColumn?
Thanks,
Rob Panosh
> I posted the question listed below the other day and got one
reply.... get
> bBrowser ... thanks Geoff! That that is not an alternative for me
right
> now. I know this can be accomplished by subclassing the Header
control (
> which I can do ) and perform a custom draw of the Header control
> using window API Drawtext() (which I am struggling with). So could
> somebody please give me a code sample to get me started.
Does this help?
http://www.codeguru.com/listview/HeaderCtrlEx.shtml
There are also a few other header control examples on CodeGuru.
--
Paul
----
Paul Piko
Piko Computing Consultants
Phone: +61 3 9432 1222 Fax: +61 3 9432 1255
Email: pa...@piko.com.au Web: http://www.piko.com.au
I have already seen that example. The problem is that it is in Visual C++
and I am having troubles translating over to VO. Tried to find VB example
with no success.
Rob
"Paul Piko" <pa...@piko.com.au> wrote in message
news:Mg_s9.10558$DP6....@news-server.bigpond.net.au...
to make a quick working VO-sample is not as hard as it seems ( the harder
job will be to make a nice interface <g>.) The codeguru sample gives all
headeritems the ownerdraw style. Afterwards the owner of the header - the
listview - traps the WM_DRAWITEM msg. That´s the place where you draw the
multiline text.
// Here are some VO - tests ...
CLASS MyListView INHERIT ListView
PROTECT _oFontText AS Font
METHOD Dispatch ( oEvent ) CLASS MyListView
LOCAL struDrawItem AS _WINDRAWITEMSTRUCT
LOCAL struRect IS _winRECT
LOCAL hDC AS PTR
LOCAL pszItem AS PSZ
LOCAL hOldFont AS PTR
LOCAL aText := {"Line1" , "break" }
LOCAL i AS DWORD
IF oEvent:Message == WM_DRAWITEM
struDrawItem := PTR ( _CAST , oEvent:lParam )
hDC := struDrawItem.hDC
struRect := struDrawItem.rcItem
// select the "small" font ( only temporary ! )
hOldFont := SelectObject ( hDC , _oFontText:handle() )
FillRect ( hDC , @struRect , GetSysColorBrush ( COLOR_BTNFACE ) )
struRect.Left += 4
struRect.Right -= 4
struRect.Top += 2
FOR i := 1 UPTO ALen ( aText )
// two lines ....
pszItem := StringAlloc ( aText [ i ] )
// DT_CENTER , DT_LEFT or DT_RIGHT alignment
DrawText ( hDC, pszItem , PszLen ( pszItem ) ,;
@struRect , _or ( DT_CENTER , DT_SINGLELINE ) )
// next line ...
struRect.Top += 12
MemFree ( pszItem )
NEXT
struRect.Top -= 14
// select again the "large" Font
SelectObject ( hDC , hOldFont )
RETURN SELF:eventReturnValue := 1L
ENDIF
RETURN SUPER:Dispatch ( oEvent )
METHOD Init(oOwner, xID, oPoint, oDimension, kStyle) CLASS MyListView
LOCAL oFontHeader AS FONT
LOCAL hHeader AS PTR
// Text font
_oFontText := Font { , 8 , "Tahoma" }
oFontHeader := Font { ,17 , "Tahoma" }
SUPER:Init(oOwner, xID, oPoint, oDimension, kStyle )
hHeader := ListView_GetHeader ( SELF:Handle() )
// the "large" font ensures that 2 lines fit in a header
SendMessage ( hHeader , WM_SETFONT , DWORD ( _CAST , oFontHeader:handle() )
, MAKELONG ( 1, 0 ) )
// ---------------------------
// After all columns are attached call
// such a method to give the headeritems the
// ownerdraw style
// ---------------------------
METHOD MakeHeaderOD() CLASS DtaLV
LOCAL i AS DWORD
LOCAL hHeader AS PTR
LOCAL struHDItem IS _winHD_ITEM
hHeader := ListView_GetHeader ( oDCListView1:Handle() )
FOR i := 1 UPTO SendMessage ( hHeader , HDM_GETITEMCOUNT , 0 , 0L )
MemClear ( @struHDItem , _sizeof ( _winHD_ITEM ) )
struHDItem.mask := HDI_FORMAT
SendMessage ( hHeader , HDM_GETITEM , i-1 , LONG ( _CAST , @struHDItem ) )
struHDItem.fmt := _or ( struHDItem.fmt , HDF_OWNERDRAW )
SendMessage ( hHeader , HDM_SETITEM , i-1 , LONG ( _CAST , @struHDItem ) )
NEXT
--
regards
Karl-Heinz
Cheers,
Rob
"Karl-Heinz Rauscher" <khrausch...@compuserve.com> wrote in message
news:ap4271$rls1k$1...@ID-61886.news.dfncis.de...
Michael
"Rob Panosh" <rob_p...@asdsoftware.com> wrote in message
news:3db5c33f$1...@news.splitrock.net...
>> ... you taking the time to put this
>> sample together for me.
yep ! .... only for you <G>