Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transparent backgrounds on my images for button

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
How do I get Access to show the white background on my BMP images as transparent when using them on command buttons?


Thanks,
1DMF

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

MIME::Lite TLS Email Encryption - Perl v0.02 beta
 
I think it needs to be a gif. BMP does not support transparency, and command buttons do not support gifs.

1) make it transaparent
GIMP is free if you do not have another image tool.
2) Use an image control and its click event.
 
using GIMP
IMG
 
I know it's possible as I have one application with BMP images and white BG's that show as transprent when applied to command buttons.

I just can't remember what I did to make it happen, it's been driving me nuts!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

MIME::Lite TLS Email Encryption - Perl v0.02 beta
 
If you can figure it out please post. I do not believe it can be done. However. If you use the technique I described, instead of a command button use a rectangle and set the color to system button face. Make it raised. Then add this code in a standard module. Will act just like a command button
Code:
Public Sub DepressButton(Rect As Rectangle)
  Rect.SpecialEffect = 2
End Sub
Public Sub RaiseButton(Rect As Rectangle)
  Rect.SpecialEffect = 1
End Sub

in the form
Code:
Private Sub Image9_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  DepressButton Me.RecBtn
End Sub

Private Sub Image9_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  RaiseButton Me.RecBtn
End Sub
 
I'm not making this up, there is something simple you do with in access and it makes the white BMP background go transparent.

I have attached an image showing the command buttons with the BMP on them and a copy of the actual BMP.

you will see it has a transparent BG on the button yet the image has a white BG!

I just wish i could remember what I did!



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

MIME::Lite TLS Email Encryption - Perl v0.02 beta
 
 http://www.homeloanpartnership.com/BMP-Access.gif
If you figure it out write a FAQ. I searched and could not do it. But interestingly if you put an image with a background on a command button, the background goes transparent when depressed. So it appears technically possible. If not the workaround I showed is pretty simple to implement. Access 2007 provided a lot of enhancements with using and working with images, and they are not that well documented. Some of these features are very powerful. For example the bound image control basically solved problems with rendering images from a path. Made this possible even in a continous form. This was a huge improvement, yet hardly any discussion on it.
 
Gimp allows saving of very large icons. Icons support transparency. Command buttons support icons ;)
To change the white background to transparent, flood fill the white with bright pink or green (something thats not used in the image). Then set the palette transparency to the same color. Save.
 
Well I don't recall doing it this way, but here is a way of achieving transparent background images on button controls...

1. Draw an image control on the form and select an image with transparency ( I used .PNG files )

2. Change the property 'Picture type' to 'shared' (noting control name or image name)

3. Click the button control

4. Click the property 'Picture' and you will see the picture from the image control is now available for selection, select it.

5. You can now change the button control 'Picture type' to 'Embedded'

You now have a transparent image that isn't compatible with buttons on a button control.

For each new button image required, simply change the image control picture source to your desired image and then use that shared image as the image for your button control.

Once you have your buttons with the desired images, simply delete the image control!

I am using Access 2010, so might only be possible with this version of access!

Hope it helps others as it was doing my head in for ages, but now all my buttons have nice trasparent images on them of my choice - sorted!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

MIME::Lite TLS Email Encryption - Perl v0.02 beta
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top