listView paint event


I have never tried painting in a listView and it doesn’t appear to be straight forward. ownerDraw is supposed to be set to true but that stops the header and items from showing up that I’m adding.

Any one used the paint even in a listView? Have any tips?


when you set ownerDraw to true it means you want to draw everything yourself. What do you really need to draw?


Not that much so I’m going another root. Thanks Denis.


actually it’s not too bad to draw yourself. you can delegate the default drawing to the framework, and do custom drawing for only specific things. so… i’m asking again… what do you specifically want to draw?


Hey Denis, Id love to know if you can restyle the header bar of a listbox with ownerdraw, I haven’t found out how to do it up until now and I hate the way the grey windows header looks, especially with a dark UI. If you know how to restyle it to change the backcolor and remove the bevel edge that would be awesome. From what i can make out, it seems more complicated that the usual owner draw methods -? :shrug:


The header for one as Pete would like as well and I would paint into the rows below the text, so I know that I would have paint The text in as well? I want the look of it to match the right hand portion of this tool.

At the moment I have made my own list using flowLayoutPanel and labels as I only need one column. This change is not seen in the image below.


you can hide default Headers. Set HeaderStyle to None and draw a Label of any look above ListView.

But it’s has to be possible to do user draw for only Headers. As I have time i will make a snippet. Hopefully it will happen this weekend.


it was easier than i thought:

  try(form.close()) catch()
  form = dotnetobject "MaxCustomControls.MaxForm"
  form.size = dotnetobject "System.Drawing.Size" 200 200
  lv = dotnetobject "ListView"
  lv.view = lv.view.Details
  lv.columns.add "Name"
  lv.columns.add "Sub"
  	item = lv.items.add "Item"
  	item.subitems.add "Sub Item"
  lv.Dock = lv.Dock.Fill
  lv.FullRowSelect = on
  lv.OwnerDraw = on
  fn onDrawColumnHeader s e =
  --	print (e.State.ToString())
  	if (dotnet.CompareEnums e.State e.State.Selected) then
  		e.Graphics.FillRectangle (dotnetclass "System.Drawing.Brushes").Maroon e.Bounds
  		brush = dotnetobject "System.Drawing.Drawing2D.LinearGradientBrush" e.Bounds \
  			(dotnetclass "System.Drawing.Color").Orange \
  			(dotnetclass "System.Drawing.Color").Maroon \
  			(dotnetclass "System.Drawing.Drawing2D.LinearGradientMode").Vertical
  		e.Graphics.FillRectangle brush  e.Bounds
  	flags = dotnet.combineEnums (dotnetclass "TextFormatFlags").HorizontalCenter (dotnetclass "TextFormatFlags").VerticalCenter
  	(dotnetclass "TextRenderer").DrawText e.Graphics e.Header.Text s.Font e.Bounds (dotnetclass "System.Drawing.Color").White flags
  fn onDrawItem s e =
  	e.DrawDefault = on
  fn onDrawSubItem s e =
  	e.DrawDefault = on
  dotnet.addEventHandler lv "DrawColumnHeader" onDrawColumnHeader
  dotnet.addEventHandler lv "DrawItem" onDrawItem
  dotnet.addEventHandler lv "DrawSubItem" onDrawSubItem
  form.controls.add lv	

PS. it’s not optimized! no time for that.


Thanks Denis, i tried some of that but wasn’t able to get any of it to work so it will be good to go over the code you have.


man - for some reason when i looked on the web everyone seemed to be using win32 calls so I assumed it was more involved. Thanks a million Denis, great work as usual.


After a quick look I definitely didn’t try any of this. Had the events right and that was about it. Thanks again Denis. I will have to do some reading now to sort out what you have done.


That is what I found as well Pete, I couldn’t make heads or tails of it all in Max Script so gave up. I might stick with what I have how ever as it is even easier then what Denis has there I think. Just not sure which is faster.

Pete what do you think of the new joystick system?


hm… i can’t make header hotTracking … the draw event doesn’t catch Hot state. well. see it later.


new system looks awesome Paul. I like the look of the pose bank on the side for facial animation. How are you hooking them up? callbacks?


Well callBacks are used to update the control when scrubbing and is disabled when play is pressed but updates as soon as it has stopped playing. The controls when interacted with directly drive ca def parameters that they are associated with.

Did you see this?

The whole thing is setup using XML files that you can build as presets. Once setup the XML file is not needed as it is stored in the def that is created so that every thing except the UI is local to the file. When the UI is launched and the control panel picked from the scene list it reads in the XML and builds the UI making all the associations via the tab property of each control.

Very fast and simple to setup a UI, all you need to do is wire the morphs, bones, what ever to the parameters and away you go. The location of the controls in the UI is all automatic but you have the ability to force a new row and use offset values to get it just the way you want. Also the groups and their colours are what ever you want as well.

This is the latest test xml file format.


love it Paul, I knew you were writing this for a while but it looks like it’s turned out very well. Congratulations!


This is the stripped down version of the one that I stared a long time ago.


This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.