我们可以利用 listindex 属性得知 listbox 的选项, 但是当鼠标移到某一个选项上面(但还没有选取),如何得知此一选项呢?方法是对 listbox 送出
lb_itemfrompoint 信息, 细节如下:
1. api 的声明:
const lb_itemfrompoint = &h1a9
private declare function sendmessage lib "user32" alias "sendmessagea" (byval hwnd as long, byval wmsg as long, byval wparam as long, lparam as any) as long
注:如果以上的声明放在「一般模块」底下, 应在 const 之前加上 public 保留字, 并且将 private 保留字去掉。
2. 调用例:(在表单上布置一个 textbox 及一个 listbox, 然后利用 mousemove 事件程序来检测鼠标所在位置的选项)
private sub list1_mousemove(button as integer, shift as integer, x as single, y as single)
dim pos as long, idx as long
pos = x / screen.twipsperpixelx + y / screen.twipsperpixely * 65536
idx = sendmessage(list1.hwnd, lb_itemfrompoint, 0, byval pos)
' idx 即等于鼠标所在位置的选项
if idx < 65536 then text1.text = list1.list(idx)
end sub
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器