Results 1 to 6 of 6

Thread: Textbox with Transparent Background

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    35
    I am wanting to display a logo on a form (no problem). I also want that logo to be visible the entire time the form is visible. The problem occurs when I have a text box over the logo.

    How can I remove the background of the text box and retain the text and the scroll bars?

  2. #2
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Sydney Australia
    Posts
    804
    'Code from Matthew Gates
    Code:
    Private Const WS_EX_TRANSPARENT = &H20&
    Private Const GWL_EXSTYLE = (-20)
    
    Private Declare Function SetWindowLong Lib "user32" _
      Alias "SetWindowLongA" (ByVal hwnd As Long, _
      ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    
    
    Private Function MakeTextboxTransparent(TxtCtl As Object) As Boolean
    
    On Error Resume Next
    TxtCtl.BackColor = TxtCtl.Parent.BackColor
    SetWindowLong TxtCtl.hwnd, GWL_EXSTYLE, WS_EX_TRANSPARENT
    MakeTextboxTransparent = Err.LastDllError = 0
    
    End Function
    
    
    Private Sub Form_Paint()
        Text1.Appearance = 0
        Text1.BorderStyle = 0
        MakeTextboxTransparent Text1
    End Sub

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    35
    I've seen this code before. I just tried it again and it does not work. The textbox back color changes to the frm's back color and thats an easy one.

  4. #4
    gaffa
    Guest
    JamesM,

    That code makes the textbox transparent, but the back colour of the text box becomes the back colour of the from, not the picture on the form

    - gaffa

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    35
    Not really. The line 'TxtCtl.BackColor = TxtCtl.Parent.BackColor' does the coloring. If you rem this line out and leave the textbox back color white; when the project is ran the textbox back color is still white not the color of the form.

  6. #6
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Sydney Australia
    Posts
    804
    I see, doesn't create true transparency. That is a problem then isn't it...

    You can't change the background colout of the textbox to match the picture?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width