Notifications
Clear all

[Closed] MAXScript dotNetController font help please

Hi I got a button all set-up in max and i was wondering is there a way to set the size and colour of my font???

I’m sure there is, but the size is a read-only… so I’m wondering how to get around this…

I’m very new to dotNet… In fact this is my first attempt at a simple button.


   try(destroyDialog testRoll)catch()
   
   rollout testRoll "Test"
   (
   	dotNetControl testButton "system.windows.forms.button" height:50
   	
   	on testRoll open do
   	(
   		testButton.text="testButton"
   	)
   )
   createDialog testRoll

I get this out of properties
.Size : <System.Single>, read-only

::EDIT::

i solved the font colour
testButton.ForeColor was the solution

after some searching i found that i most likely need to create a new font object… then apply or clone it to the current font of the button

18 Replies

 testroll.testbutton.font = dotNetObject "System.Drawing.Font" "Times New Roman" 24
-- or with some font styling
dnFontStyle = dotNetClass "System.Drawing.FontStyle"
myFontStyle = dotnet.combineenums dnFontStyle.bold dnFontStyle.italic
testroll.testbutton.font = dotNetObject "System.Drawing.Font" "Times New Roman" 24 myFontStyle
 

( oh the hilarity! )

awesome.

wow… i missunderstood “fontFamily” when you build the font…

… i kept getting that wrong type error… but never really caught on to what was causing it.

thanks a bunch… i was so close

Does anybody else get the impression that parts of .NET where created while on drugs?:hmm:

 PEN

Marco, it is a far cry from active X where the’re on drugs but they were also alcoholic schizophrenics with a touch of ADD.

Do you mind if I add this to my Dotnet button page Richard?

Paul: of course not ( though maybe use a label other than testButton )

Marco: true, but can’t the same be said for most languages, really?
Even MaxScript has some horrible inconsistencies, idosyncracies, etc.
Take for example the matchPattern functionality.

matchPattern string pattern:"<pattern>"

Practically everywhere where it’s important, a keyword parameter is optional; if it weren’t optional, you’d use a positional parameter. Yet, matchPattern absolutely -requires- you to specify the pattern, but to do so you use the keyword parameter.

I can think of similar oddities in half a dozen other scripting languages I’ve worked with or encountered

 PEN

Thanks Richard

Funny the example that you gave is one that I have to look up every time I use it, I always forget the parameter keyword as I know there is no defaut that is used and it has to be passed.

 PEN

Here it is, I just left it in the button help, at some point I should do separate pages on things like this. This was quick and dirty but gets the point across.

http://paulneale.com/tutorials/dotNet/button/button.htm#fontStyling

@PEN:

Hehe, luckily I skipped the activeX era =D. Nice going with the reference btw.

@ZeBoxx2:

Probably yes, I was just venting my frustration after the latest “OH MY GOD WHAT THE HELL WHERE THEY THINKING” moment with .NET. Things like this changing fonts or setting up colors (fromARGB?!) just seem so pointlessly contrived.

just an extra bit while we are on the subject of buttons – when using the flat styling property, you don’t have to use the mouseover and mousedown handlers to change button color states, there is a flatappearance property that can do this for you –

try(destroyDialog testR)catch()
 
 rollout testR "Test"
 (	
 	local Ccolor = dotnetclass "system.drawing.color"	
 	dotNetControl testButton "system.windows.forms.button" height:50
 				
 	on testR open do
 	(
 		testButton.flatStyle=testButton.flatStyle.flat
 		testButton.text="Test Button"
 		testButton.TextAlign= (dotNetClass "System.Drawing.ContentAlignment").BottomRight
 		testButton.backColor=testButton.backColor.lightBlue
 		
 		testButton.flatappearance.mouseoverbackcolor = Ccolor.green
 		testButton.flatappearance.mousedownbackcolor = Ccolor.red		
 		testButton.flatappearance.bordercolor = Ccolor.yellow		
 	)	
 )
 createDialog testR green
 
Page 1 / 2