W
wisenow
Unregistered / Unconfirmed
GUEST, unregistred user!
目的:自己重画菜单。<br>错误:得到菜单的标题是乱七八糟,甚至为空。<br>代码:<br>procedure WMDRAWITEM(var M: TMessage); message WM_DRAWITEM;<br><br>procedure TBookCLass.WMDRAWITEM(var M: TMessage);<br>var<br> BKcolor, txtColor: Cardinal;<br> R, R1: TRect;<br> B: HBrush;<br> mchr: array[0..255] of char;<br>begin<br> ... ... ...<br> //GetMenuString(FMenu, PDrawItemStruct(M.LParam).itemID, mchr, 255, MF_BYCOMMAND);<br> // MessageBox(0, '', '', 0);<br> // 曾经试用GetMenuString不过得到的是空 <br> //mchr[0] := pchar(PDrawItemStruct(M.LParam).itemData)^;<br><br> TextOut(PDrawItemStruct(M.LParam).hDC,<br> R.Left,<br> R.Top,<br> //pchar(Trim(mchr)),<br> //Length(Trim(mchr)));<br> pchar(PDrawItemStruct(M.LParam).itemData), // 得到的不完全正确<br> Length(Trim(pchar(PDrawItemStruct(M.LParam).itemData))));<br> //MessageBox(0, '', pchar(PDrawItemStruct(M.LParam).itemData), 0);<br> M.Result := 1;<br>end;<br>