Is it possible to change the background colour of the title in a vba user
form (the one that defaults to UserForm1 when you create a new userform)? I
know how to change the colours of the form itself and of any text boxes etc.
placed on the form but not the title.

thanks,

Re: change colour in title of userform by Doug

Doug
Fri Sep 14 03:23:37 CDT 2007

That is a Windows setting that can be changed by right clicking on the
desktop and selecting properties and then going to the Appearance tab. Any
change that you make there however will apply to all dialog boxes, etc.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Jules" <Jules@discussions.microsoft.com> wrote in message
news:93724BE4-6AD8-437B-BFC0-FFD660A0A500@microsoft.com...
> Is it possible to change the background colour of the title in a vba user
> form (the one that defaults to UserForm1 when you create a new userform)?
> I
> know how to change the colours of the form itself and of any text boxes
> etc.
> placed on the form but not the title.
>
> thanks,
>



Re: change colour in title of userform by Jules

Jules
Sun Sep 16 18:06:00 CDT 2007

Thank you. Not sure if I want to change if for all dlg boxes, but thanks.

"Doug Robbins - Word MVP" wrote:

> That is a Windows setting that can be changed by right clicking on the
> desktop and selecting properties and then going to the Appearance tab. Any
> change that you make there however will apply to all dialog boxes, etc.
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>
> "Jules" <Jules@discussions.microsoft.com> wrote in message
> news:93724BE4-6AD8-437B-BFC0-FFD660A0A500@microsoft.com...
> > Is it possible to change the background colour of the title in a vba user
> > form (the one that defaults to UserForm1 when you create a new userform)?
> > I
> > know how to change the colours of the form itself and of any text boxes
> > etc.
> > placed on the form but not the title.
> >
> > thanks,
> >
>
>
>

Re: change colour in title of userform by Karl

Karl
Tue Sep 18 15:04:08 CDT 2007

Jules <Jules@discussions.microsoft.com> wrote:
> Thank you. Not sure if I want to change if for all dlg boxes, but thanks.

What you're asking for is often referred to as 'skinning' and generally discouraged
for a variety of very good reasons. If stubborness gets the best of you, perhaps
you'll find some ideas here:

http://www.google.com/search?q=skinning+vba+userform
--
.NET: It's About Trust!
http://vfred.mvps.org



Re: change colour in title of userform by Russ

Russ
Tue Sep 18 23:58:23 CDT 2007

Jules,
I played around with this code in a userform to change the titlebar color of
the form. As long as you show a userform in its default modal mode (meaning
no other windows can be selected) and you set the default color values back
before hiding or unloading the form, you might find this code useful.

Paste this part in the (Declarations) section of the test userform code:
----------------------------------------
Option Explicit
Private Declare Function GetSysColor Lib "user32.dll" ( _
ByVal nIndex As Long) As Long
Private Declare Function SetSysColors Lib "user32.dll" ( _
ByVal nChanges As Long, _
ByRef lpSysColor As Long, _
ByRef lpColorValues As Long) As Long
Const COLOR_ACTIVECAPTION As Long = 2
Const COLOR_GRADIENTACTIVECAPTION As Long = 27
Const COLOR_CAPTIONTEXT As Long = 9
Dim myCOLOR_CAPTIONTEXT As Long, myCOLOR_ACTIVECAPTION As Long
Dim myCOLOR_GRADIENTACTIVECAPTION As Long
-----------------------------------------
Paste this in main userform module after creating two command buttons on the
test userform:
-----------------------------------------

Private Sub CommandButton1_Click()
Dim lngReturn As Long
myCOLOR_CAPTIONTEXT = GetSysColor(COLOR_CAPTIONTEXT)
myCOLOR_ACTIVECAPTION = GetSysColor(COLOR_ACTIVECAPTION)
myCOLOR_GRADIENTACTIVECAPTION = GetSysColor(COLOR_GRADIENTACTIVECAPTION)

lngReturn = SetSysColors(1, COLOR_CAPTIONTEXT, &HC0FFC0) 'Hex values for
the primary colors
lngReturn = SetSysColors(1, COLOR_ACTIVECAPTION, vbWhite)
lngReturn = SetSysColors(1, COLOR_GRADIENTACTIVECAPTION, vbRed)
End Sub

Private Sub CommandButton2_Click()
Dim lngReturn As Long

lngReturn = SetSysColors(1, COLOR_CAPTIONTEXT, myCOLOR_CAPTIONTEXT)
lngReturn = SetSysColors(1, COLOR_ACTIVECAPTION, myCOLOR_ACTIVECAPTION)
lngReturn = SetSysColors(1, COLOR_GRADIENTACTIVECAPTION,
myCOLOR_GRADIENTACTIVECAPTION)
End Sub
-----------------------------------------

This presupposes that your title bars have a gradient fill (mixing two
colors). There is a way to check for that using another API call, but I
didn't go that far.


> Thank you. Not sure if I want to change if for all dlg boxes, but thanks.
>
> "Doug Robbins - Word MVP" wrote:
>
>> That is a Windows setting that can be changed by right clicking on the
>> desktop and selecting properties and then going to the Appearance tab. Any
>> change that you make there however will apply to all dialog boxes, etc.
>>
>> --
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP
>>
>> "Jules" <Jules@discussions.microsoft.com> wrote in message
>> news:93724BE4-6AD8-437B-BFC0-FFD660A0A500@microsoft.com...
>>> Is it possible to change the background colour of the title in a vba user
>>> form (the one that defaults to UserForm1 when you create a new userform)?
>>> I
>>> know how to change the colours of the form itself and of any text boxes
>>> etc.
>>> placed on the form but not the title.
>>>
>>> thanks,
>>>
>>
>>
>>

--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID


Re: change colour in title of userform by Karl

Karl
Wed Sep 19 17:41:29 CDT 2007

Russ <drsN0SPAMmikle@hotmailD0Tcom.INVALID> wrote:
> Jules,
> I played around with this code in a userform to change the titlebar color of
> the form.

That code actually changes the titlebar color of *any* window that has the
foreground, right?

> As long as you show a userform in its default modal mode (meaning
> no other windows can be selected)

That's not system modal, though, right? I mean, another app could still steal the
foreground, or the user could Alt-Tab to another app, or yours could crash leaving
another app in the foreground, or ..., or ..., or ...?

> and you set the default color values back

And if you don't?

Not trying to be antagonistic, here. Just recalling a few hard-learned lessons.
--
.NET: It's About Trust!
http://vfred.mvps.org



Re: change colour in title of userform by Russ

Russ
Thu Sep 20 02:58:09 CDT 2007

Karl,
I do concede to a master like you. I am familiar with some of your previous
efforts.

> Russ <drsN0SPAMmikle@hotmailD0Tcom.INVALID> wrote:
>> Jules,
>> I played around with this code in a userform to change the titlebar color of
>> the form.
>
> That code actually changes the titlebar color of *any* window that has the
> foreground, right?
Yes, any window that is active or activated subsequently.
>
>> As long as you show a userform in its default modal mode (meaning
>> no other windows can be selected)
>
> That's not system modal, though, right? I mean, another app could still steal
> the
> foreground, or the user could Alt-Tab to another app, or yours could crash
> leaving
> another app in the foreground, or ..., or ..., or ...?
Yes, the system could still pop up a window outside of Word. And the
system's window titlebar would be changed.
And ..., or ...,-- those too.
>
>> and you set the default color values back
>
> And if you don't?
>
> Not trying to be antagonistic, here. Just recalling a few hard-learned
> lessons.
If you do, all previously changed windows, even those that accidentally pop
up before, will change back to normal, when selected again.

If you don't; or, since I didn't have code in case you selected button2
before button1, then you would have to go back and right click on the
Windows Desktop, select Properties...Appearance and select a theme that you
had before or if you restart Windows, I believe, it will reset back to what
you had before.
Nothing permanent, but I agree, that one must cover all bases to avoid
leaving a unwitting user perplexed.
I couldn't find a way yet to get the current active windows handle (easy)
and adjust its Caption (Titlebar) background only (hard, because it probably
involves bitmap coloring of regions, etc.).
--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID


Re: change colour in title of userform by Karl

Karl
Thu Sep 20 19:49:31 CDT 2007

Hi Russ --

> I do concede to a master like you. I am familiar with some of your previous
> efforts.

I misunderestimate stuff all the time. We're all learning, all the time.
Hopefully. <g>

>>> I played around with this code in a userform to change the titlebar color of
>>> the form.
>>
>> That code actually changes the titlebar color of *any* window that has the
>> foreground, right?
>
> Yes, any window that is active or activated subsequently.

Really good way to irritate users.

>>> and you set the default color values back
>>
>> And if you don't?
>>
>> Not trying to be antagonistic, here. Just recalling a few hard-learned
>> lessons.
>
> If you do, all previously changed windows, even those that accidentally pop
> up before, will change back to normal, when selected again.
>
> If you don't; or, since I didn't have code in case you selected button2
> before button1, then you would have to go back and right click on the
> Windows Desktop, select Properties...Appearance and select a theme that you
> had before or if you restart Windows, I believe, it will reset back to what
> you had before.

Really good way to irritate users. <G> Stuff happens. Crashes, even.

This illustrates why in the general VB groups it's exceedingly common to advise
folks to *not* mess with universal user settings. Not if they don't want their
software uninstalled, anyway.

> Nothing permanent, but I agree, that one must cover all bases to avoid
> leaving a unwitting user perplexed.

Can't be done.

> I couldn't find a way yet to get the current active windows handle (easy)
> and adjust its Caption (Titlebar) background only (hard, because it probably
> involves bitmap coloring of regions, etc.).

It's a royal PITA, really. And Microsoft is doing to the standard UI what the US
Mint is doing to the currency -- making it exceedingly difficult to reproduce. I
gave a link earlier, offering hints on how to consider proceeding. Best bet is to
tell the client you got better things to do with your life. <g>

Thanks... Karl
--
.NET: It's About Trust!
http://vfred.mvps.org