先谢谢:)
这里有一个对方的程序,可以通过spy++得到窗口中文本框的句柄,文本框似乎是对方自己写的类,继承于edit,不清楚是用什么语言做的。
请问通过什么方式可以得到文本框的内容,并且如何设置文本框的内容。
ps:我的操作系统是win2000.
如果有例子就最好了,谢谢咯。
这里有一个对方的程序,可以通过spy++得到窗口中文本框的句柄,文本框似乎是对方自己写的类,继承于edit,不清楚是用什么语言做的。
请问通过什么方式可以得到文本框的内容,并且如何设置文本框的内容。
ps:我的操作系统是win2000.
如果有例子就最好了,谢谢咯。
解决方案 »
- TcxDateEdit格式问题
- delphi高手们,帮帮忙吧,我快疯了。。。续
- DELPHI求救主从档的作业明细不能保存
- 用image.Canvas绘画黑线,image自动填充为白色,如何绘画出白线黑底,
- 請幫忙看一下這樣的代碼,高手指點!
- 在Delphi中,用什么函数得到一个字符的ASCII码
- 简单问题
- 我在用SQL server建一个数据库为:mei331后,我用ADOconnection来连,可出来错误了请看
- dephi:indexfieldnames的使用疑问?
- 各位大虾,求助。。。
- 100分在线等待给分,数据更新简单问题
- “Error Loading midas.dll”是什么原因?
下面的代码是把IE地址栏的URL拿到自己的Delphi程序Memo上:unit Unit1;interface{
Copy the content of the Internet Explorer address Bar (the URL) The API function GetWindowText do not returns the text entered in an Edit
box. We have to use another way to do that. In this case, I used the ClipBoar
as a 'middleware' to transfer the text among IE and this app. This app was created using the IE 5.5. If the IE object names of your version
are not the same as used here, then use the WinSight32 to locate the correct
names. Copyright?2001 DelphiBahia
Hugo Novaes
www.delphibahia.eti.br
[email protected]
}uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
end;var
Form1: TForm1;implementation{$R *.DFM}//Copy the text from the IE Address Bar Edit box.
function GetIEEditText(wnd: THandle; Param: Integer): Bool; stdcall;
var
wndClass: array[0..127] of char;
pc : Array [0..255] of char;
begin
//Get the object class name.
GetClassName(wnd, wndClass, SizeOf(wndClass));
//Is the desired object?
if wndClass = 'Edit' then
begin
SendMessage(wnd, EM_SETSEL, 0, -1); //Select the whole text.
SendMessage(wnd, WM_COPY, 0, 0); //Copy it to the ClipBoard.
SendMessage(Param, WM_PASTE, 0, 0); //Paste from the ClipBoard to the Memo1.
SendMessage(Param, WM_CHAR, 13, 0); //Send ENTER to the Memo1.
Result := False; //Stop searching.
end else
Result := True; //Continue searching.
end;//Searches the ComboBox where the edit box is on.
function GetIEAddres(wnd: THandle; Param: Integer): Bool; stdcall;
var
wndClass: array[0..127] of char;
begin
//Get the object class name.
GetClassName(wnd, wndClass, SizeOf(wndClass));
//Is the desired object?
if wndClass = 'ComboBoxEx32' then
begin
EnumChildWindows(wnd, @GetIEEditText, Param); //Enum the child objects.
Result := False; //Stop searching.
end else
Result := True; //Continue searching.
end;//Searchs the Internet Explorer.
function FindIExplorer(wnd: THandle; Param: Integer): Bool; stdcall;
var
wndClass: array[0..127] of char;
begin
//Get the object class name.
GetClassName(wnd, wndClass, SizeOf(wndClass));
//Is the Internet Explorer main form?
if wndClass = 'IEFrame' then
EnumChildWindows(wnd, @GetIEAddres, Param); //Enum the child objects.
Result := True; //Continue searching other IExplorer windows.
end;procedure TForm1.Button1Click(Sender: TObject);
begin
//Enum all the Windows's windows. The LParam is the memo's handle.
EnumWindows(@FindIExplorer, Memo1.Handle);
end;end.
谢谢
或者哪里有相关书籍?
a:array[0..254] of char ;
若能找到这个文本框句柄 h,则 Getwindowtext(h,a,255);