Notifications
Clear all

[Closed] how to define text color

I try to change color but no resoult.
I have tree questions in one
a) Can I define color for text in label?
b) Can I define color for string ?
c) Can I define color of text in button and can I define color off button?
That’s four:)

Is it possible without long dotnet programming?
Do anybody know that?

9 Replies

a) yes. Use createDialog myRollout fgcolor:yellow. This will set the new color to all labels, but also to other controls. Test it and you will that this is not a good solution.
b) where you will show/use these strings?
c) no. For checkbuttons you can define the “checked” color.

d) use the dotNet if you want something different than standard maxscript controls
e) or go to very long way of making a UI like RTTAssist.

Thank You however the way you show me is not enough.
I need to change text color for some text in label like in this example:

rollout unnamedRollout “Untitled” width:162 height:300
(
button btn70 “Button” pos:[28,103] width:109 height:33
label alabel “White Colorl” pos:[25,22] width:114 height:66
on btn70 pressed do
(
———- <———— HERE COLOR OF THIS TEXT SHOULD BE RED OR YELLOW
rolloutlabel = “labfrrfrfrel”
alabel.text = rolloutlabel
)
)
createdialog unnamedRollout

I also need to change color of button(or create button in different colors)(but not checkbutton check state) color but not all of them only specyffied buttons and use different color of text in buttons.

Can You give me some quick example if it’s not to complicated?

To have so colorful UI you have to use dotnet.
Search the forum(there is a sticky thread for dotNet in maxscript), check the Paul Neal web page.

ok, Thank You, so is there any simple way without dotnet to make text look different than standart like changing font, size, text background, anything?
I need it for different strings in label and I’m not skilled in programming + deadline.

2 Replies
(@denist)
Joined: 11 months ago

Posts: 0

you don’t need anything complicated. just use dotnetconrol in mxs rollout
try(destroydialog test) catch()

rollout test "Color Labels" width:200
(
	local dotcolor = dotnetclass "System.Drawing.Color"
	
	dotnetcontrol lb_0 "Label" text:"Label" width:180
	dotnetcontrol lb_1 "Label" text:"Label" width:180
	dotnetcontrol lb_2 "Label" text:"Label" width:180
	dotnetcontrol lb_3 "Label" text:"Label" width:180
	
	local labels = #(lb_0,lb_1,lb_2,lb_3)
	local bcolors = #(dotcolor.Transparent, dotcolor.Orange, dotcolor.Yellow, dotcolor.Pink)
	local fcolors = #(dotcolor.Black, dotcolor.Red, dotcolor.Green, dotcolor.Blue)
	local fonts = #("", "MS Mincho", "Tahoma", "Old English Text MT")
	local sizes = #(8, 9, 7, 9)
	
	on test open do
	(
		for k=1 to labels.count do 
		(
			labels[k].Backcolor = bcolors[k]
			labels[k].Forecolor = fcolors[k]
			labels[k].font = dotnetobject "System.Drawing.Font" fonts[k] sizes[k]
		)
	)
)
createdialog test 
(@gazybara)
Joined: 11 months ago

Posts: 0

Or if you use max 2012 and above U can try this example

With maxscript there is no way to achieve what you want.
May be Denis can show some magic with c#, but this is beyond my knowledge, and most probably is not so simple as using dotnet.

Check this script from Branko.

it’s hardly the most rad dotnet


      maxuibg = (colorman.getcolor #background) * 255
      bgcolor = (dotnetclass "System.Drawing.Color").FromArgb maxuibg[1] maxuibg[2] maxuibg[3]
      fgcolor = (dotnetclass "System.Drawing.Color").FromArgb 0 0 255
      
      fn DotNetFont fontname size style =
      (	
      	FontStyle = dotnetclass "System.Drawing.FontStyle";
      	fs = case style of
      	(
      		#regular: 	FontStyle.regular;
      		#bold:		FontStyle.bold;
      		#italic:	FontStyle.italic;
      		#underline:	FontStyle.underline;
      		#strikeout:	FontStyle.strikeout;
      		default: 	FontStyle.regular;
      	)
      	dotnetobject "System.Drawing.Font" fontname size fs;
      )
      
      
      Rollout arollout "Static Test"
      (
      
      	dotNetControl tb "Label"  width:180 height:24 
      	
      	on arollout open do
      	(
      		tb.Text = "This is A String" 
      		tb.BackColor = bgcolor;
      		tb.ForeColor = fgcolor;
      		tb.Font = DotNetFont "Times" 16 #bold
      	)	
      	
      )
      createDialog arollout width:250 height:250

Thank all of you for help, so one way or another, dotnet is the only way to go.