Active Title Bar (1 Viewer)

MikeAngelastro

Registered User.
Local time
Today, 16:11
Joined
Mar 3, 2000
Messages
254
Does anyone know how I can change the color of the form's title bar using Access VBA?
 
R

Rich

Guest
Windows controls the forms title bar colours. You therefore need an API function. I'm sure there have been examples posted here.
 

MikeAngelastro

Registered User.
Local time
Today, 16:11
Joined
Mar 3, 2000
Messages
254
Thanks Rich.

But I did a search before I wrote the post and found nothing that dealt with the form's title bar. I did another search and mine was the only post that appeared. Is there possibly another place to find this?

Mike
 

spacepro

Registered User.
Local time
Today, 23:11
Joined
Jan 13, 2003
Messages
715
Don't even know if this will work but I found this code on the internet by doing a search through Google. Anyway here it is:

Code:
You can globally change any Windows 95 desktop colour using the 
SetSysColors function. It takes three parameters : The number 
of colour elements to change, The Color object constant that 
you want to change and the RGB value.

The Declaration for this API function is:

Declare Function SetSysColors Lib "user32" Alias _
"SetSysColors" (ByVal nChanges As Long, lpSysColor As _
Long, lpColorValues As Long) As Long 

The Constants are:

Public Const COLOR_SCROLLBAR = 0 'The Scrollbar colour 
Public Const COLOR_BACKGROUND = 1 'Colour of the background with no wallpaper 
Public Const COLOR_ACTIVECAPTION = 2 'Caption of Active Window 
Public Const COLOR_INACTIVECAPTION = 3 'Caption of Inactive window 
Public Const COLOR_MENU = 4 'Menu 
Public Const COLOR_WINDOW = 5 'Windows background 
Public Const COLOR_WINDOWFRAME = 6 'Window frame 
Public Const COLOR_MENUTEXT = 7 'Window Text 
Public Const COLOR_WINDOWTEXT = 8 '3D dark shadow (Win95) 
Public Const COLOR_CAPTIONTEXT = 9 'Text in window caption 
Public Const COLOR_ACTIVEBORDER = 10 'Border of active window 
Public Const COLOR_INACTIVEBORDER = 11 'Border of inactive window 
Public Const COLOR_APPWORKSPACE = 12 'Background of MDI desktop 
Public Const COLOR_HIGHLIGHT = 13 'Selected item background 
Public Const COLOR_HIGHLIGHTTEXT = 14 'Selected menu item 
Public Const COLOR_BTNFACE = 15 'Button 
Public Const COLOR_BTNSHADOW = 16 '3D shading of button 
Public Const COLOR_GRAYTEXT = 17 'Grey text, of zero if dithering is used. 
Public Const COLOR_BTNTEXT = 18 'Button text 
Public Const COLOR_INACTIVECAPTIONTEXT = 19 'Text of inactive window 
Public Const COLOR_BTNHIGHLIGHT = 20 '3D highlight of button 


To change the colour of the title bar, or caption, of an active 
window, you would call the function in this way:

t& = SetSysColors(1, COLOR_ACTIVECAPTION, RGB(255,0,0)) 

This example would turn the active caption red

Hope this helps

Andy
 

MikeAngelastro

Registered User.
Local time
Today, 16:11
Joined
Mar 3, 2000
Messages
254
Hi,

I want to thank all of you for your help in this.

I used the code provided by spacepro and it works very well. We have an Access based accounting application and it handles any company selected by the user. We wanted to use different color schemes to ensure that the user knows instinctively which company he's working with. But the pesky title bar was always the same color. So now the program uses a color scheme for each company and it includes the active title bar.

However, reverting to the original system colors when exiting the app can be problematic. If your application is complex, the main form tends to vibrate for a few seconds before the application shuts down. On simpler apps shutdown appears smooth. Because we are using ours with Terminal Services, the original system colors are unimportant, so I disabled this part. It works quite well otherwise.

I have a sample mdb that illustrates this in a very simple way including reverting to the original system colors when exiting. If anyone would like one, I can email one to you. If the forum had a place for sample mdbs, I could upload it. But I don't think that the forum has implemented a dedicated sample app/code feature. Am I wrong? If not, this would be a handy feature.

Anyway, thanks again. I hope this is useful.

Mike
 

spacepro

Registered User.
Local time
Today, 23:11
Joined
Jan 13, 2003
Messages
715
Hi Mike,

Glad to see that it works.

Your suggestion has been said in the Suggestions forum many a time, hopefully one day this will happen. It's probably a space and bandwdith issue with the owner.

If you would be so kind please forward a sample db to spaceprogram@tiscali.co.uk

Many Thanks

Andy
 

ghudson

Registered User.
Local time
Today, 18:11
Joined
Jun 8, 2002
Messages
6,194
MikeAngelastro,

You could post your sample db to this thread. That way your sample can be found by anybody who searches and discovers this thread.

I would like to see your sample in an Access 97 version. Thanks!
 

MikeAngelastro

Registered User.
Local time
Today, 16:11
Joined
Mar 3, 2000
Messages
254
Here the sample DB in Access 2002 format as a zip. I will add an Access 97 version with my next post.
 

Attachments

  • api for system colors.zip
    14.7 KB · Views: 257

MikeAngelastro

Registered User.
Local time
Today, 16:11
Joined
Mar 3, 2000
Messages
254
Here is the Access 97 version.
 

Attachments

  • api for system colors 97.zip
    17.3 KB · Views: 174

Users who are viewing this thread

Top Bottom