mycopy / vcl-styles-utils

Automatically exported from code.google.com/p/vcl-styles-utils
0 stars 0 forks source link

Vcl.Styles.OwnerDrawFix not affecting TListView (C++) #77

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
1. Create a new VCL Forms app (C++)
2. Add TListView and populate it with some items
3. Add Vcl.Styles.OwnerDrawFix.pas and set the listview to OwnerDraw = true
4. Compile and run

The items in the listview are unselectable. Well, perhaps they are, but no 
visual clue is given.

RAD Studio XE5 on Windows 8.1.

Work-around:
First compile the project so that Vcl.Styles.OwnerDrawFix.hpp is produced. Add 
this file to the project (also write #include "Vcl.Styles.OwnerDrawFix.hpp").
Create OnDrawItem event to the listview:

void __fastcall TForm1::ListView1DrawItem(TCustomListView *Sender, TListItem 
*Item, TRect &Rect, TOwnerDrawState State)
{
    TVclStylesOwnerDrawFix *ownerdraw = new TVclStylesOwnerDrawFix();
    ownerdraw->ListViewDrawItem(Sender, Item, Rect, State);
}

Worth to note: everything works in Delphi, and it also works if you use the TMS 
component TAdvListView.

Please let me know it you need a sampleproject. Thanks!

Original issue reported on code.google.com by marius.b...@gmail.com on 23 Sep 2014 at 7:01

GoogleCodeExporter commented 9 years ago
Try checking the code of sample project of this unit
https://code.google.com/p/vcl-styles-utils/source/browse/trunk/Vcl%20Styles%20Ow
ner%20draw%20%28Demo%20App%29/Main.pas

as you can see the OnDrawItem and OnMouseDown events must be assigned explicitly

  ListView1.OwnerDraw:=True;
  ListView1.OnDrawItem:=VclStylesOwnerDrawFix.ListViewDrawItem;
  ListView1.OnMouseDown:=VclStylesOwnerDrawFix.ListViewMouseDown;

Also you can check this article for another alternatives

http://theroadtodelphi.wordpress.com/2014/08/06/vcl-styles-utils-new-feature/

Regards
Rodrigo.

Original comment by Rodrigo.Ruz.V@gmail.com on 26 Sep 2014 at 6:33