求助如何使用sendmessage ( 积分: 50 )

  • 主题发起人 主题发起人 idonot
  • 开始时间 开始时间
I

idonot

Unregistered / Unconfirmed
GUEST, unregistred user!
我想在程序中向一个外部应用程序中的一个listview控件发送消息,自动控制listview显示的内容,我这样使用:SendMessage(HWND,WM_SETTEXT,0,longint(@filestr));但行不通,特向各位大虾请教,望尽快得到回复!
 
我想在程序中向一个外部应用程序中的一个listview控件发送消息,自动控制listview显示的内容,我这样使用:SendMessage(HWND,WM_SETTEXT,0,longint(@filestr));但行不通,特向各位大虾请教,望尽快得到回复!
 
怎么没人回答啊,这可是我最后的积分了!<br>吐血求助!
 
你有没有找对这个listview的handle啊
 
有啊,但不知如何使listview的值显示为我传过去的字符
 
var pItem: TLVItem;<br> &nbsp; &nbsp;Buff: PChar;<br> &nbsp; &nbsp;PID,PRC: THandle;<br> &nbsp; &nbsp;R: Cardinal;<br>begin<br> &nbsp; &nbsp; &nbsp;GetWindowThreadProcessId(L, @PID);<br> &nbsp; &nbsp; &nbsp;PRC := OpenProcess(PROCESS_VM_OPERATION or PROCESS_VM_READ or <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PROCESS_VM_WRITE, False, PID);<br> &nbsp; &nbsp; &nbsp;Buff := VirtualAllocEx(PRC, nil, 4096, MEM_RESERVE or MEM_COMMIT, <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PAGE_READWRITE);<br> &nbsp; &nbsp; &nbsp;ZeroMemory(@pItem,SizeOf(pItem));<br> &nbsp; &nbsp; &nbsp;with pItem do<br> &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp;mask := LVIF_TEXT;<br> &nbsp; &nbsp; &nbsp; &nbsp;pszText := PChar(integer(Buff) + SizeOf(pItem) * 4);<br> &nbsp; &nbsp; &nbsp; &nbsp;cchTextMax := Length(Edit1.Text)+1;//Edit1.Text為新增Item名稱<br> &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp;WriteProcessMemory(PRC, Buff, @pItem, Sizeof(pItem), R);<br> &nbsp; &nbsp; &nbsp;WriteProcessMemory(PRC, PChar(integer(Buff) + SizeOf(pItem) * 4), <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PChar(Edit1.Text), Length(Edit1.Text)+1, R);<br> &nbsp; &nbsp; &nbsp;SendMessage(L,LVM_INSERTITEM,0,LongInt(Buff));//L為ListView的Handle<br> &nbsp; &nbsp; &nbsp;VirtualFreeEx(PRC, Buff, 0, MEM_RELEASE);<br> &nbsp; &nbsp; &nbsp;CloseHandle(PRC);<br>end;
 
TLVItem &nbsp;Delphi不认啊,帮助里也找不到,Unit中加了QComCtrls也不行,还请老兄指点
 
uses commctrl;
 
對,迷糊已經告訴你了。
 
listview还是无法接受这些信息啊
 
能告知qq或msn吗?<br>我的qq:8775446
 
上面的代碼是經過測試的,肯定是沒問題。要不然就是你的句柄沒抓到。
 
当listview的ViewStyle为vsReport,且columns为多列就无法接受信息了.<br>如果是FileListBox,如何使FileListbox接受信息使它自动设为我指定的路径呢?
 
后退
顶部