Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MenuBar Behavior 1

Status
Not open for further replies.

CubeE101

Programmer
Nov 19, 2002
1,492
US
I recently noticed that my Menu Bars have been acting a little ODD lately...

It's not that big of a deal, and I'm not sure how long this has been occurring...

Bascally, the form background is the ButtonFace color (gray)
The MenuBar shows in the form designer as White...
mb1.jpg

Then when you run the program, the bar is gray except the immediate area around the text of the MenuItems, which is also surrounded by gray...
mb2.jpg

Once you click on a menu item the gray border surrounding the menu item turns white...
mb3.jpg

Has anyone else noticed this?

Does anyone know what causes this?

*Note: it appears to happen in a few other programs as well, (PintBrush & NotePad) but most other programs work fine...

Is this something that can be corrected in VB (such as changing the menubar color), or is it a windows thing?

OS: Win XP Pro
VB: VB6

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
hmmmm...
I changed the Windows Appearance "Menu" color to gray (from white) and it looks normal now...

My company might have forced something through that changed it when the Wallpaper changed the other day...

O well, is it possible to control the menu color per program in VB?

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
I had the same problem and I used a modified version of this, though I cannot seam to find it at the moment.



Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'.
 
Thanks, DrJavaJoe

I just want it to be White (or Window Background Color)

Here's what I came up with:
Code:
Option Explicit

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 DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function SetMenuInfo Lib "user32" (ByVal hmenu As Long, mi As MENUINFO) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
Private Declare Function OleTranslateColor Lib "olepro32.dll" (ByVal OLE_COLOR As Long, ByVal HPALETTE As Long, pccolorref As Long) As Long

Private Sub Form_Load()
  Dim mi As MENUINFO, clrref As Long, hSysMenu As Long
  OleTranslateColor [b]vbWindowBackground[/b], 0, clrref
  mi.cbSize = Len(mi)
  mi.fMask = &H80000002
  mi.hbrBack = CreateSolidBrush(clrref)
  hSysMenu = GetSystemMenu(Me.hwnd, False)
'*** Draw Menu Color
  SetMenuInfo GetMenu(Me.hwnd), mi
  DrawMenuBar Me.hwnd
'*** Draw System Menu Color
  SetMenuInfo hSysMenu, mi
  DrawMenuBar hSysMenu
End Sub

Works Great!

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top