Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Alter mask of image on button

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Alter mask of image on button

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


"RB Smissaert" wrote in message
...
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change button image juanperez Excel Discussion (Misc queries) 0 February 5th 09 04:49 PM
Paste Button Image Sarah at DaVita Excel Discussion (Misc queries) 2 June 1st 07 08:46 PM
2007 - Customize Button Image Guackyxxx Setting up and Configuration of Excel 3 April 22nd 07 08:24 PM
Filling command button with image Josh Sale Excel Programming 4 October 5th 04 03:26 PM
upload a button image Oliver Chiu Excel Programming 3 July 17th 03 07:33 PM


All times are GMT +1. The time now is 11:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"