Results 1 to 7 of 7

Thread: font of menu

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    nasik,india
    Posts
    909

    font of menu

    can we change font of menu bar ?
    WHETHER YOU SUCCEED OR FAIL IS NOT AS IMPORTANT AS WHETHER YOU TRIED YOUR BEST

  2. #2
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: font of menu

    Menu bar or Menu Item?

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    nasik,india
    Posts
    909

    Re: font of menu

    menu item .
    WHETHER YOU SUCCEED OR FAIL IS NOT AS IMPORTANT AS WHETHER YOU TRIED YOUR BEST

  4. #4
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: font of menu

    You can't directly, but you can make a picture with the font on it..
    VB Code:
    1. Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
    2. Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
    3. Private Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
    4. Private Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpString As Any) As Long
    5. Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
    6. Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
    7. Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
    8. Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    9. Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
    10. Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    11.  
    12. Private Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
    13. Private Const MF_BYPOSITION = &H400&
    14. Private Const MF_BITMAP = &H4&
    15.  
    16. Private Sub Form_Load()
    17. Dim Width As Integer, Height As Integer
    18. Dim hTmpDC As Long, hMenuID As Long
    19. Dim hBitmap As Long, retValue As Long
    20. Dim tmpID As Long
    21. Dim fileName As String
    22. Dim menuPos As Integer, menuID As Long
    23.  
    24. menuPos = 0
    25. fileName = App.Path & "\new.bmp"
    26. Picture1.Picture = LoadPicture(fileName)
    27. Width = 64
    28. Height = 16
    29. hMenuID = GetSubMenu(GetMenu(Me.hwnd), menuPos)
    30. hTmpDC = CreateCompatibleDC(Picture1.hdc)
    31. hBitmap = CreateCompatibleBitmap(Picture1.hdc, Width, Height)
    32. tmpID = SelectObject(hTmpDC, hBitmap)
    33. retValue = BitBlt(hTmpDC, 0, 0, Width, Height, Picture1.hdc, 0, 0, SRCCOPY)
    34. tmpID = SelectObject(hTmpDC, tmpID)
    35. menuID = GetMenuItemID(hMenuID, menuPos)
    36. retValue = ModifyMenu(hMenuID, menuPos, MF_BYPOSITION Or MF_BITMAP, menuID, hBitmap)
    37.  
    38. retValue = DeleteDC(hTmpDC)
    39. End Sub
    The picture needs to be 64x16 big. You need to have a menu created already, with 1 subitem...

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  5. #5
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: font of menu

    With this little app you can add pictures to menu items. You can change the Form font and fontsize to what ever you want and this will change the menu font and fontsize.
    Attached Files Attached Files
    Last edited by Keithuk; Dec 25th, 2006 at 06:48 PM.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  6. #6
    New Member
    Join Date
    Jun 2012
    Posts
    1

    Re: font of menu

    Thanks for this mate it was exactly what I was searching for and it works perfectly but we cannot use CheckBoxes on the menu any longer, does anyone know how to make them working again as it is necessary to me?

    Thanks!

  7. #7
    Member
    Join Date
    Jun 2018
    Location
    New Orleans, Austin, Santa Monica
    Posts
    35

    Re: font of menu

    Cool_Menu still works, but in Windows 7 I initially received the following error:
    "Line 28: Class MSComctlLib.ImageList of control ImageList was not a loaded control class."
    I believe this is because Component MSCOMCTL.OCX is not not registered.
    I resolved this problem by running the following in elevated Command Prompt window:
    cd C:\Windows\SysWOW64\
    regtlib msdatsrc.tlb

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