PDA

View Full Version : Colored Buttons


JHaywood
06-13-2008, 06:16 PM
Is there a way to color the buttons in a rollout? I've tried creating an imgTag the same width and height as the button, giving it a solid color bitmap, setting the opacity to .5 and moving into position over the button, but that doesn't seem to work. And I know that I can create an image to use for the button, but I want to the text display and just color the background.

Is there any way to do this?

kees
06-13-2008, 06:23 PM
Hey James,

I use a 'checkbutton' for this.
They have a color property and then just always keep the button pressed.

myCheckbutton changed state do
(
mycheckbutton.state = true
-- rest of your code goes here
)


Take care,

magicm
06-13-2008, 08:49 PM
Or use a dotnet button (System.Windows.Forms.Button) and set its .BackColor property.

Martijn

JHaywood
06-13-2008, 09:02 PM
How do I convert a maxScript color value ( [255,255,255] ) to System.Drawing.Color?

Bobo
06-13-2008, 09:27 PM
How do I convert a maxScript color value ( [255,255,255] ) to System.Drawing.Color?

See the bottom of the topic "Creating A Simple DotNet MonthCalendar And Changing Its Colors". The FromArgb() method exposed by System.Drawing.Color can convert (A)RGB values to DotNet colors. Just pass the R, G and B of the MAXScript color as arguments. Note that other than in ActiveX, the colors are in the correct RGB order and not BGR.

Alternatively, you can constuct a DotNetClass and call the method in it:

yourDotNetButton.backcolor = (DotNetClass "System.Drawing.Color").fromARGB 100 100 200

LoneRobot
06-16-2008, 12:40 PM
hi James,

just to add to Bobo's post, you can also use nice button properties like text positioning, mouse overlay colors, transparent images by specifiying a few more classes. The image in this case has a white background but you will have to let them point to a different bitmap for the code to run.

rollout DotNetTest ".Net UI on MXS Form"
(

dotnetcontrol mbutton "System.Windows.Forms.Button" height:60 width:80 pos:[5,5]
dotnetcontrol mbutton2 "System.Windows.Forms.Button" height:60 width:80 pos:[88,5]

on dotnettest open do
(
mcolor = dotnetclass "System.drawing.color"
malign = dotnetclass "System.Drawing.ContentAlignment"

maxBackColor = colorMan.getColor #background
DotNetBackColor = mColor.FromArgb (maxBackColor[1] * 255.0f) (maxBackColor[2] * 255.0f) (maxBackColor[3] * 255.0f)

imageclass = dotNetclass "System.Drawing.image"
-- load bitmaps
IListimage1 = imageclass.fromfile (LRUIdir+"zfstart.bmp")
IListimage2 = imageclass.fromfile (LRUIdir+"zfstop.bmp")
--create an imagelist
imglist = dotnetobject "System.Windows.Forms.ImageList"
imglist.imagesize = dotnetobject "System.Drawing.Size" 64 35
--add them to the image list
imglist.images.add ilistimage1
imglist.images.add ilistimage2
imglist.TransparentColor = mcolor.white

mbutton.text = "Add Start"
mbutton.flatstyle = dotnetobject "System.Windows.Forms.FlatStyle" Flat
mButton.TextAlign = malign.BottomCenter
mbutton.imagealign = malign.topcenter
mbutton.FlatAppearance.MouseOverBackColor = mcolor.limegreen
mbutton.backcolor = DotNetBackColor

mButton2.text = "Add Stop"
mbutton2.flatstyle = dotnetobject "System.Windows.Forms.FlatStyle" Flat
mbutton2.imagealign = malign.topcenter
mButton2.TextAlign = malign.bottomCenter
mbutton2.FlatAppearance.MouseOverBackColor = mcolor.coral
mbutton2.backcolor = DotNetBackColor

mbutton.ImageIndex = 0
mbutton.ImageList = ImgList
mbutton2.imageindex = 1
mbutton2.ImageList = ImgList
)

on mbutton click do
(
print "start pressed"
)

on mbutton2 click do
(
print "stop pressed"
)

)
createdialog dotnettest 175 80 style:#(#style_toolwindow, #style_sysmenu)

CGTalk Moderation
06-16-2008, 12:40 PM
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.