Results 1 to 13 of 13

Thread: Transparent Listbox

  1. #1

    Thread Starter
    Addicted Member bbosh's Avatar
    Join Date
    Oct 2000
    Location
    Hell (AKA New Mexico)
    Posts
    186
    How would I make a transparent list box?
    Brian
    Programming: VB5 Pro (SP3) - QBasic 1.1,4.5
    Internet: HTML 4, CSS, JavaScript
    Visit AltInt.com!

  2. #2
    Guest
    Try this:

    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 MakeListTransparent(ListCtl As Object) As Boolean
    
        On Error Resume Next
        ListCtl.BackColor = ListCtl.Parent.BackColor
        SetWindowLong ListCtl.hwnd, GWL_EXSTYLE, WS_EX_TRANSPARENT
        MakeListTransparent = Err.LastDllError = 0
    
    End Function
    
    
    Usage
    
    
    MakeListTransparent List1

  3. #3
    Guest
    If you wish to make the Scrollbars hidden, use the ShowScrollBar API function.


    Code:
    Private Declare Function ShowScrollBar Lib "user32" _ 
    (ByVal hwnd As Long, ByVal wBar As Long, _ 
    ByVal bShow As Long) As Long 
    
    Private Const SB_BOTH = 3 
    Private Const SB_HORZ = 0 
    Private Const SB_VERT = 1 
    
    
    Private Sub List1_Scroll()
    ShowScrollBar List1.hwnd, 1, False
    End Sub

  4. #4

    Thread Starter
    Addicted Member bbosh's Avatar
    Join Date
    Oct 2000
    Location
    Hell (AKA New Mexico)
    Posts
    186
    It doesn't seem to work. The procedure removes the border but it keeps the bg color of the form, and doesn't allow the image to shine through. I removed Resume Next from the procedure, and there are no errors, and it just isn't working.
    Brian
    Programming: VB5 Pro (SP3) - QBasic 1.1,4.5
    Internet: HTML 4, CSS, JavaScript
    Visit AltInt.com!

  5. #5

    Thread Starter
    Addicted Member bbosh's Avatar
    Join Date
    Oct 2000
    Location
    Hell (AKA New Mexico)
    Posts
    186
    What shhould the function be returning? It shows false
    Brian
    Programming: VB5 Pro (SP3) - QBasic 1.1,4.5
    Internet: HTML 4, CSS, JavaScript
    Visit AltInt.com!

  6. #6

    Thread Starter
    Addicted Member bbosh's Avatar
    Join Date
    Oct 2000
    Location
    Hell (AKA New Mexico)
    Posts
    186
    Specifically, what's going on:
    Turns off border
    Makes area of list not inhabited invisible
    Every row containing data stays opaque

    Therefore,
    It seems very strange.
    Brian
    Programming: VB5 Pro (SP3) - QBasic 1.1,4.5
    Internet: HTML 4, CSS, JavaScript
    Visit AltInt.com!

  7. #7
    Guest
    What version of VB are you using? Lower version, it seems to make the Listbox grey. VB6 - transparent.

  8. #8

    Thread Starter
    Addicted Member bbosh's Avatar
    Join Date
    Oct 2000
    Location
    Hell (AKA New Mexico)
    Posts
    186
    im using v5 pro
    Brian
    Programming: VB5 Pro (SP3) - QBasic 1.1,4.5
    Internet: HTML 4, CSS, JavaScript
    Visit AltInt.com!

  9. #9
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    Same result for me, Matthew, and I'm using VB6 Ent.

  10. #10
    Guest
    Not sure if it'll help, but attached is an example of what I'm trying to show you (look at the executable file).
    Attached Files Attached Files

  11. #11

    Thread Starter
    Addicted Member bbosh's Avatar
    Join Date
    Oct 2000
    Location
    Hell (AKA New Mexico)
    Posts
    186
    I'n not sure what the exe does, but the project behaves exactly the same as the code you gave me. When I commented out the lstControl.BackColor line, the only effect was the removal of the border. Perhaps I haven't been completely clear: I have an image in the BG, which I want to show through the listbox, not just a solid color.
    Brian
    Programming: VB5 Pro (SP3) - QBasic 1.1,4.5
    Internet: HTML 4, CSS, JavaScript
    Visit AltInt.com!

  12. #12
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    One way to do this, is to keep the listbox invisible and each time wen the TopIndex changes, you have to redraw a picturebox (or something that holds the background image) using the Print statement (or TextOut API). This is also fast, so I think this would work just fine.

  13. #13
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    Oops, what am I saying! I mean each time the vertical scroll bar next to the picturebox changes...

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