Alter mask of image on button

R

RB Smissaert

I understand now that the images on buttons are a picture and a mask.
Would it be possible to alter the mask of this image?
I use a temporary button to get some FaceID images in an ImageList like
this:

'Add an empty toolbar
Set NewToolbar = Application.CommandBars.Add _
(Name:="FaceIds", temporary:=True)
NewToolbar.Visible = False

On Error Resume Next
For i = 0 To 14
Set NewButton = NewToolbar.Controls.Add _
(Type:=msoControlButton, id:=2950)
NewButton.FaceId = FaceIDNumbers(i)
NewButton.CopyFace
Set iImageName = .ImageList1.ListImages.Add(, ,
PastePicture(xlBitmap))
NewButton.Delete
Next
On Error GoTo 0

NewToolbar.Delete
Set NewToolbar = Nothing

PastePicture is the routine written by Stephen Bullen.
The trouble is that I can't alter the background colour of this image and it
is always like a grey/brown colour.
I can export the image and mask separately (from the Excel help):

Sub GetButtonImageAndMask(cbButton As CommandBarButton)

Dim picPicture As IPictureDisp
Dim picMask As IPictureDisp

With cbButton
'Get the button image and mask of this CommandBarButton object
Set picPicture = .Picture
Set picMask = .mask

'Save the button image and mask in a folder.
stdole.SavePicture picPicture, "c:\FaceIDPicture" & .FaceId & ".bmp"
stdole.SavePicture picMask, "c:\FaceIDMask" & .FaceId & ".bmp"
End With

End Sub


So, maybe it is somehow possible to alter the mask.
I can see there is the Render method of this mask, but couldn't find any
information how to use this.
Any ideas how to do this?


RBS
 
R

RB Smissaert

All solved this now with the help of Peter T.
Very simple solution, exporting to file, altering the image in a graphics
program (mask the
background colour) and then import in the ImageList control.
All working fine and as a bonus I don't need PastePicture routine of Stephen
Bullen anymore.

RBS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top