-
Owner-drawn Menu Fails
Hi all!
I have been trying to get this working for months now. I have searched lots of VB code websites and forums but cant seem to find an answer to this.
I am trying to change the font colour, backround colour and highlight colour of a standard VB menubar. I have code to change the backround colour but any attempts at changing the font colour results in a completly black menu, both font and backround.
Here is the code that I am using:
Code:
Dim mSt As MENUINFO
Dim hdc As Long
Dim hPen As Long
Dim hBrush As Long
Dim lPen As LOGPEN
Dim lOldPointer As Long
Dim lResult2 As Long
hdc = GetDC(Me.hwnd)
With mSt
.cbSize = Len(mSt)
.fMask = MIM_BACKGROUND Or MIM_APPLYTOSUBMENUS
.hbrBack = CreateSolidBrush(vbBlue)
End With
With lPen
.lopnColor = vbRed
.lopnStyle = 0
End With
hPen = CreatePenIndirect(lPen)
lOldPointer = SelectObject(hdc, hPen)
lResult2 = DeleteObject(hPen)
lResult2 = SelectObject(hdc, lOldPointer)
SetMenuInfo GetMenu(Me.hwnd), mSt
DrawMenuBar Me.hwnd
lResult2 = DeleteObject(mSt.hbrBack)
lResult2 = DeleteDC(hdc)
I've had a lot of people look at this code and end up with the answer of "well it should work" Hopefully someone on here can point out where I am going wrong so I can finally get this thing working!
Many thanks in advance!!!