Click to See Complete Forum and Search --> : transparent/invisible button
attahollander
September 18th, 2007, 09:39 AM
How can I create an invisible button?
I have a transparent image which is loaded into a hdc.
When the user clicks on the image, it should call a function, similiar to a normal button.
Are invisible buttons possible in winapi?
kirants
September 18th, 2007, 12:34 PM
A button is invisible if it doesn't paint itself and let the background see through. So, it is possible :)
But it is not clear if invisible button is what you want. It sounds like what you want is a button with an image. If so, check out BM_SETIMAGE message
attahollander
September 18th, 2007, 12:46 PM
A button is invisible if it doesn't paint itself and let the background see through. So, it is possible
But it is not clear if invisible button is what you want. It sounds like what you want is a button with an image. If so, check out BM_SETIMAGE message
No, I want the button to be invisible.
I want the function to be called when clicked on the button area.
How can I turn the button drawing off?
kirants
September 18th, 2007, 12:55 PM
Why do you even need a button then ? What is the purpose of an invisible button ?
attahollander
September 18th, 2007, 01:01 PM
I have an image with transparent background which should replace the function of the button. If I put the image on a button, the background is always gray, but never transparent.
Basically I want an image with transparent background, which can be pressed on :) (the window itself has another background)
kirants
September 18th, 2007, 01:18 PM
Basically I want an image with transparent background, which can be pressed on :) (the window itself has another background)
Perhaps an image of how you would want it to look like would help understand better.
attahollander
September 18th, 2007, 04:49 PM
Suppose I want a button like this:
http://www.fotostudioflash.nl/Button%20FSF%20werkwijze%202.jpg
where the strange pattern is the transparent background of another hdc, I don't want gray here. So I think the only solution would be to use an image that can be clicked on, as buttons can't be transparent.
kirants
September 18th, 2007, 07:38 PM
Recommend using GDI+ ( shipped with XP and up and redistributable dll available for 2k ).
Read this:
http://www.ddj.com/architect/184416447?pgno=1
idea is to make your button OWNERDRAW and handle WM_DRAWITEM to render the image to the passed in DC using GDI+ as described in the attached article.
kirants
September 18th, 2007, 07:39 PM
One more link:
http://marknelson.us/2002/07/01/rendering-transparent-gifs-revisited
attahollander
September 19th, 2007, 12:53 PM
Thanks, I got it working.
I've set the BS_OWNERDRAW and a Beginpaint/Endpaint to the button function. Now I can click on the image and it starts the function. ( I don't think this is GDI+ though, haha ), but it works :)
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.