UserForm Title Bar - Colors

Gerryc

New Member
Joined
Sep 4, 2006
Messages
1
SUBJECT: WIN32API Calls from MS Excel Visual Basic. Excel ver 97 SR-2 Visual Basic ver 8.0e

SPECIFIC: UserForm ActiveTitle Bar colors appear to adopt those of the Windows Desktop setup

QUESTION: Is it possible to temporarily alter UserForm ActiveTitle Bar colors via a WIN32API Call for a particular UserForm when loaded or on 'Show'? The Windows Desktop Color settings revert to 'normal' after the UserForm is unloaded or hidden?

Any advice or even sample code would be appreciated.

Thanks

Gerry
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Welcome to the board.

I am not 100% sure but I don't think you can change the caption bar color of a single window . I tried this before but failed.

painting the boundaries of the title bar with a graphical brush would probably work but would be difficult.

the closest I've come is to change the color of the caption text as follows :

place this in a the userform module :

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

Private Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long

Dim lngColor As Long
Const COLOR_CAPTIONTEXT = 9


Private Sub UserForm_Initialize()

    lngColor = GetSysColor(COLOR_CAPTIONTEXT)
    SetSysColors 1, COLOR_CAPTIONTEXT, vbRed
    
End Sub


Private Sub UserForm_Terminate()

    SetSysColors 1, COLOR_CAPTIONTEXT, lngColor
    
End Sub

Regards.
 
Upvote 0

Forum statistics

Threads
1,214,617
Messages
6,120,541
Members
448,970
Latest member
kennimack

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top