How to create a dontnet button to display one image when pressed once, and another - when pressed second time(for example red and grey)
--btn = dotnetobject "Button"
dotnetcontrol btn "System.Windows.Forms.Button" pos:[667,101] width:15 height:15 border:false
--btn.FlatStyle = btn.FlatStyle.Flat
btn.flatstyle = dotnetobject "System.Windows.Forms.FlatStyle" Flat
btn.Location = dotNetObject "System.Drawing.Point" 1 prevh
i=1
if i==1 then
(
btn.image = (StringToImage record_red)
i=0
)
else
btn.image = (StringToImage record_grey)
just to use that if, or there is a more correct way?
Comments (13)
Comment policy
A growing number of musicians are making their music available for licensing on royalty free music websites like MusicRevolution.com.
aah
ok! Thx Barigazy! You answered to my questions! I guess you'll have a headache because of me!
No I just try to replicate free iToo Clone modifier with mxs modifier but I go to the dead end. It's not posible, only C++ can be solution. You already have same problem in another post:)
oh, yeesss
It's working great now! By the way, does this kind of menu support separators?
Is it possible with it to create smth like that?
http://www.scriptspot.com/files/rcmenu.jpg
Yup. But you can't paint in dark gray separator. Not works.
Take look of properties of context menu. I used Proffesional mode and remove left part (where you add F1)
Answer!
About record button! It works great, THX, just didn't have time to convert it to work as btn.image, because I have image to display instead of text! By the way, does btn "CheckBox" support image?
Now about context menu! It shows just a shadow when pressing rightclick on record button-I mean about second script. See the attached image!
I appreciate very much your help, barigazy!!!! You're brave!
Attachments
.net checkbox support images.

ContextMenu works fine I tested in max2012x64 and 2014x64
Disable transparency ei. put "--" (as comment) or delete this line
--maybe this cause problem
dnCM.Opacity = 0.85d0
oh, thx Barigazy
I will try your code and I will let you know later! Thx again! Srry that I give so many questions!
on no
in my case it will be always red :)
;)
Is this simple enought
try(destroyDialog ::bgaRoll)catch()
rollout bgaRoll "• • •"
(
fn defColor r g b = (dotNetClass "System.Drawing.Color").FromArgb r g b
fn defFont fName fSize = (dotNetObject "System.Drawing.Font" fName fSize ((dotNetClass "System.Drawing.FontStyle").bold))
local C1 = defColor 100 100 100, C2 = defColor 0 0 0, C3 = defColor 150 20 20, C4 = defColor 220 220 220, Fnt = defFont "Verdana" 30
dotnetcontrol btn "CheckBox" pos:[10,10] width:180 height:80
on bgaRoll open do
(
btn.BackColor = C1 ; btn.ForeColor = C2 ; btn.font = Fnt
btn.Text = "• REC" ; btn.Appearance = btn.Appearance.Button
btn.TextAlign = btn.TextAlign.MiddleCenter ; btn.FlatStyle = btn.FlatStyle.Flat
btn.FlatAppearance.BorderSize = 10 ; btn.Cursor = (dotNetClass "Cursors").Hand
btn.FlatAppearance.CheckedBackColor = btn.FlatAppearance.MouseDownBackColor = C3
--btn.FlatAppearance.MouseOverBackColor = C1
--dnCBtn.FlatAppearance.BorderColor = C2
)
on btn MouseUp arg do
(
if btn.checked then btn.forecolor = C4 else btn.forecolor = C2
)
)
createDialog bgaRoll 200 100 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)
:)
And finaly I add example with ContextMenuStrip that you asked in previous post
Here we go. Just press RMB over button
try(destroyDialog ::bgaRoll)catch()
rollout bgaRoll "• • •"
(
fn defColor r g b = (dotNetClass "System.Drawing.Color").FromArgb r g b
fn defFont fName fSize = (dotNetObject "System.Drawing.Font" fName fSize ((dotNetClass "System.Drawing.FontStyle").bold))
fn defSize x y = (dotNetObject "System.Drawing.Size" x y)
fn defPoint x y = (dotNetObject "System.Drawing.Point" x y)
local C1 = defColor 100 100 100, C2 = defColor 0 0 0, C3 = defColor 150 20 20, C4 = defColor 220 220 220
local Fnt1 = defFont "Verdana" 30, Fnt2 = defFont "Verdana" 6.5
fn defCnxMenu dnCM items:#("Record1", "Record2", "Record3", "Record4") =
(
fn defTSMI itmStr =
(
local itm = dotNetObject "ToolStripMenuItem" itmStr ; itm.BackColor = C1
itm.AutoSize = off ; itm.Size = defSize 80 20 ; itm.Font = Fnt2 ; itm
)
dnCM.RenderMode = dnCM.RenderMode.Professional
dnCM.ShowCheckMargin = dnCM.ShowImageMargin = dnCM.AutoSize = off
dnCM.Size = defSize 81 84 ; dnCM.Opacity = 0.85d0
dnCM.Items.AddRange (for i in items collect (defTSMI i))
dotNet.addEventHandler dnCM "ItemClicked" \
(
fn cnxMenuClick s e =
(
case e.ClickedItem.Text of
(
("Record1"): print "Start Record1"
("Record2"): print "Start Record2"
("Record3"): print "Start Record3"
("Record4"): print "Start Record4"
)
)
)
)
dotnetcontrol btn "CheckBox" pos:[10,10] width:180 height:80
on bgaRoll open do
(
local dnCM = dotNetObject "ContextMenuStrip" ; defCnxMenu dnCM
btn.BackColor = C1 ; btn.ForeColor = C2 ; btn.font = Fnt1
btn.Text = "• REC" ; btn.Appearance = btn.Appearance.Button
btn.TextAlign = btn.TextAlign.MiddleCenter ; btn.FlatStyle = btn.FlatStyle.Flat
btn.FlatAppearance.BorderSize = 10 ; btn.Cursor = (dotNetClass "Cursors").Hand
btn.FlatAppearance.CheckedBackColor = btn.FlatAppearance.MouseDownBackColor = C3
btn.ContextMenuStrip = dnCM
--btn.FlatAppearance.MouseOverBackColor = C1
--dnCBtn.FlatAppearance.BorderColor = C2
)
on btn MouseUp arg do
(
if btn.checked then btn.forecolor = C4 else btn.forecolor = C2
if arg.Button == arg.Button.Right do (btn.ContextMenuStrip.Show btn (defPoint arg.x arg.y))
)
)
createDialog bgaRoll 200 100 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)
edit
If you need to change items count or font size in CMS you need also adjust height and width
--in this lines
itm.Size = defSize 80 20
dnCM.Size = defSize 81 84