还是要各位高手赐教:(0分)

  • 主题发起人 主题发起人 netbug
  • 开始时间 开始时间
N

netbug

Unregistered / Unconfirmed
GUEST, unregistred user!
请看:<br>&nbsp;procedure ww(var w:TWMGettext);message wm_gettext;<br>&nbsp;....<br>enumwindowsproc=function (hnd:THandle;param:pointer):boolean;stdcall;<br>&nbsp;procedure TForm1.ww(var w:TWMGettext);<br>&nbsp;begin<br>&nbsp; form1.ListBox1.Items.Add(w.Text);<br>&nbsp;end;<br>&nbsp;function gettitle(hnd:THandle;param:pointer):boolean;stdcall;<br>&nbsp;begin<br>&nbsp;sendmessage(hnd,wm_gettext,0,0);<br>&nbsp;result:=true;<br>&nbsp;end;<br>procedure TForm1.Button1Click(Sender: TObject);<br>var i:integer;ewproc:enumwindowsproc;<br>begin<br>listbox1.Items.Clear;<br>ewproc:=gettitle;<br>i:=findwindow(nil,'Form2');//注意<br>enumchildwindows(i,@ewproc,0);<br>end;<br>我用此应用程序想去获得form2中的edit1中的字符串,没有成功,<br>后来我把i:=findwindow(nil,'Form2')改成i:=findwindow(nil,'Form1')<br>想去获得本应用程序的Edit1中的字符串,仍然没有成功,我该如何做呢?<br>还望各位高手不令赐教,我在此先给给位鞠躬了,谢谢大家!<br>
 
strS:=FORM2.EDIT1.text;<br>--------如果你以上的代码不是有其他特殊用途的话,<br>我建议你找几个入门的例子看看。 &nbsp;
 
to netbug:<br>&nbsp; 难道还没解决吗?好好看看前几篇帖子,针对不懂的问题发问。<br><br><br>最好不要重开,
 
a piece of code that view text in edit when you point cursor to it, hoping will solve your problem.<br><br>procedure TForm1.Timer1Timer(Sender: TObject);<br>var<br>pt: tpoint;<br>s,cln:string;<br>h1,h2 : HWND;<br>lc,ltext: pchar;<br>begin<br>&nbsp; getcursorpos(pt);<br>&nbsp; str(pt.x, s);<br>&nbsp; label1.caption:=s;<br>&nbsp; str(pt.y, s);<br>&nbsp; label2.caption:=s;<br>&nbsp; h1:=windowfrompoint(pt);<br>&nbsp; str(h1,s);<br>&nbsp; label3.caption:=s;<br>&nbsp; <br>&nbsp; try<br>&nbsp; getmem(lc,255 );<br>&nbsp; getclassname(h1, lc ,255);<br>&nbsp; label4.caption:=strpas(lc);<br>&nbsp; dispose(lc);<br>&nbsp; cln:=label4.caption;<br>&nbsp; if cln ='Edit' then<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; getmem(ltext,255);<br>&nbsp; &nbsp; sendmessage(h1,wm_gettext, 255, longint(ltext));<br>&nbsp; &nbsp; label5.caption:=strpas(ltext);<br>// &nbsp; &nbsp;dispose( ltext);<br>&nbsp; &nbsp;end;<br>&nbsp; except<br>&nbsp; end;<br>&nbsp; end;
 
Thank you everyone,I have succeed
 
后退
顶部