Paint title bar, menus etc.. (Change Color) 
Author Message
 Paint title bar, menus etc.. (Change Color)

Hi.
I want to paint or change the color of title bar or menus.
How do i do it.
I did.
1 GetWindowDC
2 GetSystemMetrics
then SetSysColor but by this code it changes whole
system's color.
I want to change only title bar and menus color. how?


Fri, 21 Jan 2005 14:47:53 GMT  
 Paint title bar, menus etc.. (Change Color)
    (Assuming VB6) To change the color of the title bar and menus of one
single program, you'll have to owner-draw the menu and the title bar - no
easy task! You'll need to subclass the window and here are a few messages
you'll want to handle: WM_NCPAINT  and maybe other WM_NC* messages,
WM_MEASUREITEM, WM_DRAWITEM. You might want to do some searching online at
like www.pscode.com , www.google.com , www.codehound.com , www.mvps.org ,
and other code sites for more information.

Avery


Quote:
> Hi.
> I want to paint or change the color of title bar or menus.
> How do i do it.
> I did.
> 1 GetWindowDC
> 2 GetSystemMetrics
> then SetSysColor but by this code it changes whole
> system's color.
> I want to change only title bar and menus color. how?



Sat, 22 Jan 2005 02:29:17 GMT  
 Paint title bar, menus etc.. (Change Color)
    Er, I must correct myself, since no one else did. It seems that you do
*not* have to owner-draw the menu to change the background color, if you are
targeting Win98 and up and/or Win2000 and up. The APIs you'll need aren't in
the VB6 API viewer, but here is the test code I used. Note that you'd need
to create your own HBRUSH to get different colors. It would also seem that
you can't change the text or separator colors without owner-drawing.

' --------------------------------------------------------------------------
-----
' Prerequisites: Have a menu on the form!
' --------------------------------------------------------------------------
-----
Option Explicit

Private Const MNS_NOCHECK = &H80000000
Private Const MNS_MODELESS = &H40000000
Private Const MNS_DRAGDROP = &H20000000
Private Const MNS_AUTODISMISS = &H10000000
Private Const MNS_NOTIFYBYPOS = &H8000000
Private Const MNS_CHECKORBMP = &H4000000

Private Const MIM_MAXHEIGHT = &H1
Private Const MIM_BACKGROUND = &H2
Private Const MIM_HELPID = &H4
Private Const MIM_MENUDATA = &H8
Private Const MIM_STYLE = &H10
Private Const MIM_APPLYTOSUBMENUS = &H80000000

Private Type MENUINFO
  cbSize As Long
  fMask As Long
  dwStyle As Long
  cyMax As Long
  hbrBack As Long
  dwContextHelpID As Long
  dwMenuData As Long
End Type
Private Declare Function SetMenuInfo Lib "user32" (ByVal hMenu As Long,
lpcmi As MENUINFO) As Long
Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long

Private Const WHITE_BRUSH = 0
Private Declare Function GetStockObject Lib "gdi32" (ByVal nIndex As Long)
As Long

Private Sub Form_Load()
   Dim hMenu As Long
   Dim mi As MENUINFO

   hMenu = GetMenu(hwnd)
   If hMenu Then
      mi.cbSize = Len(mi)
      mi.fMask = MIM_BACKGROUND Or MIM_APPLYTOSUBMENUS
      mi.hbrBack = GetStockObject(WHITE_BRUSH)
      SetMenuInfo hMenu, mi
   End If
End Sub

You might want to look up SetMenuInfo in the online MSDN help for more
information on what it can do, and if it doesn't do what you need, then
you'll have to go with owner-drawing and subclassing.

Avery



Wed, 09 Feb 2005 09:00:16 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Change Font in title bar of mdi child/Hide title bar

2. Change Font in title bar of mdi child/Hide title bar

3. Change default win98 active title bar color?

4. How to change color of title bar

5. Changing Title Bar Color ??

6. Change default win98 active title bar color?

7. Title bar (caption) color change

8. Changing a specific form's title bar color

9. Title Bar Color Change

10. Change the Title Bar Color

11. Changing title bar color of a form

12. Changing to color of a forms title bar

 

 
Powered by phpBB® Forum Software