473,692 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Control.BackCol or Transparency, Control.BackCol or = Color.Transpare nt

in my app i need to make a RichTextbox control transparent.

i need it to be a like a pane of glass lying on a sheet of paper, where u
can see everything on the sheet of paper not covered by text written on the
glass pane. i need to be able to see the control or form that is underneath
the RichTextbox, and at the same time to be able to write and erase text to
the RichTextbox.

i'm assuming that it is the backcolor that hides what is underneath a
control. so i tried setting rtb.BackColor = Color.Transpare nt.

when u do that u get a error that BackColor may not be Color.Transpare nt.
bummer. i looked for help and found the following link on the cd that came
with net 2005

ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio .v80.en/dv_fxmclictl/html/32433e63-f4e9-4305-9857-6de3edeb944a.ht m
the heading is:
How to: Give Your Control a Transparent Background

in it it tells u the following:

=============== =========
By default, controls do not support transparent backcolors. However, you can
allow your control to have a background color that is opaque, transparent,
or partially transparent by using the Control.SetStyl e Method in the
constructor. The SetStyle method of the Control class allows you to set
particular style preferences for your controls, and can be used to enable or
disable support for transparent backcolors.

To give your control a transparent backcolor
Locate the constructor for your control class.

Call the SetStyle method of your form in the constructor.

SetStyle(Contro lStyles.Support sTransparentBac kColor, True)

This will enable your control to support a transparent backcolor.

Beneath the line of code you added in step 1, add the following line. This
will set your control's BackColor to Transparent.

Me.BackColor = Color.Transpare nt
=============== =============== ========

i subclassed the RichTextbox control, added a constructor, as follows: (i
tried Me.SetStyle(Con trolStyles.Opaq ue, False)
& Me.SetStyle(Con trolStyles.Opaq ue, True) & omitting it alltogether, it
didn't help.)
---------------
Public Class clsRtbx
Inherits System.Windows. Forms.RichTextB ox
Sub New()
SetStyle(Contro lStyles.Support sTransparentBac kColor, True)
Me.SetStyle(Con trolStyles.Opaq ue, False)
Me.BackColor = Color.Transpare nt
End Sub

End Class
--------------

to test it, i did the following in the Form_Load event

Dim rtb2 As New clsRtbx

rtb2.Text = ""
rtb2.Top = 0
rtb2.Left = 0
rtb2.Width = 300
rtb2.Multiline = True
rtb2.Height = 200
rtb2.BackColor = Color.Transpare nt 'i tried with this line, and without
it
Me.Controls.Add (rtb2)
rtb2.BringToFro nt()

when i did this, i did not get the color transparency error, but it still
hides everything underneath itself!

am i missing something?

i would greatly appreciate to find out if a control can be make transparent
(as explained above, to see what is underneath it, while being able to
write/erase to it), and how to do it.

thanks, ray


Jun 12 '06 #1
4 9364
I have code for this, but you will need to be patient as it is somewhere I
need to find.
Jun 12 '06 #2
stuart,

any chance u found the code?

thanks, ray
Jun 23 '06 #3
I remember promising to do something about a transparent textbox?
Please let me know if this is OK

Inherits System.Windows. Forms.RichTextB ox' doesn't work with TextBox
Private Const WM_SHOWWINDOW As Long = &H18
Private Const WM_SETFONT As Long = &H30
Public Sub New()
MyBase.New()
SetStyle(Contro lStyles.Support sTransparentBac kColor Or
ControlStyles.U serPaint Or ControlStyles.A llPaintingInWmP aint Or
ControlStyles.D oubleBuffer, True)
End Sub
Protected Overrides Sub WndProc(ByRef m As System.Windows. Forms.Message)
MyBase.WndProc( m)
Select Case m.Msg
Case WM_SHOWWINDOW
Dim msg As Message = Message.Create( Handle, WM_SETFONT, Font.ToHfont(),
IntPtr.Zero)
MyBase.WndProc( msg)
End Select
End Sub
Protected Overrides ReadOnly Property CreateParams() As
System.Windows. Forms.CreatePar ams
Get
Dim cp As CreateParams = MyBase.CreatePa rams
cp.ExStyle = cp.ExStyle Or &H20
Return cp
End Get
End Property
Protected Overrides Sub OnPaint(ByVal e As
System.Windows. Forms.PaintEven tArgs)
If Me.GetStyle(Con trolStyles.User Paint) Then
Me.myInvalidate ()
Me.SetStyle(Con trolStyles.User Paint, False)
End If
End Sub
Jun 23 '06 #4
hi stuart,

thanks so much for the snipped it worked fine.

(there was i think a small typo, in the OnPaint sub, 'Me.myInvalidat e()'
gets flagged down as an error saying that myInvalidate is not a member, i
changed it t 'Me.Invalidate( )', and i think it works fine. i never tinkered
that deep down in controls, so please let me know if this was your
intention, or else please let me how u would fix this.)

thanks again,

ray
Jun 27 '06 #5

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

Similar topics

5
9498
by: Paul Schnitter | last post by:
Update: My custom control is based on the article "Creating Visual Basic .NET controls from scratch" in "Adventures in .NET" on MSDN. It is designed to be a replacement for the VB6 shape control. My control draws a shape (circle, square, rectangle ...)
6
3599
by: Tom | last post by:
why doesn't user control support transparent ? even after you programmatically make it transparent the controls that you add on it still doesn't transparency where they normally would in a winform why is that ? Tom
20
4519
by: Nathan Sokalski | last post by:
I am trying to create graphics with GDI+ that include transparency. However, the transparency never seems to show up, even though my colors have an alpha value of 0. How can I generate a graphic that is completely transparent in certain areas (so that the web page background shows through)? I save my graphics as gif files. I would appreciate, if possible, a simple example so that I can see the code. Thanks. -- Nathan Sokalski...
1
20175
by: Efkas | last post by:
My application have some level : 1. MyButton class with Label inheritance 2. MyComponent as User Control loading and positionning some of MyButtons 3. MyApp loading and positionning MyComponent I prefer don't insert a background in MyComponent, and using the MyApp one as general background with MyComponent positionned, but I am not able to have MyComponent background transparent.
2
6743
by: Simon Tamman {Uchiha Jax} | last post by:
I understand that MS made their controls annoyingly difficult to modify (for example transparency on a listbox, tab control, treeview etc) to ensure they didn't torpedo the third party control library industry (or is this just an excuse to fob us off with controls that are difficult to extend?). Therefore could anyone tell me of a company that offers decent transparent controls?
9
14811
by: SStory | last post by:
I have a picturebox in my About form. would like to have a link to my company website. Wanted the links background to be transparent. It seems that no one knows how to do this. Have asked many times. VB help says that transparent is possible with a background image but not above a control. So how can I provide a link (URL) that is clickable, but transparent, over the picturebox in my about box?
1
1418
by: t perkins | last post by:
would there be a reason why i cannot set the backcolor on lables to be transparent. it is set to be transparent, but it does not work for some reason. any help would be greatly appreciated tony
0
2865
by: MasterOfTheDark | last post by:
This one's a hairy one to explain. What I've got is a class called "VistaGroupBox" that I put some nice-looking Vista-style gradients in the background and made to look like the ribbon categories you see in Office 2007. I got it working great, and created a few more controls, including a "VistaButton", which is primarily transparent when the cursor does not hover over it. However, when I added a standard Panel in the VistaGroupBox and put my...
0
8610
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
8545
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8968
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8810
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8810
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5822
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4562
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2978
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1961
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.