Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing the Application Background Color with Code 1

Status
Not open for further replies.

helpplz

Technical User
Nov 10, 2002
6
US
I would like to change the MS Access Application background color to fit into my color scheme of my forms and other object. I know the application background color can be changed under 'Start - Settings - Control Panel - Display', but I do not want my users manually making the color change. I would like run a module in access on open that will change the application background color. I have looked all over the net and cannot find code to do this. Can it be done and if so how?

Thank you in advance for your time and knowledge.
 
You'll have to use the API, but remember when you set this color you change it for the OS not just for Access. That said, here's the code - no charge:

Code:
'Public Declarations
'********************
'     SYSTEM COLOR CONSTANTS
'********************
Public Const COLOR_SCROLLBAR = 0
Public Const COLOR_BACKGROUND = 1
Public Const COLOR_ACTIVECAPTION = 2
Public Const COLOR_INACTIVECAPTION = 3
Public Const COLOR_MENU = 4
Public Const COLOR_WINDOW = 5
Public Const COLOR_WINDOWFRAME = 6
Public Const COLOR_MENUTEXT = 7
Public Const COLOR_WINDOWTEXT = 8
Public Const COLOR_CAPTIONTEXT = 9
Public Const COLOR_ACTIVEBORDER = 10
Public Const COLOR_INACTIVEBORDER = 11
Public Const COLOR_APPWORKSPACE = 12
Public Const COLOR_HIGHLIGHT = 13
Public Const COLOR_HIGHLIGHTTEXT = 14
Public Const COLOR_BTNFACE = 15
Public Const COLOR_BTNSHADOW = 16
Public Const COLOR_GRAYTEXT = 17
Public Const COLOR_BTNTEXT = 18
Public Const COLOR_INACTIVECAPTIONTEXT = 19
Public Const COLOR_BTNHIGHLIGHT = 20

' global variable to hold original color
Public glAppBackGroundOrig As Long

'********************
'     API Functions
'********************
Public Declare Function SetSysColors Lib "user32" (ByVal nChanges As Long, _
                    lpSysColor As Long, lpColorValues As Long) As Long
    
Public Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long

'@-------------------- Changing colors --------------------@

  Dim lngRet As Long

  ' Before changing color, get existing color:
  glAppBackGroundOrig = GetSysColor(COLOR_APPWORKSPACE)


  'Set the new color:

  ' Following line changes app background to 3D button face color...
  lngRet = SetSysColors(1, COLOR_APPWORKSPACE, GetSysColor(COLOR_BTNFACE))


'@-------------------- Restoring Color --------------------@

  lngRet = SetSysColors(1, COLOR_APPWORKSPACE, glAppBackGroundOrig)

VBSlammer
redinvader3walking.gif

Unemployed in Houston, Texas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top