Visual Foxpro Rocks!

May 27, 2006

How to change VFP tooltips appearance using BINDEVENT()


May 28, 2006

For those of you who reads my article on UT Magazine (VFP9 OwnerDrawn Menu - October 2005) and use the class, might have noticed that the sample doesn't work (crashed) under Win9X/ME. This is because the code has a logic bug, a small but fatal! Take a look for OnMeasureMenuItem() method in PopupMenu class, and change the whole code inside that method with the code below. If you have changed the code then change accordingly:

** OnMeasureMenuItem
LParameters th_Wnd as Long, tp_MIS as Long

** tp_MIS = pointer to MeasureItemStruct

Local lp_PopItem, lh_DC, lh_OldFont, ls_Size
Local lc_ItemText, ln_Len, ln_SizeX, ln_SizeY

Store 0 to lp_PopItem, ln_Len
CopyMem2Num( @lp_PopItem, tp_MIS + (DWORD_Size*5), DWORD_Size )
CopyMem2Num( @ln_Len, lp_PopItem+64, DWORD_Size )

If (ln_Len > 0)
lc_ItemText = space(64)
ls_Size = replicate( c0, POINT_Size )
CopyMem( @lc_ItemText, lp_PopItem, ln_Len )
lc_ItemText = left( lc_ItemText, ln_Len )
lc_ItemText = strtran( lc_ItemText, '&', '' )
ln_Len = ln_Len - 1
lh_DC = GetDC( th_Wnd )
lh_OldFont = SelectObject( lh_DC, This.hFont )
GetTextExtentPoint32( lh_DC, lc_ItemText, ln_Len, @ls_Size )
SelectObject( lh_DC, lh_OldFont )
ReleaseDC( th_Wnd, lh_DC )

If This.lUseGradient
ln_SizeX = This.Buff2Num( ls_Size, 1 ) + GetSystemMetrics( SM_CXMENUCHECK ) + 24
else
ln_SizeX = This.Buff2Num( ls_Size, 1 ) + GetSystemMetrics( SM_CXMENUCHECK ) + 20
endif
ln_SizeY = This.Buff2Num( ls_Size, 5 ) + 7
else && Separator
ln_SizeX = 0
ln_SizeY = 5
endif

CopyNum2Mem( tp_MIS + (DWORD_Size*3), ln_SizeX, DWORD_Size ) && Item Width
CopyNum2Mem( tp_MIS + (DWORD_Size*4), ln_SizeY, DWORD_Size ) && Item Height


Go to Download area


Special thanks to:
Malcolm Greene (www.bdurham.com) for providing me this space on their web site


Author by: Herman Tan
Copyright © 2006 - 2008


counter