Custom Control.Backdrop

I have a custom control made from a canvas control (windows os).Though the mouse down event I have the image change…and change back to the original through the mouse up event. I do this for quite a few images in the control with a if/elseif (below is the mouse down event). The mouse down image is always the same name but with “_d” on the end. This custom control is just for myself and is specifically for this app so I realize it is not flexible enough to use for other apps. Is there a way where instead of using this big if/else that I can do something like Me.Backdrop = Me.Backdrop.tostring.+ “_d”? I know that syntax is not possible, from what I’ve read you can’t convert a string to a picture and load it like that. I was wondering if there was some other way. Thanks for any help you can provide.

if Me.Backdrop = button1 then
Me.Backdrop = button1_d
elseif Me.Backdrop = button2 then
Me.Backdrop = button2_d
elseif Me.Backdrop = button3 then
Me.Backdrop = button3_d
elseif Me.Backdrop = button4 then
Me.Backdrop = button4_d
end if

Add 2 arrays of type picture to your control, and 2 other variables
LiteArr() as picture
DarkArr() as Picture
IsShowingDark as boolean
CurrentStyle as integer

Initialise them in the constructor.

So for example,
LiteArr(2) = button2
DarkArr(2) = button2_d
IsShowingDark = false

Now, in your button down/ up code, all you need is this:

if IsShowingDark then 
  Me.backdrop = LiteArr(CurrentStyle)
  me.backdrop = DarkArr(currentstyle)
end if
IsShowingDark = not IsShowingDark

Thanks Jeff, I’ll give it a try.