Results 1 to 5 of 5

Thread: List boxes

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2001
    Posts
    5
    Is it possible to change the border colour of a listbox in any way? Through the API or not?
    «davidc»

  2. #2
    Addicted Member Babbalouie's Avatar
    Join Date
    Jan 2001
    Location
    On the bright, blue sea...
    Posts
    197
    I've got code that will change the border style, but not the colour, if you want it...
    Building A Better Body Albeit Left Out Under Intense Extrapolation

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2001
    Posts
    5
    OK sure please!! Its a good start isn't it!

    Thanks in advance (although I'd still like to hear from anyone with colour code!)

    «davidc»
    «davidc»

  4. #4
    Addicted Member Babbalouie's Avatar
    Join Date
    Jan 2001
    Location
    On the bright, blue sea...
    Posts
    197
    BAS Module Code

    Code:
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal CX As Long, ByVal CY As Long, ByVal wFlags As Long) As Long
    Private Const GWL_EXSTYLE = (-20)
    Private Const WS_EX_CLIENTEDGE = &H200
    Private Const WS_EX_STATICEDGE = &H20000
    Private Const SWP_FRAMECHANGED = &H20
    Private Const SWP_NOMOVE = &H2
    Private Const SWP_NOOWNERZORDER = &H200
    Private Const SWP_NOSIZE = &H1
    Private Const SWP_NOZORDER = &H4
    
    Public Function AddOfficeBorder(ByVal hwnd As Long)
        
    Dim lngRetVal As Long
        
        'Retrieve the current border style
        lngRetVal = GetWindowLong(hwnd, GWL_EXSTYLE)
        
        'Calculate border style to use
        lngRetVal = lngRetVal Or WS_EX_STATICEDGE And Not WS_EX_CLIENTEDGE
        
        'Apply the changes
        SetWindowLong hwnd, GWL_EXSTYLE, lngRetVal
        SetWindowPos hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOOWNERZORDER Or SWP_NOZORDER Or SWP_FRAMECHANGED
        
    End Function
    Building A Better Body Albeit Left Out Under Intense Extrapolation

  5. #5
    Addicted Member Babbalouie's Avatar
    Join Date
    Jan 2001
    Location
    On the bright, blue sea...
    Posts
    197
    Oops...

    To use:

    AddOfficeBorder YourControl.hWnd
    Building A Better Body Albeit Left Out Under Intense Extrapolation

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