delphi – ListBox长项提示
发布时间:2020-12-15 04:02:02 所属栏目:大数据 来源:网络整理
导读:有一个包含一些长项的ListBox.这些长项超出了ListBox的右边缘,这里有一个想法,当鼠标悬停在这些项目上时显示这些项目的提示. 我找到了一个例子:(从http://delphi.about.com/cs/adptips2001/a/bltip0201_4.htm开始) procedure TForm1.ListBox1MouseMove (Send
有一个包含一些长项的ListBox.这些长项超出了ListBox的右边缘,这里有一个想法,当鼠标悬停在这些项目上时显示这些项目的提示.
我找到了一个例子:(从http://delphi.about.com/cs/adptips2001/a/bltip0201_4.htm开始) procedure TForm1.ListBox1MouseMove (Sender: TObject; Shift: TShiftState; X,Y: Integer) ; var lstIndex : Integer ; begin with ListBox1 do begin lstIndex:=SendMessage(Handle,LB_ITEMFROMPOINT,MakeLParam(x,y)) ; if (lstIndex >= 0) and (lstIndex <= Items.Count) then Hint := Items[lstIndex] else Hint := '' end; end; 它工作,但每次我想查看另一个项目的提示时,我必须将我的鼠标从ListBox移开,然后指向另一个项目以查看其提示.有没有办法在不将鼠标移离ListBox边框的情况下查看每个项目的提示? 解决方法var fOldIndex: integer = -1; procedure TForm1.ListBox1MouseMove (Sender: TObject; Shift: TShiftState; X,y)) ; // this should do the trick.. if fOldIndex <> lstIndex then Application.CancelHint; fOldIndex := lstIndex; if (lstIndex >= 0) and (lstIndex <= Items.Count) then Hint := Items[lstIndex] else Hint := '' end; end; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |