Transparent CheckBox (How To?)

Windows specific forum
LuaDev
User
User
Posts: 33
Joined: Tue Feb 16, 2010 2:41 pm

Transparent CheckBox (How To?)

Post by LuaDev »

Hi Guys

I have a few checkboxs over a image and i need the to make the background transparent so it all looks like it should, after searching the forum and MSDN for half the day to find i can only change the actual color of the background, iv conceded to ask for help

Is it possible to make the background area transparent, and if so, please, show me how

Thanks in advance
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Transparent CheckBox (How To?)

Post by IdeasVacuum »

I was looking for an API way some time ago. It could be that there is an answer in the API but I couldn't find it. Even if you set your transparency colour to the colour seen around the box (rgb 248,248,248), nothing doing.

You could define your own 'gadget', something like an image gadget and two images to toggle or two 2D draw routines drawing directly on your window.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
LuaDev
User
User
Posts: 33
Joined: Tue Feb 16, 2010 2:41 pm

Re: Transparent CheckBox (How To?)

Post by LuaDev »

i also tried all manor of things to draw the background as transparent but no dice

the thing is, my app has a selection of *.msstyle skins that i wanted the checkboxs to adhere to, so im going to have to either recreate each theme checkbox (which i dont want to have to do, i want it to be future proof) or just stick them in a container and be done with it

the latter sounds best to me at this stage

Thanks for the input
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Transparent CheckBox (How To?)

Post by netmaestro »

There's good news and bad news on this front. The bad news is that because the checkbox is a type of button, the OS will ignore brushes returned from WM_CTLCOLORBTN and this makes the usual approach fail. However, the good news is that a checkbox is one of the easiest controls to ownerdraw. You can use the checkmark from the Marlett font (letter 'b') for the check and DrawFrameControl for the box, and draw your text transparently. Done.
BERESHEIT
LuaDev
User
User
Posts: 33
Joined: Tue Feb 16, 2010 2:41 pm

Re: Transparent CheckBox (How To?)

Post by LuaDev »

Thanks for the tips, i tried it, it didn't quite look like i wanted, looks better in a coloured container with skinned checkboxes
Post Reply