Notifications
Clear all

[Closed] icons in activeX listview Controller

hi all,

I’ve got an activeX listview control that I want to add some icons to. There is a mention in the docs about using ImageList ActiveX control but for the life of me i just cant get it to work.
for my listcontol i’ve pretty much used the “How to…” from the help file.

Has anyone managed to do this or can i only have icons in a treeview object?

Thanks for any help.

11 Replies
 JHN

If your on anything newer then max8 I would suggest using a dotnet form instead of ActiveX. ActiveX doesn’t work on 64bit and is not being developed anymore, at least not for max. Dotnet is the way to go, and is somewhat similar, more examples can be found as well.

-Johan

Thanks for the info. I feel like crying to be honest. I’ve been writing quite a big plugin for the last 6 months and was hoping to finish it before the end of the year.
I havent got a 64bit operating system so never been able to test it.

I hate my life!

Hi

I dont know if is enough quick for you , for sure need some adjustments


try destroyDialog dotnetIconTestDialog catch()
rollout dotnetIconTestDialog "Icons List" width:160 height:324
(
	local winColor  = ((colorMan.getColor #window)*255)as color
	local textColor = ((colorMan.getColor #text)*255)as color
	local transparent_color = color 185 185 185
	local icon_file, icn_count
	GroupBox grp1 "DotNet TreeView Icons:" pos:[4,4] width:152 height:316
	button btn1 "Load Max UI Icons..." pos:[12,288] width:136 height:24
	dotNetControl tv "treeView" pos:[12,24] width:136 height:260
	fn netDrColor clr  = ((dotNetClass "System.drawing.color").fromArgb clr.r clr.g clr.b)
	fn getIconDotNet img h icn_num =
	(
		local x = (h * icn_num)

		local icon = (dotNetObject "Drawing.Bitmap" h h) --Create new bitmap object
		local gra  = (dotNetClass "Drawing.Graphics").fromImage icon --Create new Graphics object
		local newRect = dotnetObject "Drawing.rectangle" 0 0  h  h
		gra.DrawImage img newRect x 0 h h (dotNetClass "Drawing.GraphicsUnit").Pixel	
		icon
	)
	fn getIconList =
	(
		
		local img = (dotNetClass "Drawing.Image").FromFile icon_file --get the saved image from file as bitmap
		local w = img.width
		local h = img.height
		icn_count = (w / h) as integer
		
		local img_list = dotNetObject "ImageList"
		img_list.ImageSize = dotNetObject "Drawing.Size" h h
		img_list.ColorDepth = img_list.ColorDepth.Depth24Bit
		img_list.transparentColor = netDrColor transparent_color
		
		for i = 1 to icn_count do img_list.images.add (getIconDotNet img h i)
		img.dispose()
		
		return img_list
	)
	fn loadIconset =
	(
		local icons_path = (GetDir #ui)+"Icons\\"
		getOpenFileName caption:"Select Icon Set"  \ 
		filename:icons_path \
		types:"BMP image file (*.bmp)"
	)
	fn fillTreeView = 
	(
		for i = 1 to icn_count do 
		(
			local d = (dotNetObject "TreeNode" ("icon" + i as string)) 
			d.ImageIndex = i
			tv.nodes.add d
		)
		tv.SelectedNode = tv.Nodes.Item[ 0 ] -- select the first Item
		return true
	)
	on dotnetIconTestDialog open  do
	(
		tv.BackColor= netDrColor winColor
		tv.ForeColor= netDrColor textColor
		tv.HideSelection=false -- When this ListView loses the focus, it will still show what's selected
		tv.HotTracking = true 
		
		start_lib = (GetDir #ui)+"Icons\\Maintoolbar_24i.bmp"
		if doesfileexist start_lib do
		(
			icon_file = start_lib
			print icon_file
			tv.nodes.Clear()
			tv.ImageList = getIconList()
			fillTreeView()
		)
	)
	on dotnetIconTestDialog close  do
	(
		
	)
	on btn1 pressed  do
	(
		icon_file = loadIconset()
		if icon_file != udefined do 
		(
			print icon_file
			tv.nodes.Clear()
			tv.ImageList = getIconList()
			fillTreeView()
		)
	)
)
createDialog  dotnetIconTestDialog

 PEN

You do not need a 64 bit system to use dotNet. Any max version above 8 will allow the used of dotNet instead of activeX. If this is a tool that you intend on using into the future I suggest that you switch it to dotNet as axtiveX is no longer used.

Ok, I’ve bitten the bullit and started converting my script.
THanks for all the helpful advice. It’ll probably be better in the long run.

I’ve got the listview back up and running in dotnet. Can someone help me in accessing the values directly? I used to use this to access a single value in a column:

testvalue = ct_display_window.lv.listitems[1].ListSubItems[2].text

How do i access this in dotnet?

Thanks again.

testvalue = ct_display_window.lv.listitems[1].ListSubItems[2].text

should be something like

testvalue = ct_display_window.lv.items.item[1].subItems.item[2].text

thanks very much!!

It’s all converted and working now. a lot less painfull than I envisaged.

DotNetObject “ListView”
here is how to get some properties of selected item
you can also select the same node in second wiew

   on lv1 MouseUp s a do
   (
       if s.SelectedItems.count !=0 do
       (
           itm = s.SelectedItems.item[0]
           num = s.SelectedIndices.item[0]
           lv2.items.item[ num ].selected = true
         -- or
           ht = (s.HitTest a.location)
           format "item:%

” ht.Item.text
)
)

ah, cool!

You wouldnt know anything about drawing the listview would you?
I’ve got about 10 columns of different sizes and when i first draw the lv window, the column header tabs are just one long rectangular grey box.
If i click on a tab, it becomes visible. If i click inbetween tabs, all of them become visible.

Do I need to refresh it when it’s drawn or something.

Page 1 / 2