Don't expect miracles here, this code is onle 10% done, but it does demonstrate how to make a supposedly solid control "transparent".
The main code you want to look at is in the TransLab.vb file. Pay attention to the TextChanged and OnPaint methods. There has been overwhelming pressure to show this to you all so I have not had time to comment or even finish this.
Most of you are bright enough to figure out how it works
Run the test program (included) and hit the partially obscured button.
Rate me!!!!
Let me know what you think.
######
Issues: Nothing much really, when the test app fires up, click the button as mentioned above and then label should spring to life, you may have to force a repaint by moving the form offscreen and bring it back.
I had a question, why do you dissallow the user to see the text changes in design time?
I didn't, not deliberately anyway, its that I didn't get round to making it public. I was only aiming to get the effect, I wasn't trying to make a full control
Epix: You'll have to wait I'm afraid. I have no plans to finish this at the moment.
The jaggie text can not be smoothed because of the method used to draw and cut the text. Its using the
DrawText method of the graphicspath object which does not support AntiAliasing.
The font size issue is because we didnt add support for fontsize, only fontcolor.
Glad you like it though. Maybe at some point we can determine a different method for transparency that will
allow us to smooth the text.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Also why does the text always show up smaller than the selected font size?
I also found this in my own version of the control (derived directly from Class Control rather than usercontrol). Frankly I have no idea. You can set the size of the font in the properties window like with any control, but it always seems to come out about 20% smaller at runtime than it does in designmode. Weird. Must be something to do with the way GraphicsPath.AddString works.
As Rob said, antialiasing in this articular situation is impossible because there is no available background to composite with. This is a problem that would take quite a lot of time and API to fix. It is possible though, and it would probably cause a lot of overhead.
Hey wossname, any new ideas on other methods for drawing the text only.
Perhaps some way to utilize a lables transparency to actually copy the colors behind it except for the text?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Hey wossname, any new ideas on other methods for drawing the text only.
Perhaps some way to utilize a lables transparency to actually copy the colors behind it except for the text?
Nope. I haven't given it any further thought. Doubt I'd ever need such a control anyway.