Results 1 to 6 of 6

Thread: Giving BackColor to MENU n TABCONTROL

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2005
    Posts
    33

    Question Giving BackColor to MENU n TABCONTROL

    How can I give back color and icons in the Menu. Also, how can I give backcolor to the TabControl, in VB 6.0

    is there any third party conponent or dll available for that.

    Thanx

  2. #2
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: Giving BackColor to MENU n TABCONTROL

    yes there is, you can make use of vbaccelerator

    click here
    http://www.vbaccelerator.com
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Giving BackColor to MENU n TABCONTROL


  4. #4
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: Giving BackColor to MENU n TABCONTROL

    to give Icons to Menu:
    VB Code:
    1. Const MF_BYPOSITION = &H400&
    2. Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
    3. Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
    4. Private Declare Function SetMenuItemBitmaps Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal hBitmapUnchecked As Long, ByVal hBitmapChecked As Long) As Long
    5. Private Sub Form_Load()
    6.     'KPD-Team 2000
    7.     'URL: [email]KPDTeam@Allapi.net[/email]
    8.     'E-Mail: [email]KPDTeam@Allapi.net[/email]
    9.     Dim hMenu As Long, hSubMenu As Long
    10.     'get the handle of the menu
    11.     hMenu = GetMenu(Me.hwnd)
    12.     'check if there's a menu
    13.     If hMenu = 0 Then
    14.         MsgBox "This form doesn't have a menu!"
    15.         Exit Sub
    16.     End If
    17.     'get the first submenu
    18.     hSubMenu = GetSubMenu(hMenu, 0)
    19.     'check if there's a submenu
    20.     If hSubMenu = 0 Then
    21.         MsgBox "This form doesn't have a submenu!"
    22.         Exit Sub
    23.     End If
    24.     'set the menu bitmap
    25.     SetMenuItemBitmaps hSubMenu, [b]0[/b], MF_BYPOSITION, Image1.Picture, Image1.Picture
    26. End Sub
    where the bold 0 represents the submenu number starting from 0.
    Show Appreciation. Rate Posts.

  5. #5
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: Giving BackColor to MENU n TABCONTROL

    to change the color of Menu bar, try this, posted by Jcis (in some post)
    VB Code:
    1. Option Explicit
    2.  
    3. Private Type MENUINFO
    4.     cbSize As Long
    5.     fMask As Long
    6.     dwStyle As Long
    7.     cyMax As Long
    8.     hbrBack As Long
    9.     dwContextHelpID As Long
    10.     dwMenuData As Long
    11. End Type
    12.  
    13. Private Declare Function DrawMenuBar Lib "user32" _
    14.     (ByVal hwnd As Long) As Long
    15.  
    16. Private Declare Function GetMenu Lib "user32" _
    17.     (ByVal hwnd As Long) As Long
    18.  
    19. Private Declare Function GetSystemMenu Lib "user32" _
    20.     (ByVal hwnd As Long, _
    21.     ByVal bRevert As Long) As Long
    22.  
    23. Private Declare Function SetMenuInfo Lib "user32" _
    24.     (ByVal hmenu As Long, _
    25.     mi As MENUINFO) As Long
    26.  
    27. Private Declare Function CreateSolidBrush Lib "gdi32" _
    28.     (ByVal crColor As Long) As Long
    29.  
    30. Private Declare Function OleTranslateColor Lib "olepro32.dll" _
    31.     (ByVal OLE_COLOR As Long, _
    32.     ByVal HPALETTE As Long, _
    33.     pccolorref As Long) As Long
    34.  
    35. Private Const MIM_BACKGROUND As Long = &H2
    36. Private Const MIM_APPLYTOSUBMENUS As Long = &H80000000
    37.  
    38. Private Function SetMenuColour(ByVal hwndfrm As Long, _
    39.         ByVal dwColour As Long, _
    40.         ByVal bIncludeSubmenus As Boolean) As Boolean
    41.         'set application menu colour
    42.     Dim mi As MENUINFO
    43.     Dim flags As Long
    44.     Dim clrref As Long
    45.         'convert a Windows colour (OLE colour)
    46.     'to a valid RGB colour if required
    47.     clrref = TranslateOLEtoRBG(dwColour)
    48.    
    49.     'we're changing the background,
    50.     'so at a minimum set this flag
    51.     flags = MIM_BACKGROUND
    52.    
    53.     If bIncludeSubmenus Then
    54.         'MIM_BACKGROUND only changes
    55.         'the back colour of the main
    56.         'menu bar, unless this flag is set
    57.         flags = flags Or MIM_APPLYTOSUBMENUS
    58.     End If
    59.         'fill in struct, assign to menu,
    60.     'and force a redraw with the
    61.     'new attributes
    62.     With mi
    63.         .cbSize = Len(mi)
    64.         .fMask = flags
    65.         .hbrBack = CreateSolidBrush(clrref)
    66.     End With
    67.         SetMenuInfo GetMenu(hwndfrm), mi
    68.     DrawMenuBar hwndfrm
    69.    
    70. End Function
    71.  
    72. Private Function TranslateOLEtoRBG(ByVal dwOleColour As Long) As Long
    73.     OleTranslateColor dwOleColour, 0, TranslateOLEtoRBG
    74. End Function
    75.  
    76. Private Sub Form_Load()
    77.     'Change RGB(180, 210, 240) to the color you want
    78.     Call SetMenuColour(Me.hwnd, RGB(255, 255, 0), True)
    79. End Sub
    i tried something similar for Tabcontrol, but no success, but you may search here. i am sure you will get some positive results.
    Show Appreciation. Rate Posts.

  6. #6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width