得到其他窗口中一个 ListBox 的内容(200分)

  • 主题发起人 主题发起人 ap
  • 开始时间 开始时间
procedure TForm1.Timer1Timer(Sender: TObject);<br>var<br>&nbsp; cursorpoint:TagPOINT;<br>&nbsp; windowhandle:hwnd;<br>&nbsp; textmaxlength:integer;<br>&nbsp; textcontent:array[0..100] of char;<br>&nbsp; returnlength:word;<br>begin<br>&nbsp; textmaxlength:=100;<br>&nbsp; Memo2.lines.clear;<br>&nbsp; if GetCursorPos(cursorpoint) then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; Memo2.Lines.Add(format('光标位置x=%d,y=%d',[cursorpoint.x,cursorpoint.y]));<br>&nbsp; &nbsp; &nbsp; windowhandle:=windowfrompoint(cursorpoint);<br>&nbsp; &nbsp; &nbsp; if windowhandle&lt;&gt;null then<br>&nbsp; &nbsp; &nbsp; &nbsp; Memo2.Lines.Add(format('光标处窗口名柄号为%d',[windowhandle]));<br>&nbsp; &nbsp; &nbsp; if iswindow(windowhandle) then<br>&nbsp; &nbsp; &nbsp; &nbsp; returnlength:=SendMessage(windowhandle,WM_GETTEXT,textmaxlength,lparam(@textcontent));<br>&nbsp; &nbsp; &nbsp; if returnlength&gt;0 then<br>&nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Memo2.Lines.Add('读到窗口标题为:');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Memo2.Lines.Add(textcontent);<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; end;<br><br>end;
 
正好我也来学学啊
 
memo1.lines.text:=anotherform.listbox1.items.text;<br>搞掂
 
发送 LB_GETTEXT 消息可以得到结果。<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;From: BaKuBaKu
 
每一个带Form的单元,其TForm的后代类在private前声明的属性和方法均为Public的,<br>因此只要引用该Form所在单元,就可以用dedman所说的来取数据。
 
多人接受答案了。
 
后退
顶部