dotnet List View Horizontal Padding

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 05 May 2013   #1
Thumbs up dotnet List View Horizontal Padding

is there any setting in listView [properties or something] that making horizontal padding become not so far for each control.

currentlly



become something like this



currently im using this setup


	fn initLv theLv =
  		(
  			theLv.View = (dotNetClass "System.Windows.Forms.View").LargeIcon
  			theLv.Multiselect = true
  			theLv.Scrollable = true
			theLv.margin =dotnetobject "System.Windows.Forms.Padding" 1 --doesnt work
			theLv.Padding  =dotnetobject "System.Windows.Forms.Padding" 1 --this doesnt work
  		)


thanks for the guidance
 
Old 05 May 2013   #2
try this

http://qdevblog.blogspot.co.uk/2011...em-spacing.html
 
Old 05 May 2013   #3
Thanks mr.Lo , but im not that advanced user ,still in progress of learning in dotnet ms, could you ascend how to use it in my ms.... I know little bit of compiling thing in ms but still dont know how to use it tho.


fn compileThis =
(
	title  =""
	title+="using System.Runtime.InteropServices;\n"
	title+="[DllImport(\"user32.dll\")]\n"
	title+="public static extern int SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);\n"
	title+="public int MakeLong(short lowPart, short highPart)\n"
	title+="{\n"
	title+="\treturn (int)(((ushort)lowPart) | (uint)(highPart << 16));\n"
	title+=" }\n"
	title+="public void ListViewItem_SetSpacing(ListView listview, short leftPadding, short topPadding)\n"
	title+="{\n"
	title+= "\tconst int LVM_FIRST = 0x1000;\n"
	title+="\tconst int LVM_SETICONSPACING = LVM_FIRST + 53;\n"
	title+="\tSendMessage(listview.Handle, LVM_SETICONSPACING, IntPtr.Zero, (IntPtr)MakeLong(leftPadding, topPadding));\n"
	title+="}\n"
	
	compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters" 
	compilerParams.ReferencedAssemblies.AddRange #("user32.dll","System.Windows.Forms.dll"); 
	compilerParams.GenerateInMemory = true
	compilerResults = (dotnetobject "Microsoft.CSharp.CSharpCodeProvider").CompileAssemblyFromSource compilerParams #(title)
	
)
compileThis()
 
 (
  	Global myScenes # ()
  	Global imageList = dotNetObject "System.Windows.Forms.ImageList"	
  	try destroyDialog myImageTest catch()
  	Rollout myImageTest "Scenes" width:500 height:500
  	(
  		dotNetControl sceneLv "System.Windows.Forms.ListView" width:480 height:480 
  		
  		fn initLv theLv =
  		(
  			theLv.View = (dotNetClass "System.Windows.Forms.View").largeIcon
  			theLv.Multiselect = true
  			theLv.Scrollable = true
			theLv.margin =dotnetobject "System.Windows.Forms.Padding" 1
			theLv.Padding  =dotnetobject "System.Windows.Forms.Padding" 1
  		)
  				
  		fn fillLv theLv =
  		(
			colorclass = (dotnetclass "system.drawing.color")
			
  			theLv.Clear()
  			theLv.items.Clear()	
  			theLv.Refresh()
  			imageList.images.Clear()
  			imageList.Dispose()
  
  			imageList.imagesize =  dotnetobject "System.Drawing.Size" 150 150
  			imageList.ColorDepth = imageList.ColorDepth.Depth32Bit
  			
			theLv.backcolor = theLv.backcolor.fromARGB 50 50 50
			theLv.forecolor = colorClass.white
			
  			local thumbs = #()
  			local items = #()
  			
  			for s = 1 to myScenes.count do
  			(

				
  				filePrefix = (getFilenamePath myScenes[s]) + (getFilenameFile myScenes[s])
				thumbFile =  filePrefix + ".jpg"
  				maxFile = filePrefix + ".max"
  				
  				append thumbs ((dotNetClass "System.Drawing.Image").fromFile thumbFile)
				
				item = dotNetObject "System.Windows.Forms.ListViewItem" (filenameFromPath maxFile)
  				item.name = maxFile
  				
  				item.imageIndex = s - 1
				
				--myborder=dotNetObject "System.Windows.Forms.BorderStyle.Fixed3D"
				
				
  				theLv.items.add item
  			)
  
  			imageList.images.addrange thumbs
  			
  			theLv.LargeImageList = imageList
  			theLv.SmallImageList = imageList
  			
  			for t in thumbs do t.dispose()
  		)
  		
  		on sceneLv mouseUp arg do
  		(	
  			hit=(sceneLv.HitTest (dotNetObject "System.Drawing.Point" arg.x arg.y))
  			if(hit != undefined AND hit.item != undefined) then
  			(	
  				-- hit.item.name has full path of max scene
  				print hit.item.name
  			)
  		)
  		
  		fn collectScenes =
  		(
  			myScenes = getFiles "D:\\*.max"
  		)
  		
  		on myImageTest open do
  		(
  			initLv sceneLv
  			collectScenes()
  			fillLv sceneLv
  		)
  		
  		on myImageTest close do
  		(
  			imageList.dispose()	
  		)
  		
  	)
  	createDialog myImageTest	
  )


where i must put the "ListViewItem_SetSpacing(this.listView1, 64 + 32, 100 + 16);" line ?

thanks for your answer.
 
Old 05 May 2013   #4
Originally Posted by fajar: Thanks mr.Lo , but im not that advanced user ,still in progress of learning in dotnet ms, could you ascend how to use it in my ms.... I know little bit of compiling thing in ms but still dont know how to use it tho.

you don't need any on-fly compiled assembly. you can do it with pure mxs. the only thing that you need is to send the right message to the right control. it's one line of code... if you can wait i will show it tomorrow.
 
Old 05 May 2013   #5
Ok thanks ....will wait till tomorrow then, right now just try a thing up.
Thanks denisT
 
Old 05 May 2013   #6
fn setListViewSpacing lv leftPadding topPadding =
(
	local hWnd = lv.handle
	local LVM_SETICONSPACING = 0x1000 + 53
	local lParam = bit.or (bit.shift topPadding 16) leftPadding
	windows.SendMessage hWnd LVM_SETICONSPACING 0 lParam			
)


Keep in mind that:
  • The listview must already be created (it must have a valid handle)
  • The values for padding must include the size of the icons, otherwise you will get an invalid result. For example, in your case, to get 0 padding between the icons, you must pass values of 150 and 150 for the padding.
  • Sending a value of -1 will reset the padding to default.
 
Old 05 May 2013   #7
Thank you so much Mr.Lo, your function just work fine.
 
Old 05 May 2013   #8
Thread automatically closed

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.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 10:54 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.