how can i change the font of menu items dynamically or during design time
or making them bold, or italic ect..
thanks
Printable View
how can i change the font of menu items dynamically or during design time
or making them bold, or italic ect..
thanks
Hmmmm.....As far as I know you can't change menu font because the Empire wants to preserve a particular feel about Windows and Windows applications. Do a message search on 'Menu Font' or something - I think I saw it on this board.
I can there's a third party control that might do the job.
Long story...
I've made an app which makes a menu (and menubar) with the tahoma font. You can change the form's font and by doing that you change the menu's font.
I could modify the app so that you can italicise and make them bold at run-time, but that would take a couple of days.
I'll send it to you then.
Please tell me if you don't need it. I ahte it when you spend a couple of days making code for people, who then decide not to use it.
That just makes me mad.
Grrrrrrr.
Where was I? Oh, yes. I'll send it to you in a couple of days.
Promised.
after thinking microsoft really sucks
i decided to creat my own menu'z :)
so dont need to send anything YET
unless my plan fails
here is what am trying to do
i got a form going, that will have customized labels (using as menu items)
so i can change the form background to what ever i want, change the font to what eva i want ect
possibilies become endless..
these menu'z are for popupz
I got an example and tried to shorten it as much as possible for simplicity sake. (This will change the Font, Style and Colour)
Insert this into a Form with SubMenus and a CommandButton.
Code:Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hDC As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hDC As Long) As Long
Private Declare Function CreateFont Lib "gdi32" Alias "CreateFontA" (ByVal H As Long, ByVal W As Long, ByVal E As Long, ByVal O As Long, ByVal W As Long, ByVal i As Long, ByVal u As Long, ByVal S As Long, ByVal C As Long, ByVal OP As Long, ByVal CP As Long, ByVal Q As Long, ByVal PAF As Long, ByVal F As String) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
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 Long) As Long
Private Declare Function Rectangle Lib "gdi32" (ByVal hDC As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal hObject As Long) As Long
Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
Const MF_BITMAP = &H4&
Const MF_STRING = &H0&
Private Sub Command1_Click()
Dim hID As Long
Dim hMenu As Long
Dim hSubMenu As Long
Dim hDC As Long
Dim hFont As Long
Dim hBmp As Long
Dim lh()
hMenu = GetMenu(Form1.hwnd)
hSubMenu = GetSubMenu(hMenu, 0)
hDC = CreateCompatibleDC(Me.hDC)
iCount = GetMenuItemCount(hSubMenu)
ReDim lh(iCount)
'Loop through the SubMenus
For i = 0 To GetMenuItemCount(hSubMenu)
hID = GetMenuItemID(hSubMenu, i)
hFont = CreateFont(-16, 0, 0, 0, 800, 1, 0, 0, 0, 0, 0, 0, 0, Me.FontName)
lh(i) = CreateCompatibleBitmap(hDC, 200, 18)
hBmp = SelectObject(hDC, lh(i))
SelectObject hDC, hFont
Rectangle hDC, -1, -1, 201, 19
TextOut hDC, 0, 0, "SubMenu" & i, 8
ModifyMenu hSubMenu, hID, MF_BITMAP, hID, lh(i)
Next i
End Sub
Private Sub Form_Load()
'Change the FontName here
Me.FontName = "Courier"
End Sub