Notifications
Clear all

[Closed] Dot net control on CA modifier not working

er…but how am I going to pass arguments from the CA to the createwindow function to the new dummy rollout window?

 lo1

Well, not very elegant, but unless you restructure your program somehow, this is the best idea I currently have:

rollout dummyRollout ""
(
	local parameter
	
	on dummyRollout open do
	(
		if parameter != undefined do createWindow parameter
		destroyDialog dummyRollout
	)
)
on yourCAButton pressed do
(
	dummyRollout.parameter = 42
	createDialog dummyRollout	
)

all dotnet events don’t work in form run from a ca or a plugin placed in modifier panel.
the problem is that all initialization for all dotnet objects done at moment when ca or plugin is not active yet.
here is my solution:


global executeTimer = 
(
	timer = dotnetobject "Timer"
	timer.interval = 10
	fn executeJob s e = 
	(
		s.Stop()
		s.tag.value[1] data:s.tag.value[2]
	)
	dotnet.addEventHandler timer "Tick" executeJob
	timer
)

custAttr = attributes custAttr
(
	fn showDialog data:undefined = 
	(
		form = dotnetobject "MaxCustomControls.Maxform"
		form.StartPosition = form.StartPosition.Manual
		form.Size = dotnetobject "System.Drawing.Size" 170 230
		form.Location = dotnetobject "System.Drawing.Point" 1000 200
		form.ShowIcon = form.ShowInTaskbar = form.MaximizeBox = form.MinimizeBox = off
		
		form.Text = "CA Dialog"
		form.tag = dotnetmxsvalue data
		
		bt = dotnetobject "Button"
		bt.Text = "Click Test"
		bt.Height = 24
		bt.Dock = bt.Dock.Top
		
		fn onClick s e =
		(
			print "Click"
		)
		dotnet.addEventHandler bt "Click" onClick
		
		form.controls.add bt
		form.Showmodeless()
		
		fn onShown s e = 
		(
			print "Shown"
			if s.tag.value != undefined do s.tag.value.params.bt.Enabled = off
		)
		dotnet.addEventHandler form "Shown" onShown
		fn onClosed s e = 
		(
			print "Closed"
			if s.tag.value != undefined do s.tag.value.params.bt.Enabled = on
		)
		dotnet.addEventHandler form "Closed" onClosed
		form
	)
	local dialog
	
	parameters params
	(
	)
	rollout params "Edit"
	(
		dotnetcontrol bt "Button" text:"Show Window" width:120 height:24  align:#center
		on bt MouseClick s e do
		(
			showDialog data:this -- not events!!!
			
		    /* replace line above with two lines below to get events working */
			
		    --executeTimer.tag = dotnetmxsvalue #(showDialog, this)
			--executeTimer.Start()
		)
		on params open do
		(
			
		)
	)
)
delete objects
b = box isselected:on
custattributes.add b custAttr baseobject:on

of course it’s just the idea.

Thanks guys. (denis -wow) I had no idea it was such a complex issue. I might consider using msx approach.I thought dotnet made things simpler.

Io – I couldn’t get the parameter to attach to dummyrollout via the dummyrollout.parameter = 42 method…

 lo1

sorry, my bad. This one works:

fn handlerFunction =
(
	print "Mouse is down."
)

fn someFunction param =
(
	local form = dotNetObject "Form"
	form.width = form.height = param
	
	dotnet.addEventHandler form "MouseDown" handlerFunction
	
	form.show()	
)


rollout dummyRollout ""
(
	local param
	
	timer tim interval:5 active:on
	
	on tim tick do if param != undefined do 
	(		
		destroyDialog dummyRollout
		someFunction param
	)
)


att = attributes "testAtt"
(
	rollout attRol ""
	(
		button runFn "runFn"
		
		on runFn pressed do
		(			
			createDialog dummyRollout pos:[-2000,-2000]
			dummyRollout.param = 400
		)
	)
)

myBox = box isSelected:on
custAttributes.add myBox att

thanks…the param tho…I was wanting to transfer specific morph targets…not form width …
edit///ok I get it…I’ll try with some real arguments…

 lo1

well what’s stopping you?

yeep…thanks Io…now I’ve forgotton why I’m fighting the dot net thing…it’s faster, right? But speed isn’t the issue really…thnx again

Page 2 / 2