Solved Transparent icons in ribbon bar (1 Viewer)

Saphirah

Active member
Local time
Today, 12:18
Joined
Apr 5, 2020
Messages
163
Hello everyone,

for my current project i created a custom Ribbon Bar using XML. For that i want to use custom icons, as you can see in this screenshot.
1591719531498.png

Basically my goal is to load an image (Red circles with numbers from 1-10) and display one of them, depending on a variable.
I created a bunch of bmp files with gimp, 32 bit using alpha channel, and the image displays correct in my photo viewer.

But every time i try to load the image using this access vba code
Code:
Public Sub LoadImages(imageId As String, ByRef Image)
    Set Image = LoadPicture(CurrentProject.Path & "\Icons\" & imageId)
End Sub

it prints an error:
Code:
Error 481: Invalid Picture

I did read online that the tool i used to export the images (GIMP) exports bmp files as an invalid format. That is why i pasted the image in Paint, exported it as a bmp and it loaded fine, but lost its transparency, as you can see in the screenshot.

1591719531498.png




So here is my question. What tools do you use to create a custom Ribbon icon? How can i import a transparent image as a ribbon icon? Maybe a different file format?
Thank you very much!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:18
Joined
Oct 29, 2018
Messages
21,357
Hi. I haven't tried it myself, but have you tried using a PNG image?
 

Saphirah

Active member
Local time
Today, 12:18
Joined
Apr 5, 2020
Messages
163
Hi. I haven't tried it myself, but have you tried using a PNG image?

Yeah but PNG images are not supported by the LoadPicture function.

Code:
The file name of the graphic to be loaded. The graphic can be a bitmap file (.bmp), icon file (.ico), run-length encoded file (.rle), or metafile (.wmf).
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:18
Joined
Oct 29, 2018
Messages
21,357
Yeah but PNG images are not supported by the LoadPicture function.

Code:
The file name of the graphic to be loaded. The graphic can be a bitmap file (.bmp), icon file (.ico), run-length encoded file (.rle), or metafile (.wmf).
Oh, that's a bummer.

PS. Have you checked this out?
 
Last edited:

cheekybuddha

AWF VIP
Local time
Today, 11:18
Joined
Jul 21, 2014
Messages
2,237
Hi, try converting to wmf.

IIRC they support transparency (but not opacity)
 

Saphirah

Active member
Local time
Today, 12:18
Joined
Apr 5, 2020
Messages
163
Oh, that's a bummer.

PS. Have you checked this out?
Hey, thank you for the link. Finally it is working using the basGDI Module! Thank you very much!

For future viewers: i changed the code
Code:
Public Sub LoadImages(imageId As String, ByRef Image)
    Set Image = LoadPicture(CurrentProject.Path & "\Icons\" & imageId)
End Sub
to
Code:
Public Sub LoadImages(imageId As String, ByRef image)
    Set image = LoadPictureGDIP(CurrentProject.Path & "\Icons\" & imageId)
End Sub

and imported the basGDI Module from the following file: https://www.accessribbon.de/Count/count.php?id=73
and it works like a charm
1591723657243.png
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:18
Joined
Oct 29, 2018
Messages
21,357
Hey, thank you for the link. Finally it is working using the basGDI Module! Thank you very much!

For future viewers: i changed the code
Code:
Public Sub LoadImages(imageId As String, ByRef Image)
    Set Image = LoadPicture(CurrentProject.Path & "\Icons\" & imageId)
End Sub
to
Code:
Public Sub LoadImages(imageId As String, ByRef image)
    Set image = LoadPictureGDIP(CurrentProject.Path & "\Icons\" & imageId)
End Sub

and imported the basGDI Module from the following file: https://www.accessribbon.de/Count/count.php?id=73
and it works like a charm
View attachment 82727
Hi. Congratulations! Glad to hear you got it to work. Good luck with your project.
 

Users who are viewing this thread

Top Bottom