Hello:
When I send LVM_SORTITEMS message to a list view control, I can sort
the items of the list view control.
And, I can send HDM_SETITEM message to the head control to add/remove
a bitmap triangle indicator. It works OK.
But, I want to "Draw" a triangle indicator:
01: I send HDM_SETITEM message to the head control, change the HDITEM.fmt with HDF_OWNERDRAW
02: In my main window WM_DRAWITEM message, I can not receive the head control's WM_DRAWITEM message.
03: I read the MSDN, the head control only send WM_DRAWITEM to it's parent window.
In a list view control, the head control is the child window of the list view control.
should I subclass the list view control ?
So, how to "Draw" a triangle indicator?
^^^^^^^^^^^^^^^^^^^^^^
Is there anybody has any idea?
Thanks...
When I send LVM_SORTITEMS message to a list view control, I can sort
the items of the list view control.
And, I can send HDM_SETITEM message to the head control to add/remove
a bitmap triangle indicator. It works OK.
But, I want to "Draw" a triangle indicator:
01: I send HDM_SETITEM message to the head control, change the HDITEM.fmt with HDF_OWNERDRAW
02: In my main window WM_DRAWITEM message, I can not receive the head control's WM_DRAWITEM message.
03: I read the MSDN, the head control only send WM_DRAWITEM to it's parent window.
In a list view control, the head control is the child window of the list view control.
should I subclass the list view control ?
So, how to "Draw" a triangle indicator?
^^^^^^^^^^^^^^^^^^^^^^
Is there anybody has any idea?
Thanks...
Hi,
I assume your talking about the sort arrows in the header control of the listview. I am not sure if I have ever seen it 'drawn' before as there is no message callback for the header (TIKO), which you need to process WM_PAINT where the drawing would have to take place. You could try to subclass the header but that would be problematic and quite a bit of work when the bitmap method works fine and is more than flexible enough. I suppose you could create a bitmap, draw a triangle on it then assign it to the header button but it hardly seems worth the effort.
To subclass the header and process WM_PAINT you would follow these general steps...
When processing WM_PAINT you will have to completely draw the header, since it has buttons this may not be that easy as buttons are notoriously difficult to draw. Not really a project that I would attempt as there is a much more efficient and easy way to do it already.
Donkey
I assume your talking about the sort arrows in the header control of the listview. I am not sure if I have ever seen it 'drawn' before as there is no message callback for the header (TIKO), which you need to process WM_PAINT where the drawing would have to take place. You could try to subclass the header but that would be problematic and quite a bit of work when the bitmap method works fine and is more than flexible enough. I suppose you could create a bitmap, draw a triangle on it then assign it to the header button but it hardly seems worth the effort.
To subclass the header and process WM_PAINT you would follow these general steps...
- [*]Obtain the handle of the listview
[*]Enumerate the listviews child windows
[*]Obtain the handle to the header control
[*]Subclass the header control saving the address of it's WndProc
[*]Process WM_PAINT, sending all other messages to the original WndProc
When processing WM_PAINT you will have to completely draw the header, since it has buttons this may not be that easy as buttons are notoriously difficult to draw. Not really a project that I would attempt as there is a much more efficient and easy way to do it already.
Donkey
hello, donkey, thank you for your response.
Your methord may be OK.
"Draw" a triangle indicator, that is using GDI function to draw the indicator, such as MoveToEx,LineTo....
I had just complete the "Drawing" a triangle indicator, It works OK.
It works OK, and I think it works easy than subclassing the head control.
BTW: hWndHeadControl = GetWindow(hWndListview, GWL_CHILD) , becase the list view control only has one child control.
ha, donkey, you're warmhearted. thank you.
Your methord may be OK.
"Draw" a triangle indicator, that is using GDI function to draw the indicator, such as MoveToEx,LineTo....
I had just complete the "Drawing" a triangle indicator, It works OK.
- Subclass the list view control
- In the new list-view-control's proc, I just get WM_DRAWITEM message, and send the WM_DRAWITEM message to the parent window(the main window)
- In the main window proc, when WM_DRAWITEM message, and the DRAWITEMSTRUCT.hwndItem == head-control, I can use DRAWITEMSTRUCT to draw the item
It works OK, and I think it works easy than subclassing the head control.
BTW: hWndHeadControl = GetWindow(hWndListview, GWL_CHILD) , becase the list view control only has one child control.
ha, donkey, you're warmhearted. thank you.
Actually I removed the post by accident, I was meaning to press modify :) At any rate it doesn't work when you add buttons to the header so it's pretty useless. Good idea with your method though...
I would never trust that listviews would only have one child control, I constantly add controls like comboboxes to them.
I would never trust that listviews would only have one child control, I constantly add controls like comboboxes to them.
:D I had read the post you just posted and then removed.
ha :lol:
thanks...
ha :lol:
thanks...
......
I would never trust that listviews would only have one child control, I constantly add controls like comboboxes to them.
Yes, you're right. :thumbsup: