关于QQ的Listview处理 ( 积分: 100 )

  • 主题发起人 主题发起人 李连杰
  • 开始时间 开始时间

李连杰

Unregistered / Unconfirmed
GUEST, unregistred user!
&nbsp;我现在能用LVM_DELETEITEM删除其中一项(Listview),用LVM_SETBKIMAGE更换背景颜色.<br> &nbsp;但始终末能用Sendmessage去选中其中的一项(如鼠标点击);<br> &nbsp;但有一句却有这样的作用:<br> &nbsp;SendMessage(句柄,WM_KEYDOWN,VK_END,6);<br> &nbsp;不过用这句的时候,总是选择了最后的一项,而且不会显示高亮.<br> &nbsp;我想知道用那句才能选中某一项.<br> &nbsp;如果要加分的话,没问题.
 
&nbsp;我现在能用LVM_DELETEITEM删除其中一项(Listview),用LVM_SETBKIMAGE更换背景颜色.<br> &nbsp;但始终末能用Sendmessage去选中其中的一项(如鼠标点击);<br> &nbsp;但有一句却有这样的作用:<br> &nbsp;SendMessage(句柄,WM_KEYDOWN,VK_END,6);<br> &nbsp;不过用这句的时候,总是选择了最后的一项,而且不会显示高亮.<br> &nbsp;我想知道用那句才能选中某一项.<br> &nbsp;如果要加分的话,没问题.
 
要加分呦,要选某一项就用<br><br>var i:integer;<br> &nbsp; &nbsp;Item: TLVItem;<br>begin<br> &nbsp;//得到一项<br> &nbsp;i:=SendMessage(ListView1.Handle,LVM_GETNEXTITEM,0,MakeLong(LVNI_BELOW, 0));<br> &nbsp;Item.stateMask := LVIS_SELECTED;<br> &nbsp;Item.state := LVIS_SELECTED;<br> &nbsp;//设置某项选中<br> &nbsp;SendMessage(ListView1.Handle, LVM_SETITEMSTATE, i, Longint(@Item)) ;<br> &nbsp;SendMessage(ListView1.Handle,WM_SETFOCUS ,0,0);<br>end;
 
一定会加分,我说的是其它程,你这个不知行不行,先试一下.<br> &nbsp; &nbsp; 你放心---------信誉第一
 
TO weekboy<br><br>很奇怪,用你的能够选中任何一项,会显示高亮.但是是假的,你试一下,打开QQ的查找/添加好友.用下面的语句可以选中,但当你点击加为好友的时候却是空的.<br><br><br>你看一下这问题出在那<br><br><br>procedure TForm1.Button12Click(Sender: TObject);<br>Var<br> &nbsp; hMemo, hRichEdit, HWindow, HButton: THandle; //句柄变量<br> &nbsp; szText &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : Array[0..255] Of char; &nbsp; //得到的字符串<br> MyText &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : String; &nbsp;//发送的字符串<br> &nbsp; i:integer;<br> &nbsp; &nbsp;Item: TLVItem;<br>begin<br>HWindow := 0;//从零开始,即从第一个字窗体开始遍历查找<br>hMemo := FindWindowEx(0, HWindow, '#32770','QQ2004查找/添加好友');//<br> HWindow := FindWindowEx(hMemo,0, 'systabcontrol32',0);//<br> HButton := FindWindowEx(HWindow,0, '#32770',0);<br> EDIT1.TEXT:='张小雨1'; &nbsp; &nbsp; // &nbsp; &nbsp; &nbsp;由于我不知道如何进入第四个#32700,所以都给它起个名字,当然,如果谁告诉我也会有一百分.<br>SendMessage(HButton, WM_SETTEXT, 256,integer(EDIT1.TEXT));<br><br>HButton := FindWindowEx(HWindow,0, '#32770','');//<br>EDIT1.TEXT:='张小雨2';<br>SendMessage(HButton, WM_SETTEXT, 256,integer(EDIT1.TEXT));<br><br>HButton := FindWindowEx(HWindow,0, '#32770','');//<br>EDIT1.TEXT:='张小雨3';<br>SendMessage(HButton, WM_SETTEXT, 256,integer(EDIT1.TEXT));<br><br><br><br>HButton := FindWindowEx(HWindow,0, '#32770','');//<br>EDIT1.TEXT:='张小雨4';<br>SendMessage(HButton, WM_SETTEXT, 256,integer(EDIT1.TEXT));<br>HButton := FindWindowEx(HWindow,0, '#32770','');//<br>EDIT1.TEXT:='张小雨5';<br>SendMessage(HButton, WM_SETTEXT, 256,integer(EDIT1.TEXT));<br>HButton := FindWindowEx(HWindow,0, '#32770','');//<br>EDIT1.TEXT:='张小雨6';<br>SendMessage(HButton, WM_SETTEXT, 256,integer(EDIT1.TEXT));<br>HButton := FindWindowEx(HWindow,0, '#32770','');//<br>EDIT1.TEXT:='张小雨7';<br>SendMessage(HButton, WM_SETTEXT, 256,integer(EDIT1.TEXT));<br>HButton := FindWindowEx(HWindow,0, '#32770','');//<br>EDIT1.TEXT:='张小雨8';<br>SendMessage(HButton, WM_SETTEXT, 256,integer(EDIT1.TEXT));<br>HButton := FindWindowEx(HWindow,0, '#32770','');//<br>EDIT1.TEXT:='张小雨9';<br>SendMessage(HButton, WM_SETTEXT, 256,integer(EDIT1.TEXT));<br>HButton := FindWindowEx(HWindow,0, '#32770','');//<br>EDIT1.TEXT:='张小雨10';<br>SendMessage(HButton, WM_SETTEXT, 256,integer(EDIT1.TEXT));<br><br><br>//这里是我要进去的第四个#32700<br>HButton := FindWindowEx(HWindow,0, '#32770','张小雨4');<br>hRichEdit := FindWindowEx(HButton, 0,'syslistview32', 'list1');<br>IF (hRichEdit&amp;lt;&amp;gt;0) THEN SHOWMESSAGE('OK');<br><br>//SendMessage(hRichEdit,WM_KEYDOWN,VK_END,6);// 这句就是我说的,他可以点击最后一项<br><br>Item.stateMask := LVIS_SELECTED;//可能是这两句有问题吧.<br> &nbsp;Item.state := LVIS_SELECTED;<br>SendMessage(hRichEdit, LVM_SETITEMSTATE, 1,Longint(@Item)) ;<br>SendMessage(hRichEdit,WM_SETFOCUS ,0,0);<br>end;
 
TO weekboy<br><br>行了,加了.
 
后退
顶部