Results 1 to 2 of 2

Thread: Window's Appearance

  1. #1

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111

    Window's Appearance

    I was playing around at 3 a.m. one day, of course exetremely bored. So I poped up the Accessibility Option Magnifier, which has High-Contrast option, I clicked it, don't know if it was the boredum or what... but I thought it looked cool(flat). So I messed around with it, and found there are options you can't change(high-lights/shadows of 3d-objects) I went into VB, again boredum, and I saw Color values for the shadows, etc. I was wondering how I could change these, then possibly make a program to automate the task.

    Thanks,

  2. #2
    Fanatic Member Kaverin's Avatar
    Join Date
    Oct 2000
    Posts
    930
    You can do that with the SetSysColors() API.
    VB Code:
    1. 'in a module
    2. Public Declare Function GetSysColor Lib "user32" Alias "GetSysColor" (ByVal nIndex As Long) As Long
    3. Public Declare Function SetSysColors Lib "user32" Alias "SetSysColors" (ByVal nChanges As Long, lpSysColor As Long, lpColorValues As Long) As Long
    4.  
    5. 'there's a lot of constants  heh heh
    6. 'you could make an enum if you wanted
    7. Public Const COLOR_SCROLLBAR As Long = 0
    8. Public Const COLOR_BACKGROUND As Long = 1
    9. Public Const COLOR_ACTIVECAPTION As Long = 2
    10. Public Const COLOR_INACTIVECAPTION As Long = 3
    11. Public Const COLOR_MENU As Long = 4
    12. Public Const COLOR_WINDOW As Long = 5
    13. Public Const COLOR_WINDOWFRAME As Long = 6
    14. Public Const COLOR_MENUTEXT As Long = 7
    15. Public Const COLOR_WINDOWTEXT As Long = 8
    16. Public Const COLOR_CAPTIONTEXT As Long = 9
    17. Public Const COLOR_ACTIVEBORDER As Long = 10
    18. Public Const COLOR_INACTIVEBORDER As Long = 11
    19. Public Const COLOR_APPWORKSPACE As Long = 12
    20. Public Const COLOR_HIGHLIGHT As Long = 13
    21. Public Const COLOR_HIGHLIGHTTEXT As Long = 14
    22. Public Const COLOR_BTNFACE As Long = 15
    23. Public Const COLOR_BTNSHADOW As Long = 16
    24. Public Const COLOR_GRAYTEXT As Long = 17
    25. Public Const COLOR_BTNTEXT As Long = 18
    26. Public Const COLOR_INACTIVECAPTIONTEXT As Long = 19
    27. Public Const COLOR_BTNHIGHLIGHT As Long = 20
    28. Public Const COLOR_3DDKSHADOW As Long = 21
    29. Public Const COLOR_3DLIGHT As Long = 22
    30. Public Const COLOR_INFOTEXT As Long = 23
    31. Public Const COLOR_INFOBK As Long = 24
    32. Public Const COLOR_HOTLIGHT As Long = 26
    33. Public Const COLOR_GRADIENTACTIVECAPTION As Long = 27  'win98
    34. Public Const COLOR_GRADIENTINACTIVECAPTION As Long = 28  'win98
    35.  
    36. 'to change the active titlebar color to red (just 1 change)
    37. SetSysColors 1, COLOR_ACTIVECAPTION, vbRed
    38.  
    39. 'retrieve the color of the background of a window
    40. Dim lngColor As Long
    41. lngColor = GetSysColor(COLOR_WINDOW)
    42.  
    43. 'this is how you do multiple changes at once
    44. 'add this to a form
    45. Private alngOldColors(0 To 15) As Long
    46. Private alngNewColors(0 To 15) As Long
    47. Private alngSystemColorIndex(0 To 15) As Long
    48.  
    49. Private Sub Form_Load()
    50.    Dim i As Long
    51.    Randomize Timer
    52.    For i = 0 To 15 'change the first 16 system colors
    53.       alngOldColors(i) = GetSysColor(i) 'save the old color
    54.       alngNewColors(i) = QBColor(Int(Rnd * 16)) 'set up a new color
    55.       alngSystemColorIndex(i) = i 'save the index
    56.    Next i
    57.    'apply all the changes, there's a total of 16 to make
    58.    SetSysColors 16, alngSystemColorIndex(0), alngNewColors(0)
    59. End Sub
    60.  
    61. Private Sub Form_Unload(Cancel As Integer)
    62.    'restore the original colors
    63.    SetSysColors 16, alngSystemColorIndex(0), alngOldColors(0)
    64. End Sub
    It will be a system wide change of course, so everything in windows will be affected by the SetSysColors() function.

    There is an existing enum called SystemColorConstants that you could use since they have the same index and ordering of the above constants, but you will have to mask out the upper bit. System colors are identified by having the uppermost bit set, and the index value. Just mask one of the enum constants with &hFF and you can get the index to give to the functions above if you don't want to use the constants here.
    Last edited by Kaverin; Sep 3rd, 2001 at 10:25 PM.
    I'm baaaack...
    VB5 Professional Edition, VC++ 6
    Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se

    I feel special because I finally figured out how to loop midis: Post link
    I'm a fanatic too

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