Multi-line header for listview 
Author Message
 Multi-line header for listview

Using the listview common control with the style set to report.  Does
anyone know of a way to have the column headings be multilined?  Simply
inserting a vbLf in the middle of the text doesn't work.  I found a code
example that does this in C++ using MFC, but so far have not had much luck
converting the code to VB.

I know I need to get to the controls message loop, no problem there.  I
figure I probably need to intercept the WM_PAINT message and then set the
text on each column header manually.

Any pointers or examples would be greatly appreciated.

--
Tom Porterfield



Wed, 27 Aug 2003 22:49:45 GMT  
 Multi-line header for listview

Quote:

>Using the listview common control with the style set to report.  Does
>anyone know of a way to have the column headings be multilined?  Simply
>inserting a vbLf in the middle of the text doesn't work.  I found a code
>example that does this in C++ using MFC, but so far have not had much luck
>converting the code to VB.

>I know I need to get to the controls message loop, no problem there.  I
>figure I probably need to intercept the WM_PAINT message and then set the
>text on each column header manually.

>Any pointers or examples would be greatly appreciated.

You are correct that you need to subclass the WM_PAINT message.  You
can set the header font to a size large enough to allow you to draw
the desired number of lines of text.  As I recall, I had to explicitly
let the listview draw the text first and then override the return.

HTH,
Bryan
____________________________________________________________
New Vision Software            "When the going gets weird,"
Bryan Stafford                   "the weird turn pro."

Microsoft MVP-Visual Basic     Fear and Loathing in LasVegas



Wed, 27 Aug 2003 23:20:23 GMT  
 Multi-line header for listview


Quote:


>>Using the listview common control with the style set to report.  Does
>>anyone know of a way to have the column headings be multilined?  Simply
>>inserting a vbLf in the middle of the text doesn't work.  I found a
>>code example that does this in C++ using MFC, but so far have not had
>>much luck converting the code to VB.

>>I know I need to get to the controls message loop, no problem there.  I
>>figure I probably need to intercept the WM_PAINT message and then set
>>the text on each column header manually.

>>Any pointers or examples would be greatly appreciated.

>You are correct that you need to subclass the WM_PAINT message.  You
>can set the header font to a size large enough to allow you to draw
>the desired number of lines of text.  As I recall, I had to explicitly
>let the listview draw the text first and then override the return.

>HTH,
>Bryan

Thanks Bryan, it's a start.  I have no problem capturing the WM_PAINT
message for the header control.  Any hints as to what API calls I need to
investigate to override the return after letting the listview draw the text?

--
Tom Porterfield



Thu, 28 Aug 2003 05:20:43 GMT  
 Multi-line header for listview

Quote:





>>>Using the listview common control with the style set to report.  Does
>>>anyone know of a way to have the column headings be multilined?  Simply
>>>inserting a vbLf in the middle of the text doesn't work.  I found a
>>>code example that does this in C++ using MFC, but so far have not had
>>>much luck converting the code to VB.

>>>I know I need to get to the controls message loop, no problem there.  I
>>>figure I probably need to intercept the WM_PAINT message and then set
>>>the text on each column header manually.

>>>Any pointers or examples would be greatly appreciated.

>>You are correct that you need to subclass the WM_PAINT message.  You
>>can set the header font to a size large enough to allow you to draw
>>the desired number of lines of text.  As I recall, I had to explicitly
>>let the listview draw the text first and then override the return.

>>HTH,
>>Bryan

>Thanks Bryan, it's a start.  I have no problem capturing the WM_PAINT
>message for the header control.  Any hints as to what API calls I need to
>investigate to override the return after letting the listview draw the text?

In your window proc, you just call the NextWindowProc function
*before* you draw your text.  This let's the listview think everything
is peachy with it's drawing so that you can come in afterward and draw
what you want.  

You will probably want to use the DrawText function to draw your
header text.

HTH,
Bryan
____________________________________________________________
New Vision Software            "When the going gets weird,"
Bryan Stafford                   "the weird turn pro."

Microsoft MVP-Visual Basic     Fear and Loathing in LasVegas



Thu, 28 Aug 2003 11:57:44 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. ListView multi-lined column headers

2. Multi line column header in VB6

3. Simulating or Having more than 1 column header line with ListView

4. ListView - multiple lines in column header

5. Remove multi-selected lines from listview

6. multi-line listview?

7. remove multi-selected lines from listview box

8. ListView - Multi-Line subitems

9. Multi-line column in ListView

10. LISTVIEW - multi line Display

11. LISTVIEW Control - multi lines

12. Multi-Line Column in ListView

 

 
Powered by phpBB® Forum Software