TO weekboy<br><br>很奇怪,用你的能够选中任何一项,会显示高亮.但是是假的,你试一下,打开QQ的查找/添加好友.用下面的语句可以选中,但当你点击加为好友的时候却是空的.<br><br><br>你看一下这问题出在那<br><br><br>procedure TForm1.Button12Click(Sender: TObject);<br>Var<br> hMemo, hRichEdit, HWindow, HButton: THandle; //句柄变量<br> szText : Array[0..255] Of char; //得到的字符串<br> MyText : String; //发送的字符串<br> i:integer;<br> 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'; // 由于我不知道如何进入第四个#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&lt;&gt;0) THEN SHOWMESSAGE('OK');<br><br>//SendMessage(hRichEdit,WM_KEYDOWN,VK_END,6);// 这句就是我说的,他可以点击最后一项<br><br>Item.stateMask := LVIS_SELECTED;//可能是这两句有问题吧.<br> Item.state := LVIS_SELECTED;<br>SendMessage(hRichEdit, LVM_SETITEMSTATE, 1,Longint(@Item)) ;<br>SendMessage(hRichEdit,WM_SETFOCUS ,0,0);<br>end;