LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to overlay icons on picture buttons in CVI

Hello out there.
 
I have a problem with graphics. In my CVI app I'm using picture buttons. Now, what I want is to mark certain icon pictures on my buttons with "overlay" icons during run time. I guess the solution is simple, but I can't find it. Investigating towards Windows API didn't help me. My attempts went to bitmap overlay / windows icon overlay ... but at last nothing came to work.
 
Can someone help me ?
 
 
0 Kudos
Message 1 of 7
(4,796 Views)

Not sure I understand your problem - does not the SetCtrlBitmap() function do what you want?

JR

0 Kudos
Message 2 of 7
(4,785 Views)
Unfortunately Not. I'm looking for a way to Display 2 overlayed Pictures (Icons) on my button. I hoped it was possible to avoid mask-shifting bitmap-manipulation and so on ...
As I see the function SetCtrlBitmap can set only 1 Bitmap into the picture object.
 
 
0 Kudos
Message 3 of 7
(4,763 Views)

Hello Tomsaw,

I suggest the following workaround: create an invisible canvas. On this canvas, draw your icons using the desired transparency (for using transparency, refer to the example in C:\Program Files\National Instruments\CVIxx\samples\userint\alphablend.cws). Now, get the bitmap from the canvas using GetCtrlBitmap and put the bitmap on the picture button.

0 Kudos
Message 4 of 7
(4,759 Views)

Thank you for the good suggestion ! It almost works now ... but there's still a littlle problem.

When I have a canvas with a background colour it works fine - but: the color of the canvas appears on my button => not what I want

(the original icon in the background has a transparent frame, the original icon in the foreground is - despite a little part almost complete transparent).

When I have a canvas with transparent background colour it works fine - but: the color of the canvas appears on my button => not what I want

Using the function "DrawImage" from the sample you suggested doesn't work either. On my composite picture on the button I always have a black frame (former transparent). Is there any other way to keep transparency when copying the picture to the button Smiley Sad

 

0 Kudos
Message 5 of 7
(4,757 Views)
Tomsaw,

It's true that GetCtrlBitmap doesn't return a transparent bitmap, but would it work okay if you painted the canvas background to be the same color as the button?

Luis
0 Kudos
Message 6 of 7
(4,735 Views)
Hello and thanks for all the answers. It works now and it was quite easy at last.
 
1. Draw bitmap (background icon) on canvas with transparent background
2. Draw only visibe area of second bitmap (foreground icon) onto the canvas (made a little square frame on the foreground icon)
3. GetCtrlBitmap from canvas and SetCtrlBitmap on picture button - the transparent frame of the background picture button icon stays
 
 
0 Kudos
Message 7 of 7
(4,718 Views)