在FormCreate设置PersonSignLB的windows消息
aHint :=THintWindow.Create(nil);
aHint.Color :=clInfoBk;FWndMethod := PersonSignLB.WindowProc;PersonSignLB.WindowProc := LabelWndProc;
显示个人提示框
procedure TMainForm.LabelWndProc(var Msg: TMessage);
//根据一定长度,将字符串变为回车的字符
function SplitByLen(src:string;var row:Integer;perCount:Integer):string; var i,j:Integer; c:Char; sTemp,s1:string; bIsDBCS:Boolean; begin row :=Ceil(Length(src)/perCount); sTemp :=''; bIsDBCS :=False; for I := 1 to row do begin for j:= 1 to perCount do begin if bIsDBCS then bIsDBCS := False else if Windows.IsDBCSLeadByte(byte(src[j])) then bIsDBCS := True; end;if bIsDBCS then Dec(perCount);
if i=row then sTemp :=sTemp +Copy(src,1,perCount) else sTemp :=sTemp +Copy(src,1,perCount)+#10#13; src :=Copy(src,perCount+1,Length(src)-perCount); end; if bIsDBCS then Inc(perCount); Result :=sTemp; end;var
p,p1,p2: TPoint; iRow:Integer; s:string;begin GetCursorPos(p); p1 :=Point(p.x,p.y+20);if Msg.Msg = CM_MOUSELEAVE then
begin ShowWindow(aHint.Handle, SW_HIDE); end else if Msg.Msg = CM_MOUSEENTER then begin s :=SplitByLen(FSingLB,iRow,36); //djc 2012-8-30 mod if iRow=1 then p2 :=Point(p.x+220,p.y+36) else p2 :=Point(p.x+220,p.y+26*iRow); aHint.ActivateHint(Rect(p1,p2),s); end; FWndMethod(Msg);end;