Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# .NET WinForm
I'm looking for a focusable (can raise GotFocus and LostFocus event), borderless and transparent background control with text presentation. Do you know any already made one or a custom one?
 
Please don't suggest me the link to Alpha blend transparent textbox (right in CodeProject), I've tried it and it's not fine enough (the rendered text looks worse than lacking of antialiasing). I don't find any control for that purpose except the RichTextBox with over ridden CreateParams. But I don't want to use RichTextBox, it's not light weight and even using it, I have to customize some event-related methods...
 
Your help would be highly appreciated!
Thanks.
Posted 17-Apr-13 8:08am
supernorb2.6K
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Suddenly there is a thought springing in my mind which helps me solve this. I can't believe there is such a simple solution.
 
The control I want is a very common control for customization. It's called UserControl. I tested it with a label added to a UserControl's Controls and set the label's Dock to DockStyle.Fill, set the text to any thing I want, set the UserControl's BackColor to Color.Transparent and wowww, it worked. I thought of drawing string myself but wondered how it gets and loses focus? UserControl is exactly what I want...
 
Thank God!
  Permalink  
Comments
supernorb at 17-Apr-13 14:02pm
   
There are many questions about Focusable Label??? And here, this is a good start point to create your own Focusable Label. It's so simple. Ha ha
Dave Kreskowiak at 17-Apr-13 14:30pm
   
and wowww, it worked. No, it didn't! You have the illusion it worked. Transparent in Windows Forms just tells the control to take on the background settings of the control that's hosting your control. If you put another control behind your control, you won't see it!
 
Transparent in Windows Forms is a complete lie. Why? Because the top control over a region of pixels OWNS all of the pixels it covers. When controls underneather your control are told to paint themselves, they are excluded from painting the pixels where your top level control sits.
supernorb at 18-Apr-13 8:16am
   
Sorry Dave Kreskowiak, I don't want it to be so real transparent. I only want it to be transparent to the background of the parent not to anything behind it. And I said it worked, it's not illusion.
supernorb at 18-Apr-13 8:19am
   
Thank you Dave Kreskowiak, anyway I would like to thank you because you let me know the real transparency in WPF, that has encouraged me more to visit the world of WPF. And I would like to accept your answer for that. Thanks =)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Sure. You can get an entirely library of such controls. Drop Windows Forms and use WPF. You get all the rendering options you could ever want.
  Permalink  
Comments
supernorb at 17-Apr-13 13:42pm
   
I love Windows Forms so much, don't want to get rid of it, and I'm sure to say I will love WPF for its features I can benefit from. But I'm asking this question for a solution in Windows forms, Oh WPF is my new world of programming windows. =))

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 555
1 Kornfeld Eliyahu Peter 409
2 Maciej Los 369
3 DamithSL 196
4 OriginalGriff 188
0 OriginalGriff 6,353
1 DamithSL 4,854
2 Maciej Los 4,466
3 Kornfeld Eliyahu Peter 4,058
4 Sergey Alexandrovich Kryukov 3,897


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 17 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100