JDYoder
10-05-2001, 05:38 AM
Can optionbuttons be transparent so that the form's background picture behind them shows through? So that all you'll see of the optionbutton is the circle portion, and whatever text is in it's label?
Can OptionButtons be Transparent?JDYoder 10-05-2001, 05:38 AM Can optionbuttons be transparent so that the form's background picture behind them shows through? So that all you'll see of the optionbutton is the circle portion, and whatever text is in it's label? ChiefRedBull 10-05-2001, 06:17 AM I would guess this involves subclassing the button.... and no doubt <font color=purple>Hand</font color=purple> will appear any moment now and explain all..... images/icons/wink.gif Chief "How are we to learn, if those that know will not teach... ?" - Me. Laurent 10-05-2001, 06:28 AM can't you simply use visible=false? I'll be amongst the best any minute now ! Banjo 10-05-2001, 06:33 AM That would remove the optionbutton entirely. JDYoder wants to have the button and text visible but with a transparant background instead of a solid colour. Laurent 10-05-2001, 06:36 AM oups sorry! that wasn't what i tought I'll be amongst the best any minute now ! ChiefRedBull 10-05-2001, 06:40 AM If you set the visible to false you wouldn't be able to see the option button at all! Thats not what you want right? You just want to be able to see through it, but still see the button and the text? I'm getting slow in my old age...images/icons/wink.gif Chief "How are we to learn, if those that know will not teach... ?" - Me. JDYoder 10-05-2001, 06:41 AM Correct, Banjo and ChiefRedBull. Anyone even know if it's possible? Banjo 10-05-2001, 06:50 AM As Chief said you could sub-class the OptionButton. You'd then have to intercept the WM_PAINT message to draw your own background. However, you would also have to draw the rest of the control as well. Ad1 10-05-2001, 06:50 AM try searching here or the user interface board, I'm sure I have seen this exact same question answered before, maybe 2 or 3 months ago Garrett Sever 10-05-2001, 07:27 AM The answer is - yes and no. They can be, but its not easy. If you are using a pattern brush to paint on the background of the parent (form, picturebox, etc), you can subclass the option button and capture the WM_CTLCOLORSTATIC message. If you pass back the handle to your pattern brush, then it will paint the background with that brush. Look here (http://www.visualbasicforum.com/bbs/showflat.php?Cat=&Board=visbas&Number=43778&page=3&view=collapsed&sb=5&o=7&part=) for an example of this method. The other possibility is a brute-force interception of the WM_PAINT message, as Banjo indicated. The above link will show this method as well. Or look at this (http://www.visualbasicforum.com/bbs/showflat.php?Cat=&Board=CodeLib&Number=45147&page=0&view=collapsed&sb=5&o=93&part=) project for another example. This leaves you with three potential solutions: 1) You could use GetDC on the optionbutton's parent hWnd and copy the control into a memory bitmap. You could then create a pattern brush using this bitmap and pass it back to the WM_CTLCOLORSTATIC message. Granted, this is not going to be simple to code, and I don't really feel like messing with it. 2) You could use the SetWindowRgn / CombineRgn API functions to limit the Option button's window to the only non-background pixels. This would be less involved than option 1. Look here (http://www.visualbasicforum.com/bbs/showflat.php?Cat=&Board=CodeLib&Number=45565&page=0&view=collapsed&sb=5&o=7&part=) for code on this. 3) You could take the easy way out. I do this all the time. Use an optionbutton/label combination. Make the optionbutton tiny (195 twips X 195 twips or so) and change its style to Graphic. Put a label next to it and set ITS background property to "Transparent". You can even go so far as to use a bitmap checkmark or something and set the mask color. I've attached a screenshot of what I mean. Regards, -<font color=purple>The Hand</font color=purple> <font color=green>All your code are belong to us...</font color=green> images/icons/tongue.gif Garrett Sever 10-05-2001, 03:57 PM I've posted an example project (http://www.visualbasicforum.com/bbs/showflat.php?Cat=&Board=CodeLib&Number=54561&page=0&view=collapsed&sb=5&o=7&part=) of method #2 in the Code Library section of the forum. To show how easy it is, this took me 15 minutes this morning over one cup of coffee. Attached is a screenshot. Regards, -<font color=purple>The Hand</font color=purple> <font color=green>All your code are belong to us...</font color=green> images/icons/tongue.gif<P ID="edit"><FONT class="small"><EM>Edited by The Hand on 10/05/01 06:39 PM.</EM></FONT></P> JDYoder 10-06-2001, 04:06 PM Thanks for the responses! (Would have replied sooner, but couldn't get into this forum for some reason). Anyway, wish it was easier, but I'll look into the various methods. Thanks! Garrett Sever 10-06-2001, 04:26 PM The second method posted in the Code Library (link above) will do exactly what you need. Just include the VB module in your project. I've already done it for you. -<font color=purple>The Hand</font color=purple> <font color=green>All your code are belong to us...</font color=green> images/icons/tongue.gif JDYoder 10-09-2001, 08:40 AM Hand -- I was just now able to take a look at this. And it ROCKS!! Thanks for much! You da man! BTW, I want to give credit where credit is due. So is it enough that your name is in the code? Or in the actual exe that uses it, would you like your name in credits as well? |
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum