Results 1 to 7 of 7

Thread: Colouring Bars

  1. #1

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Colouring Bars

    ok Robert it is in detail

    I have seen in various applications that Scroll bars are of different fascinating colours and of attractive styles as well.

    what i want to ask is that how can we change colour of VB6 horizontal/vertical scroll bars .

    Bundle of Thx.

  2. #2
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011

    Re: Colouring Bars

    Quote Originally Posted by vbPoet
    ok Robert it is in detail

    I have seen in various applications that Scroll bars are of different fascinating colours and of attractive styles as well.

    what i want to ask is that how can we change colour of VB6 horizontal/vertical scroll bars .

    Bundle of Thx.
    I have seen this long ago

    VB Code:
    1. 'In a form
    2.  
    3. Option Explicit
    4.  
    5. Private Sub Form_Load()
    6.     Call Hook(Me.hWnd)
    7. End Sub
    8. Private Sub Form_Unload(Cancel As Integer)
    9.     Call Unhook(Me.hWnd)
    10. End Sub
    11.  
    12.  
    13.  
    14. 'In a standard module
    15. Option Explicit
    16.  
    17. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, _
    18.                                                                             ByVal nIndex As Long, _
    19.                                                                             ByVal dwNewLong As Long) _
    20.                                                                             As Long
    21. Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, _
    22.                                                                               ByVal hWnd As Long, _
    23.                                                                               ByVal Msg As Long, _
    24.                                                                               ByVal wParam As Long, _
    25.                                                                               ByVal lParam As Long) _
    26.                                                                               As Long
    27. Private Declare Function DefWindowProc Lib "user32" Alias "DefWindowProcA" (ByVal hWnd As Long, _
    28.                                                                             ByVal wMsg As Long, _
    29.                                                                             ByVal wParam As Long, _
    30.                                                                             ByVal lParam As Long) _
    31.                                                                             As Long
    32. Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
    33. Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    34.  
    35. Private Const GWL_WNDPROC = (-4)
    36. Private Const WM_CTLCOLORSCROLLBAR = &H137
    37.  
    38. Private mPrevProc As Long
    39.  
    40. Public Sub Hook(hWnd As Long)
    41.     mPrevProc = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WndProc)
    42. End Sub
    43.  
    44. Public Sub Unhook(hWnd As Long)
    45.  
    46.     Call SetWindowLong(hWnd, GWL_WNDPROC, mPrevProc)
    47.     mPrevProc = 0&
    48.  
    49. End Sub
    50.  
    51. Public Function WndProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    52. On Error Resume Next
    53.  
    54. Static hBrush As Long
    55.  
    56.     If uMsg = WM_CTLCOLORSCROLLBAR Then
    57.         If hBrush = 0 Then hBrush = CreateSolidBrush(vbRed) 'For a red background
    58.        
    59.         WndProc = hBrush
    60.         Exit Function
    61.     End If
    62.  
    63.     'Call DeleteObject(hBrush)
    64.  
    65.     If mPrevProc Then
    66.         WndProc = CallWindowProc(mPrevProc, hWnd, uMsg, wParam, lParam)
    67.     Else
    68.         WndProc = DefWindowProc(hWnd, uMsg, wParam, lParam)
    69.     End If
    70.  
    71. End Function

  3. #3

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Re: Colouring Bars

    it helped...
    and further i will try it get required results

    but as u have written in your signature don't say thanks so i won't
    but tell me How To RATE u ....

  4. #4
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011

    Re: Colouring Bars

    Quote Originally Posted by vbPoet
    it helped...
    and further i will try it get required results

    but as u have written in your signature don't say thanks so i won't
    but tell me How To RATE u ....
    Hey man... under my avatar... Click on Rate this post

    well. i think it should be how we rate ppl...

  5. #5

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Re: Colouring Bars

    O guy
    it is not working as xpected ...
    becuase i just wanted to colour scroll bar as red or yellow ...!!

  6. #6
    Member
    Join Date
    Mar 2009
    Posts
    53

    Re: Colouring Bars

    hi guys, its working fine for me. but i need a small change in this. i just want to change the button color of scrollbar as scrollbar back color. is it possibile?

  7. #7
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Colouring Bars

    This is an old thread.... ie. about 5 years old....

    Create your own thread...

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

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