How to change the colour of title bar? (1 Viewer)

Voyager

Registered User.
Local time
Today, 17:01
Joined
Sep 7, 2017
Messages
95
Hello experts,
Could you assist me in changing the colour of title bar. There were certain suggestions asking me to change the theme settings of windows but I want only to change the colour of me access form. Is there a way? I browsed but did not find a solution I am in need of. Could you assist I feel there should be a code for it.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 06:31
Joined
Feb 28, 2001
Messages
27,179
There is, but it is based on the theme, which is what those suggestions were all about.

You have to understand that Access doesn't draw windows. It only fills in windows. Windows draws (empty) windows and leaves the rest to you. But that means you have no ability to reset title bar colors from Access-based windows unless you somehow find the Windows theme that governs creation of ALL windows - including those used by Excel, Word, Windows Explorer (when windowed), and your favorite windowed game.

I looked for this, trying to find the things you could reveal with something if you know its hwnd (window handle), but I'm apparently not asking the right questions either. I don't see anything in my References library that looks right for the structures you need because they are owned by SYSTEM and might not be in a public library. I actually DID find a System library but what was in it didn't seem relevant to window drawing.

I also have a 5-volume set of the Win32 API books but that didn't seem to help much either. They have a few windows structures but always talk about how the colors MUST be chosen from the current Windows theme. If you could find the structure that defines themes, you can change its color - but in so doing, you will change the color of EVERY window currently open on your desktop. AND given Windows security, if you had a Win10 version, you might have an alert from Windows Defender complaining about how a program was attempting to alter system configuration data. Definitely not a good thing.

I think you are stuck with the "Windows Theme" answer for now, unless someone else has researched this from a different direction and stumbled across a solution.
 

Voyager

Registered User.
Local time
Today, 17:01
Joined
Sep 7, 2017
Messages
95
Docman, Thank you very much for taking time to address my issue. Then I have to do an extensive research to get my answer.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:31
Joined
Oct 29, 2018
Messages
21,471
Docman, Thank you very much for taking time to address my issue. Then I have to do an extensive research to get my answer.
And please don't forget to give us an update to whatever you find: good or bad. Good luck!
 

Voyager

Registered User.
Local time
Today, 17:01
Joined
Sep 7, 2017
Messages
95
And please don't forget to give us an update to whatever you find: good or bad. Good luck!



Sure. I will if I can especially for the lot you have helped me out. [emoji3]


Sent from my iPhone using Tapatalk
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 06:31
Joined
Feb 28, 2001
Messages
27,179
I can only wish you good luck and suggest that with a LOT of search of MSDN, you might find some answers there, but I'm afraid they will adhere to the "party line" that apps don't draw windows, Windows draws windows. If you succeed, the good news is that the hwnd property of a given form will lead you to the window handle of the window in which that form resides. If you are going to do anything at all, it will start with the window handle.

Beyond that, it is a nightmare of links to get to anything related to the actual window and its properties. However, may I make a small request? If you actually DO find a solution, post at least some hints by coming back and marking this thread closed. Tell us what you found.

And as another suggestion, leave this thread open because it is entirely possible that some other member of the forum faced this once and found a solution that I haven't found yet. Perhaps because they came from a different direction. As you well know, if you don't know what question to ask, you might not get the answer you want, and that is where I find myself at the moment.
 

Voyager

Registered User.
Local time
Today, 17:01
Joined
Sep 7, 2017
Messages
95
Hi experts,
Thanks for your time and valuable suggestions. I was able to use the code given in this link
https://wellsr.com/vba/2017/excel/remove-window-border-title-bar-around-userform-vba/

with some minor tweaks it’s successful. All I did was

1. I have placed first two codes in a standard module.
2. Third code in form load event
And got the result I wanted.

Doc man, dbguy, isladogs this is what I can do for the forum with my knowledge. Hope I did an attempt.

'PLACE IN A STANDARD MODULE

Code:
Option Explicit
Option Private Module

Public Const GWL_STYLE = -16
Public Const WS_CAPTION = &HC00000

    Public Declare PtrSafe Function GetWindowLong _
                           Lib "user32" Alias "GetWindowLongA" ( _
                           ByVal hWnd As Long, _
                           ByVal nIndex As Long) As Long
    Public Declare PtrSafe Function SetWindowLong _
                           Lib "user32" Alias "SetWindowLongA" ( _
                           ByVal hWnd As Long, _
                           ByVal nIndex As Long, _
                           ByVal dwNewLong As Long) As Long
    Public Declare PtrSafe Function DrawMenuBar _
                           Lib "user32" ( _
                           ByVal hWnd As Long) As Long
    Public Declare PtrSafe Function FindWindowA _
                           Lib "user32" (ByVal lpClassName As String, _
                           ByVal lpWindowName As String) As Long


Code:
Sub HideTitleBar(frm As Object)
    Dim lngWindow As Long
    Dim lFrmHdl As Long
    lFrmHdl = FindWindowA(vbNullString, frm.Caption)
    lngWindow = GetWindowLong(lFrmHdl, GWL_STYLE)
    lngWindow = lngWindow And (Not WS_CAPTION)
    Call SetWindowLong(lFrmHdl, GWL_STYLE, lngWindow)
    Call DrawMenuBar(lFrmHdl)
End Sub

Code:
Option Explicit 
Private sub Form_load()
MODULENAME.HideTitleBar
Docmd.Maximize
End sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:31
Joined
Oct 29, 2018
Messages
21,471
Hi experts,
Thanks for your time and valuable suggestions. I was able to use the code given in this link
https://wellsr.com/vba/2017/excel/remove-window-border-title-bar-around-userform-vba/

with some minor tweaks it’s successful. All I did was

1. I have placed first two codes in a standard module.
2. Third code in form load event
And got the result I wanted.

Doc man, dbguy, isladogs this is what I can do for the forum with my knowledge. Hope I did an attempt.
Hi. Thanks for coming back and letting us know what you found and able to do. But just to clarify, will this code change the color of the title bar or just hide it? If to change to a different color, where does it say which color you're changing it to? Thanks again.
 

isladogs

MVP / VIP
Local time
Today, 12:31
Joined
Jan 14, 2017
Messages
18,219
Thank you for your contribution.
Unfortunately it doesn't do anything. Sorry.

First of all, if you maximise a form, you will not have a title bar anyway. Secondly you need to change your code to reference the current form

Code:
Private Sub Form_Load()

HideTitleBar Me 'added Me to reference current form
'DoCmd.Maximize 'disabled

End Sub

If you do this using overlapping windows setting, you will see it has no effect.

To remove the title bar, just make a borderless form.
In design view, change the border style to None.

The module code isn't needed and seems to have no effect anyway

EDIT
In case it helps, have a look at the borderless form in this example http://www.mendipdatasystems.co.uk/control-application-interface/4594365418
I've taken it a stage further and removed the entire application window as well...but that's not a requirement of this type of form
 
Last edited:

Voyager

Registered User.
Local time
Today, 17:01
Joined
Sep 7, 2017
Messages
95
I am sorry. I didn’t explain the story well in my earlier post. This is what I did.
1) Understanding that changing the colour of the title bar will become an unwanted work if I want to trigger some events while minimising or maximising the form I have decided to do a work around.
2) That’s is getting rid of the task bar itself. So I used the procedure from the earlier post to get the result.
3) Then I have applied the colour I wished to the header of the form.
4) When I maximised the form I got exactly what I want.
5) If I want to to maximise or minimise or close I will create buttons for it.
6) I have kept from border style to thin. Pop up and nodal to yes. Not to worry about Control box, max, min buttons and close button, code will take care of it.
Hope I am able to more clearer now.
 

Voyager

Registered User.
Local time
Today, 17:01
Joined
Sep 7, 2017
Messages
95
I see what you are saying. What a foolish thing I was trying to do. This is simple answer.
What you said works for me if I open the form in Maximize mode with border property chosen to None.
Thank you.


Sent from my iPhone using Tapatalk
 

isladogs

MVP / VIP
Local time
Today, 12:31
Joined
Jan 14, 2017
Messages
18,219
That is indeed clearer but my previous comments still apply.
The code you supplied does not remove the title bar.

EDIT Posts crossed.

There is usually a simple solution :cool:
 

Voyager

Registered User.
Local time
Today, 17:01
Joined
Sep 7, 2017
Messages
95
I acknowledge it.


Sent from my iPhone using Tapatalk
 

isladogs

MVP / VIP
Local time
Today, 12:31
Joined
Jan 14, 2017
Messages
18,219
No worries - the main thing is that you have a solution that you are happy with :)
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:31
Joined
Oct 29, 2018
Messages
21,471
I am sorry. I didn’t explain the story well in my earlier post. This is what I did.
1) Understanding that changing the colour of the title bar will become an unwanted work if I want to trigger some events while minimising or maximising the form I have decided to do a work around.
2) That’s is getting rid of the task bar itself. So I used the procedure from the earlier post to get the result.
3) Then I have applied the colour I wished to the header of the form.
4) When I maximised the form I got exactly what I want.
5) If I want to to maximise or minimise or close I will create buttons for it.
6) I have kept from border style to thin. Pop up and nodal to yes. Not to worry about Control box, max, min buttons and close button, code will take care of it.
Hope I am able to more clearer now.
Thanks for the clarification!
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 06:31
Joined
Feb 28, 2001
Messages
27,179
Of course, this approach works and is a prime example of an old engineering axiom: If you can't fix the problem, CHANGE the problem and see if you can fix the result. I was trying to find a way to color the title bar, but making it a no-border window and putting a label at the top of the form has a similar visual effect, which is all that you really wanted.

Thanks for proving yet again that there are more than just a couple of ways to skin a rabbit.
 

ramonmiro

New member
Local time
Today, 12:31
Joined
Sep 19, 2012
Messages
3
Hello experts,
Could you assist me in changing the colour of title bar. There were certain suggestions asking me to change the theme settings of windows but I want only to change the colour of me access form. Is there a way? I browsed but did not find a solution I am in need of. Could you assist I feel there should be a code for it.
Hello experts,
Could you assist me in changing the colour of title bar. There were certain suggestions asking me to change the theme settings of windows but I want only to change the colour of me access form. Is there a way? I browsed but did not find a solution I am in need of. Could you assist I feel there should be a code for it.
Go to File / Options
Under General go to "Prersonalize your copy of Microsoft office"
Here you can customnize the Office backgound and the Office Theme
Hope it helps
 

Users who are viewing this thread

Top Bottom