Re: Transparent textbox
- From: "Mike Williams" <Mike@xxxxxxxxxxxxxxxxx>
- Date: Thu, 11 Aug 2005 23:50:51 +0100
"Laphan" <3232@xxxxxxxxx> wrote in message
news:11fnh25hachdmfb@xxxxxxxxxxxxxxxxxxxxx
> Running VB6 and want a text entry field that has a transparent
> bg. Noticed that this isn't a problem for a label, but text boxes
> seem to have to have a matt bg.
I've just tried all sorts of setting on the hWnd of a TextBox, using various
things including the SetWindowLong API and the various window styles
(including WS_EX_TRANSPARENT) and nothing seems to work reliably.
Personally, I would be inclined to write the "edit this text" stuff myself,
and draw the resultant text directly onto the Form in a transparent manner.
This would require quite a bit of work though.
Alternatively, and perhaps more simply, you could use an "invisible" Text
Box into which the user enters his data and a transparent Label Control to
actually display the data he has entered. You can't actually set the TextBox
Visible property to False, because it would not then respond to user input,
but you can achieve the same "invisible" effect by positioning it off the
display.
The following is just some simple test bed code, and you will need to add
some more code to display the flashing cursor and to allow the user to
"click into" the edit field in a way that shows him where he has clicked
(which should be reasonably easy but which, as is often the case, might
present some problems that I haven't yet thought of!). Paste the following
code into a VB Form containing one text box and one label control. Set the
picture property of the Form to whatever picture you want. Run the program
and start typing. Obviously there is more work yet to be done, but this
should give you a start.
Okay, I must admit that I'm a little bit drunk at the moment (Lambs rum and
Coke®) so this stuff might not work as you expect it to, but having said
that I have to say that I often write my best code when I am drunk! Before I
retired I was a taxi driver (sob, sob, how many times have I said that in
this newsgroup!), and my "drunken moments in the early hours of the morning"
often produced some of my best stuff! Okay, it is not exactly the "early
hours of the morning" here at the moment, but it certainly feels like it!
Mike
Oops. Neary forgot the code. Here it is . . .
(Don't you just love this ability to check and amend your post before you
actually post it! You wouldn't believe how many spelling mistakes and
"typos" I found!).
Private Sub Form_Load()
Me.Show
Text1.Font.Name = "Times new Roman"
Text1.Font.Bold = True
Text1.Font.Size = 18
Text1.Text = ""
Label1.BackStyle = 0 ' transparent
Label1.Font.Name = Text1.Font.Name
Label1.Font.Size = Text1.Font.Size
Label1.Font.Bold = Text1.Font.Bold
Label1.Caption = Text1.Text
Text1.SetFocus
Text1.Left = -Text1.Width
Label1.ForeColor = vbCyan
End Sub
Private Sub Text1_Change()
Label1.Caption = Text1.Text
End Sub
.
- Follow-Ups:
- Re: Transparent textbox
- From: Frank Adam
- Re: Transparent textbox
- Prev by Date: Re: Compiling Visual Basic - every time different?
- Next by Date: Re: Compiling Visual Basic - every time different?
- Previous by thread: Converting a Favorites URL to http://.......
- Next by thread: Re: Transparent textbox
- Index(es):
Relevant Pages
|