Notifications
Clear all

[Closed] DotNet controls Picture Box

The LoneRobot script seems to work fine here. What Max version are you on? Also I couldn’t get your script yo display any buttons…

I have 3DsMax 9
In my script you must do these steps to load images in to form

  1. make a dir
  2. create one subdir inside
  3. put there some jpg images
  4. run the script, dialog will be apear
  5. press button browse and assing the first dir
  6. images will be loaded in to buttons

now check the buttons if is highliting and rClick menu is apearing
merge some model in scene and check it again… image buttons will be dead

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

Actually the buttons are not dead. They are staying alive, but their event handlers are dead…

 PEN

Wow, that is one nasty bug. Is there a way to check for them and add them back?

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

IMHO it’s the [color=red]TERRIBLE BUG! It’s possible to handle some general events and re-add event handlers to layout’s controls… But there is no way to handle gc itself. [/color]

actualy Yes! they ar not dead ,but the result is nearly same.

This gallery is supposed to store and add meshes to scene. 

To make work going “faster”.
Now if I’m merge an object in to scene.
Then I must every time fil flowlayoutpanel with [color=white]event Handlers[/color](slow down)
And if will be there more than 100 obj in the Gallery…?

 PEN

Well get that bug reported over at ADSK’s bug reporting page so that it gets corrected. Does this still happen if you are not using a rollout and use a dotNet dialog instead?

1 Reply
(@merlinel)
Joined: 11 months ago

Posts: 0

Hi PEN

here is all made in DotNet form:


  (
local jpg_images_dir = "E:\\3DGallery\\Objects\\Table" --set dir with JPG IMAGES

local colorclass = dotnetclass "system.drawing.color"
local colors = dotNetClass "System.Drawing.Color"
local dockStyle = dotNetClass "System.Windows.Forms.DockStyle"
local singleborder = (dotNetClass "System.Windows.Forms.BorderStyle").fixedsingle	
 local dnfont = dotNetObject "System.Drawing.Font" "Verdana" 6.5 ((dotNetClass "System.Drawing.FontStyle").bold)
 local dnfontlarge = dotNetObject "System.Drawing.Font" "Verdana" 8.5 ((dotNetClass "System.Drawing.FontStyle").bold)
 local dnMXSlarge = dotNetObject "System.Drawing.Font" "System" 8.5 ((dotNetClass "System.Drawing.FontStyle").bold)

local leg = dotnetobject "label"
leg.text = "textbox"
leg.margin = dotnetobject "system.windows.forms.padding" 2
leg.size = dotnetobject "system.drawing.size" 543 531

fn Btn_Pressed sender eventargs =
 (
	 local stringdata
	 leg.forecolor = sender.forecolor		
	 leg.backcolor = if sender.text == "Transparent" then colorclass.white else sender.backcolor		

	 --higlight thumbnails
	 if sender.backcolor == colorclass.yellow
	 then
	 (
		 stringdata = "pressed 1"--sender.tag
		 sender.backcolor = colorclass.cadetblue
	 )
	 else
	 (
		 stringdata = "pressed 2"--sender.text	
		 sender.backcolor = colorclass.yellow --not working too
	 )
	 leg.text = stringdata
	 show eventargs
 )

local flp = dotnetobject "flowlayoutpanel"
flp.width=543
flp.height=531

flp.padding = dotnetobject "system.windows.forms.padding" 2	

local Images_Array = getFiles (jpg_images_dir + "\\*.jpg")
local dnobjarray = #()
for i in Images_Array do
 (
	local btndragdrop = dotnetobject "button"
	btndragdrop.size = dotnetobject "system.drawing.size" 160 120
	 btndragdrop.forecolor = colorclass.ivory --text color
	 btndragdrop.margin = dotnetobject "system.windows.forms.padding" 2 -- thumbs distance
	 btndragdrop.flatstyle = (dotNetclass "System.Windows.Forms.FlatStyle").flat
	 btndragdrop.font= dnfont
	 btndragdrop.text = getFilenameFile i	
	 btndragdrop.textalign = (dotnetclass "System.Drawing.ContentAlignment").BottomCenter
	btndragdrop.Image = dotNetObject "System.Drawing.Bitmap" i
	dotNet.addEventHandler btndragdrop "click" Btn_Pressed
	append dnobjarray btndragdrop
)
flp.controls.addrange dnobjarray

local dotForm = (dotNetObject "System.Windows.Forms.Form")
dotForm.Controls.addrange #(flp,leg)
--dotForm.Controls.add leg
dotForm.Text = " Picture Box Test 1"
dotForm.topmost = true

dotForm.show()
)
  

The dotNetBug is won again…:shrug:

I would NEVER let MAX kick my a$$!!!

I found how to fix this bug…

Doesn’t work:


try(destroydialog dlg) catch()
rollout dlg "" 
(
 dotNetControl flp "flowlayoutpanel" height:60
 
 fn whenButtonClick s e = (format "\"%\" clicked
" s.text)
 fn makeButtons = for k=1 to 2 collect 
 (
  btn = dotnetobject "button"
  btn.text = "Layout B" + (k as string)
  dotNet.addEventHandler btn "click" whenButtonClick
  btn
 )
 on dlg open do
 (
  local buttons = makeButtons()
  flp.controls.addrange buttons
 )
)
createdialog dlg

Works!!!


try(destroydialog dlg) catch()
rollout dlg "" 
(
 dotNetControl flp "flowlayoutpanel" height:60
 
 local buttons = #()
 fn whenButtonClick s e = (format "\"%\" clicked
" s.text)
 fn makeButtons = for k=1 to 2 collect 
 (
  btn = dotnetobject "button"
  btn.text = "Layout B" + (k as string)
  dotNet.addEventHandler btn "click" whenButtonClick
  btn
 )
 on dlg open do
 (
  buttons = makeButtons()
  flp.controls.addrange buttons
 )
)
createdialog dlg

Find one difference

Actually this is not a bug at all. I understand now why it happens. (… and not with only Layout control).

 JHN

Is it because the controls/eventhandlers are created and assigned in a global or local scope and then assigned to a dotnet control. The eventhandler stays in that scope but is not used and thus cleared whenever a gc occurs. So when the time comes to call the eventhandler it’s gone.

Something like that?

-Johan

It seems no solution be found here
I will try to find some other way

but thanks guys anyway :wavey:

Maybe a bit late, but i saw you got the showproperties a tad wrong.
here is how to get the properties of various controls:

rollout tltest "XtraTreeList Test" width: 300 height: 200
 (   
 	dotNetControl tl "DevExpress.XtraTreeList.TreeList" width: 274 height: 180
 	fn ListProps ax p:true m:true e:true =
 	(
 		clearlistener()
 		format "%: %
" ax (classof ax)
 		if p do try (format "PROPERTIES:
"; showProperties ax) catch (format "No Properties for %
" ax)
 		if m do try (format "METHODS:
"; showMethods ax) catch (format "No Methods for %
" ax)
 		if e do try (format "EVENTS:
"; showEvents ax) catch (format "No Events for %
" ax)
 	)
 	on tltest open do ListProps tl
 )
 createdialog tltest

now you get all the properties, methods and event hadlers.

Page 3 / 4