怎样获取其它进程中ListBox(多列) 各Item的内容(50分)

  • 主题发起人 主题发起人 win32asm
  • 开始时间 开始时间
W

win32asm

Unregistered / Unconfirmed
GUEST, unregistred user!
发LB_GETTEXT消息可获取单列ListBox中的类容。<br>怎样得到多列ListBox中各Item的内容呢!发LB_GETITEMDATA消息??具体如何实现?
 
http://www.delphibbs.com/keylife/iblog_show.asp?xid=6393
 
这种方法对于多列ListBox好像行不通
 
如果你说的多列是用listview来实现的话,可以看看这篇文章<br>获取其他进程中ListView的文本<br>http://www.csdn.net/develop/Read_Article.asp?id=26046<br><br>另外<br>获取其他程序中TreeView的内容<br>http://www.csdn.net/develop/Read_Article.asp?id=26109<br><br>获取其他进程中ListBox和ComboBox的内容<br>http://www.csdn.net/develop/Read_Article.asp?id=26111
 
unit Unit1;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br>&nbsp; StdCtrls;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; GroupBox1: TGroupBox;<br>&nbsp; &nbsp; Button3: TButton;<br>&nbsp; &nbsp; Button4: TButton;<br>&nbsp; &nbsp; GroupBox2: TGroupBox;<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; Memo1: TMemo;<br>&nbsp; &nbsp; Edit1: TEdit;<br>&nbsp; &nbsp; Label1: TLabel;<br>&nbsp; &nbsp; GroupBox3: TGroupBox;<br>&nbsp; &nbsp; Button2: TButton;<br>&nbsp; &nbsp; Edit2: TEdit;<br>&nbsp; &nbsp; Label2: TLabel;<br>&nbsp; &nbsp; Label3: TLabel;<br>&nbsp; &nbsp; Edit3: TEdit;<br>&nbsp; &nbsp; Memo2: TMemo;<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; &nbsp; procedure Button2Click(Sender: TObject);<br>&nbsp; &nbsp; procedure Button3Click(Sender: TObject);<br>&nbsp; &nbsp; procedure Button4Click(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var s: array [0..4095] of char;<br>&nbsp; i: integer;<br>&nbsp; iItemCount: integer;<br>begin<br>&nbsp; try<br>&nbsp; &nbsp; StrToInt(trim(Edit1.text));<br>&nbsp; except<br>&nbsp; &nbsp; MessageDlg('请输入一个$开头的16进制整数ComboBox代号!',mtError, [mbOK], 0);<br>&nbsp; &nbsp; Exit;<br>&nbsp; end;<br>&nbsp; //Get comboBox items count<br>&nbsp; iItemCount:= sendMessage(StrToInt(trim(Edit1.text)),CB_GETCOUNT,0,0);<br><br>&nbsp; //Add it to memo1.<br>&nbsp; memo1.Lines.clear;<br>&nbsp; for i := 0 to iItemCount - 1 do<br>&nbsp; begin<br>&nbsp; &nbsp; sendMessage(StrToInt(trim(Edit1.text)),CB_GETLBTEXT,i,LongInt(@s));<br>&nbsp; &nbsp; memo1.Lines.Add(s);<br>&nbsp; end;<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>var s: array [0..4095] of char;<br>&nbsp; i: integer;<br>begin<br>&nbsp; try<br>&nbsp; &nbsp; StrToInt(trim(Edit2.text));<br>&nbsp; except<br>&nbsp; &nbsp; MessageDlg('请输入一个$开头的16进制整数ComboBox代号!',mtError, [mbOK], 0);<br>&nbsp; &nbsp; Exit;<br>&nbsp; end;<br>&nbsp; <br>&nbsp; //Insert a string into combobox item.<br>&nbsp; StrPCopy(s,Edit3.text);<br>&nbsp; sendMessage(StrToInt(trim(edit2.text)),CB_INSERTSTRING,1,LongInt(@s));<br>end;<br><br>procedure TForm1.Button3Click(Sender: TObject);<br>begin<br>&nbsp; //借用其它程序的combobox<br>&nbsp; windows.SetParent($00100196,Self.Handle);<br>&nbsp; //SetVisible。。。<br>&nbsp; ShowWindow($00100196,SW_SHOWNORMAL);<br>end;<br><br>procedure TForm1.Button4Click(Sender: TObject);<br>begin<br>&nbsp; //还给其它程序的combobox<br>&nbsp; windows.SetParent($00100196,$0001000c);<br>end;<br><br>end.<br>-------------------------------------dfm-----------------------------<br>object GroupBox1: TGroupBox<br>&nbsp; Left = 376<br>&nbsp; Top = 16<br>&nbsp; Width = 225<br>&nbsp; Height = 121<br>&nbsp; Caption = #20599#21035#20154#31243#24207#30340#25511#20214#29992<br>&nbsp; TabOrder = 0<br>&nbsp; object Button3: TButton<br>&nbsp; &nbsp; Left = 16<br>&nbsp; &nbsp; Top = 32<br>&nbsp; &nbsp; Width = 145<br>&nbsp; &nbsp; Height = 25<br>&nbsp; &nbsp; Caption = #20511#29992#20854#23427#31243#24207'ComboBox'<br>&nbsp; &nbsp; TabOrder = 0<br>&nbsp; &nbsp; OnClick = Button3Click<br>&nbsp; end<br>&nbsp; object Button4: TButton<br>&nbsp; &nbsp; Left = 18<br>&nbsp; &nbsp; Top = 74<br>&nbsp; &nbsp; Width = 123<br>&nbsp; &nbsp; Height = 25<br>&nbsp; &nbsp; Caption = #36824#20854#23427#31243#24207'ComboBox'<br>&nbsp; &nbsp; TabOrder = 1<br>&nbsp; &nbsp; OnClick = Button4Click<br>&nbsp; end<br>end<br>object GroupBox2: TGroupBox<br>&nbsp; Left = 24<br>&nbsp; Top = 8<br>&nbsp; Width = 337<br>&nbsp; Height = 329<br>&nbsp; Caption = #24471#21040#20854#23427#31243#24207' ComboBox '#20869#23481<br>&nbsp; TabOrder = 1<br>&nbsp; object Label1: TLabel<br>&nbsp; &nbsp; Left = 16<br>&nbsp; &nbsp; Top = 24<br>&nbsp; &nbsp; Width = 90<br>&nbsp; &nbsp; Height = 12<br>&nbsp; &nbsp; Caption = 'ComboBox'#31383#21475'ID:'<br>&nbsp; end<br>&nbsp; object Button1: TButton<br>&nbsp; &nbsp; Left = 232<br>&nbsp; &nbsp; Top = 16<br>&nbsp; &nbsp; Width = 75<br>&nbsp; &nbsp; Height = 25<br>&nbsp; &nbsp; Caption = #21015#20986#20869#23481<br>&nbsp; &nbsp; TabOrder = 0<br>&nbsp; &nbsp; OnClick = Button1Click<br>&nbsp; end<br>&nbsp; object Memo1: TMemo<br>&nbsp; &nbsp; Left = 16<br>&nbsp; &nbsp; Top = 48<br>&nbsp; &nbsp; Width = 289<br>&nbsp; &nbsp; Height = 273<br>&nbsp; &nbsp; TabOrder = 1<br>&nbsp; end<br>&nbsp; object Edit1: TEdit<br>&nbsp; &nbsp; Left = 112<br>&nbsp; &nbsp; Top = 16<br>&nbsp; &nbsp; Width = 97<br>&nbsp; &nbsp; Height = 20<br>&nbsp; &nbsp; TabOrder = 2<br>&nbsp; end<br>end<br>object GroupBox3: TGroupBox<br>&nbsp; Left = 24<br>&nbsp; Top = 344<br>&nbsp; Width = 337<br>&nbsp; Height = 105<br>&nbsp; Caption = #32473#20854#23427#31243#24207'ComboBox '#25554#20837#20854#23427#20869#23481<br>&nbsp; TabOrder = 2<br>&nbsp; object Label2: TLabel<br>&nbsp; &nbsp; Left = 96<br>&nbsp; &nbsp; Top = 21<br>&nbsp; &nbsp; Width = 90<br>&nbsp; &nbsp; Height = 12<br>&nbsp; &nbsp; Caption = 'ComboBox'#31383#21475'ID:'<br>&nbsp; end<br>&nbsp; object Label3: TLabel<br>&nbsp; &nbsp; Left = 96<br>&nbsp; &nbsp; Top = 61<br>&nbsp; &nbsp; Width = 36<br>&nbsp; &nbsp; Height = 12<br>&nbsp; &nbsp; Caption = #20869#23481#65306<br>&nbsp; end<br>&nbsp; object Button2: TButton<br>&nbsp; &nbsp; Left = 8<br>&nbsp; &nbsp; Top = 16<br>&nbsp; &nbsp; Width = 75<br>&nbsp; &nbsp; Height = 25<br>&nbsp; &nbsp; Caption = #25554#20837<br>&nbsp; &nbsp; TabOrder = 0<br>&nbsp; &nbsp; OnClick = Button2Click<br>&nbsp; end<br>&nbsp; object Edit2: TEdit<br>&nbsp; &nbsp; Left = 198<br>&nbsp; &nbsp; Top = 53<br>&nbsp; &nbsp; Width = 121<br>&nbsp; &nbsp; Height = 20<br>&nbsp; &nbsp; TabOrder = 1<br>&nbsp; end<br>&nbsp; object Edit3: TEdit<br>&nbsp; &nbsp; Left = 200<br>&nbsp; &nbsp; Top = 13<br>&nbsp; &nbsp; Width = 113<br>&nbsp; &nbsp; Height = 20<br>&nbsp; &nbsp; TabOrder = 2<br>&nbsp; end<br>end<br>object Memo2: TMemo<br>&nbsp; Left = 376<br>&nbsp; Top = 152<br>&nbsp; Width = 233<br>&nbsp; Height = 297<br>&nbsp; Lines.Strings = (<br>&nbsp; &nbsp; ' &nbsp;'#27880#24847#65306<br>&nbsp; &nbsp; ' &nbsp;'#35201#37197#21512'WS32.exe '#20351#29992#12290<br>&nbsp; &nbsp; ' &nbsp;'#25214#21040#25511#20214#31383#21475'ID'#26159#20851#38190#65292#26597#25214#26041#27861#20026#65306<br>&nbsp; &nbsp; ''<br>&nbsp; &nbsp; ' &nbsp;'#29616#20851#38381'WS32.exe'#20197#22806#25152#26377#31243#24207#12290<br>&nbsp; &nbsp; ' &nbsp;1'#12289#36873#20013'WS32.exe/Options/Controls '<br>&nbsp; &nbsp; ' &nbsp;2'#12289#36873#20013'Messages/Process/New Process'<br>&nbsp; &nbsp; ''<br>&nbsp; &nbsp; ' &nbsp;'#25171#24320'"'#20854#23427#31243#24207'".'#38543#20415#19979#25289#19968#20010'ComboBox'<br>&nbsp; &nbsp; #65292#30475<br>&nbsp; &nbsp; 'WS32.exe '#21738#37324#38378#21160#65292#38378#21160#30340#37027#20010#26641#26525#30340'ID'<br>&nbsp; &nbsp; #23601#26159#26412'ComboBox'#30340'ID'#12290)<br>&nbsp; TabOrder = 3<br>end<br>
 
文本的dfm应该是这样:<br>------------------<br>object Form1: TForm1<br>&nbsp; Left = 192<br>&nbsp; Top = 133<br>&nbsp; Width = 623<br>&nbsp; Height = 480<br>&nbsp; Caption = 'Form1'<br>&nbsp; Color = clBtnFace<br>&nbsp; Font.Charset = GB2312_CHARSET<br>&nbsp; Font.Color = clWindowText<br>&nbsp; Font.Height = -12<br>&nbsp; Font.Name = '宋体'<br>&nbsp; Font.Style = []<br>&nbsp; OldCreateOrder = False<br>&nbsp; PixelsPerInch = 96<br>&nbsp; TextHeight = 12<br>&nbsp; object GroupBox1: TGroupBox<br>&nbsp; &nbsp; Left = 376<br>&nbsp; &nbsp; Top = 16<br>&nbsp; &nbsp; Width = 225<br>&nbsp; &nbsp; Height = 121<br>&nbsp; &nbsp; Caption = '偷别人程序的控件用'<br>&nbsp; &nbsp; TabOrder = 0<br>&nbsp; &nbsp; object Button3: TButton<br>&nbsp; &nbsp; &nbsp; Left = 16<br>&nbsp; &nbsp; &nbsp; Top = 32<br>&nbsp; &nbsp; &nbsp; Width = 145<br>&nbsp; &nbsp; &nbsp; Height = 25<br>&nbsp; &nbsp; &nbsp; Caption = '借用其它程序ComboBox'<br>&nbsp; &nbsp; &nbsp; TabOrder = 0<br>&nbsp; &nbsp; &nbsp; OnClick = Button3Click<br>&nbsp; &nbsp; end<br>&nbsp; &nbsp; object Button4: TButton<br>&nbsp; &nbsp; &nbsp; Left = 18<br>&nbsp; &nbsp; &nbsp; Top = 74<br>&nbsp; &nbsp; &nbsp; Width = 123<br>&nbsp; &nbsp; &nbsp; Height = 25<br>&nbsp; &nbsp; &nbsp; Caption = '还其它程序ComboBox'<br>&nbsp; &nbsp; &nbsp; TabOrder = 1<br>&nbsp; &nbsp; &nbsp; OnClick = Button4Click<br>&nbsp; &nbsp; end<br>&nbsp; end<br>&nbsp; object GroupBox2: TGroupBox<br>&nbsp; &nbsp; Left = 24<br>&nbsp; &nbsp; Top = 8<br>&nbsp; &nbsp; Width = 337<br>&nbsp; &nbsp; Height = 329<br>&nbsp; &nbsp; Caption = '得到其它程序 ComboBox 内容'<br>&nbsp; &nbsp; TabOrder = 1<br>&nbsp; &nbsp; object Label1: TLabel<br>&nbsp; &nbsp; &nbsp; Left = 16<br>&nbsp; &nbsp; &nbsp; Top = 24<br>&nbsp; &nbsp; &nbsp; Width = 90<br>&nbsp; &nbsp; &nbsp; Height = 12<br>&nbsp; &nbsp; &nbsp; Caption = 'ComboBox窗口ID:'<br>&nbsp; &nbsp; end<br>&nbsp; &nbsp; object Button1: TButton<br>&nbsp; &nbsp; &nbsp; Left = 232<br>&nbsp; &nbsp; &nbsp; Top = 16<br>&nbsp; &nbsp; &nbsp; Width = 75<br>&nbsp; &nbsp; &nbsp; Height = 25<br>&nbsp; &nbsp; &nbsp; Caption = '列出内容'<br>&nbsp; &nbsp; &nbsp; TabOrder = 0<br>&nbsp; &nbsp; &nbsp; OnClick = Button1Click<br>&nbsp; &nbsp; end<br>&nbsp; &nbsp; object Memo1: TMemo<br>&nbsp; &nbsp; &nbsp; Left = 16<br>&nbsp; &nbsp; &nbsp; Top = 48<br>&nbsp; &nbsp; &nbsp; Width = 289<br>&nbsp; &nbsp; &nbsp; Height = 273<br>&nbsp; &nbsp; &nbsp; TabOrder = 1<br>&nbsp; &nbsp; end<br>&nbsp; &nbsp; object Edit1: TEdit<br>&nbsp; &nbsp; &nbsp; Left = 112<br>&nbsp; &nbsp; &nbsp; Top = 16<br>&nbsp; &nbsp; &nbsp; Width = 97<br>&nbsp; &nbsp; &nbsp; Height = 20<br>&nbsp; &nbsp; &nbsp; TabOrder = 2<br>&nbsp; &nbsp; end<br>&nbsp; end<br>&nbsp; object GroupBox3: TGroupBox<br>&nbsp; &nbsp; Left = 24<br>&nbsp; &nbsp; Top = 344<br>&nbsp; &nbsp; Width = 337<br>&nbsp; &nbsp; Height = 105<br>&nbsp; &nbsp; Caption = '给其它程序ComboBox 插入其它内容'<br>&nbsp; &nbsp; TabOrder = 2<br>&nbsp; &nbsp; object Label2: TLabel<br>&nbsp; &nbsp; &nbsp; Left = 96<br>&nbsp; &nbsp; &nbsp; Top = 21<br>&nbsp; &nbsp; &nbsp; Width = 90<br>&nbsp; &nbsp; &nbsp; Height = 12<br>&nbsp; &nbsp; &nbsp; Caption = 'ComboBox窗口ID:'<br>&nbsp; &nbsp; end<br>&nbsp; &nbsp; object Label3: TLabel<br>&nbsp; &nbsp; &nbsp; Left = 96<br>&nbsp; &nbsp; &nbsp; Top = 61<br>&nbsp; &nbsp; &nbsp; Width = 36<br>&nbsp; &nbsp; &nbsp; Height = 12<br>&nbsp; &nbsp; &nbsp; Caption = '内容:'<br>&nbsp; &nbsp; end<br>&nbsp; &nbsp; object Button2: TButton<br>&nbsp; &nbsp; &nbsp; Left = 8<br>&nbsp; &nbsp; &nbsp; Top = 16<br>&nbsp; &nbsp; &nbsp; Width = 75<br>&nbsp; &nbsp; &nbsp; Height = 25<br>&nbsp; &nbsp; &nbsp; Caption = '插入'<br>&nbsp; &nbsp; &nbsp; TabOrder = 0<br>&nbsp; &nbsp; &nbsp; OnClick = Button2Click<br>&nbsp; &nbsp; end<br>&nbsp; &nbsp; object Edit2: TEdit<br>&nbsp; &nbsp; &nbsp; Left = 198<br>&nbsp; &nbsp; &nbsp; Top = 53<br>&nbsp; &nbsp; &nbsp; Width = 121<br>&nbsp; &nbsp; &nbsp; Height = 20<br>&nbsp; &nbsp; &nbsp; TabOrder = 1<br>&nbsp; &nbsp; end<br>&nbsp; &nbsp; object Edit3: TEdit<br>&nbsp; &nbsp; &nbsp; Left = 200<br>&nbsp; &nbsp; &nbsp; Top = 13<br>&nbsp; &nbsp; &nbsp; Width = 113<br>&nbsp; &nbsp; &nbsp; Height = 20<br>&nbsp; &nbsp; &nbsp; TabOrder = 2<br>&nbsp; &nbsp; end<br>&nbsp; end<br>&nbsp; object Memo2: TMemo<br>&nbsp; &nbsp; Left = 376<br>&nbsp; &nbsp; Top = 152<br>&nbsp; &nbsp; Width = 233<br>&nbsp; &nbsp; Height = 297<br>&nbsp; &nbsp; Lines.Strings = (<br>&nbsp; &nbsp; &nbsp; ' &nbsp;注意:'<br>&nbsp; &nbsp; &nbsp; ' &nbsp;要配合WS32.exe 使用。'<br>&nbsp; &nbsp; &nbsp; ' &nbsp;找到控件窗口ID是关键,查找方法为:'<br>&nbsp; &nbsp; &nbsp; ''<br>&nbsp; &nbsp; &nbsp; ' &nbsp;现关闭WS32.exe以外所有程序。'<br>&nbsp; &nbsp; &nbsp; ' &nbsp;1、选中WS32.exe/Options/Controls '<br>&nbsp; &nbsp; &nbsp; ' &nbsp;2、选中Messages/Process/New Process'<br>&nbsp; &nbsp; &nbsp; ''<br>&nbsp; &nbsp; &nbsp; ' &nbsp;打开"其它程序".随便下拉一个ComboBox'<br>&nbsp; &nbsp; &nbsp; ',看'<br>&nbsp; &nbsp; &nbsp; 'WS32.exe 哪里闪动,闪动的那个树枝的ID'<br>&nbsp; &nbsp; &nbsp; '就是本ComboBox的ID。')<br>&nbsp; &nbsp; TabOrder = 3<br>&nbsp; end<br>end
 
to jlutt-sadan<br>这个多列ListBox不是用listview实现的。我知道发LB_GETTEXT消息可取得普通ListBox中的内容,但是就是无法取得多列ListBox中的内容
 
唉,难道真的这么难吗?
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部