473,385 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Painting under a control

Hi all.

I have given up trying to make my textboxes transparent. It can't be done
(AFAIK!) So now, I am going to try to paint under the textbox the part of
the screen that is covered by it. My (possible) problem is that the
textboxes are sitting on top of images, and also, I have no idea where to
start!

So, is there anybody here that can help or has done this already and is
willing to share the code?

Thanks,
Bob
Nov 21 '05 #1
1 1080
A solution which has a little issue: The cursor in the control is slightly
misplaced.

Imports System.Windows.Forms

Public Class TransparentTextBox
Inherits System.Windows.Forms.TextBox

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

Me.SetStyle(ControlStyles.Opaque, False)
Me.SetStyle(ControlStyles.SupportsTransparentBackC olor, True)
Me.SetStyle(ControlStyles.UserPaint, True)
Me.BackColor = System.Drawing.Color.Transparent
End Sub

'UserControl overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
components = New System.ComponentModel.Container
End Sub

#End Region

Protected Overrides Sub OnPaintBackground(ByVal pevent As
System.Windows.Forms.PaintEventArgs)
Me.SetStyle(ControlStyles.SupportsTransparentBackC olor, True)
Me.BackColor = System.Drawing.Color.Transparent
MyBase.OnPaintBackground(pevent)
End Sub

Protected Overrides Sub OnPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
e.Graphics.DrawString(Me.Text, Me.Font, New
System.Drawing.SolidBrush(Me.ForeColor), New
System.Drawing.PointF(e.ClipRectangle.X, e.ClipRectangle.Y))
End Sub

Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
MyBase.OnTextChanged(e)
Me.Invalidate()
End Sub

Protected Overrides Sub OnEnter(ByVal e As System.EventArgs)
MyBase.OnEnter(e)
Me.Invalidate()
End Sub
End Class

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Harry_Crow | last post by:
I'm painting in the Non Client area of the control. I'm facing some flicker problem. Is it possible to achive Double buffer painting in Non Client area. The SetStyle with...
5
by: Alien | last post by:
I have a hex editor-type class that extends UserControl and paints its data to a PictureBox. Basically the problem is that repainting it takes usually between 60 and 80ms, which may seem pretty...
3
by: Shravan Kumar | last post by:
Hi, I am using my code to set column widths of datagrid columns dynamically, but when I am setting the column widths to zero, the header text of the column whose width is made to zero is...
2
by: Robert Misiak | last post by:
Hi everyone- I've done a lot of searching around on the web and I'm sure the answer to this question is no, but I'll ask anyway. Is it possible to create an inherited MonthCalendar control and...
4
by: Dafü | last post by:
Hello! I have an application that paint graphics in VB.NET. Each graphic is painted after a long calculation process. My problem is when another windows pass over my graphics or I resize the...
2
by: Carl Gilbert | last post by:
Hi I am developing a custom on screen keyboard. So far I have an array of buttons and then using SendKeys to send the text of the button to the active control to receive the text. The only...
5
by: marfi95 | last post by:
I am having to resort to Mick's methods when it comes to hiding/showing tabpages of my tab control since .NET doesn't work correct. I think I have it finally workign the way I need, but because I...
1
by: Brendon Bezuidenhout | last post by:
Evening, I have a slight erk with the ComboBoxRenderer running under Vista and was hoping someone could shed some light on this for me. I've created a custom control that inherits from Button...
1
by: stowasser | last post by:
Does anyone know of a good drawing/ painting control? Anything that has a an online canvas that you can draw on and then add effects to? I don't mind a flash control, but I would like to use...
4
by: Marina Levit | last post by:
I am trying to do some processing on a background thread while keeping the UI painting. However, this is a generic server side call routine - and it needs to block until the server side call...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.