求一段代码 关于sendmessage类似的! beginthread 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 就是 visual foxpro 数据库 如果手中有类似的例子是最好的 我想这跟语言无关,sendmessage的思路是对的,你可以先找到下拉框的句柄,再发送CB_ADDSTRING消息 SendMessage(下拉框句柄,CB_ADDSTRING,0,字符串); 各位达人,请看清我的问题!! 那个标题当时在提问的时候想的,没想到弄出差错了!我再重申一下我的问题吧!我只想求一段 用DELPHI 可以向另一个程序中的文本框、下拉框和子窗口中的文本框 等输入自己想要的信息这样一个小例子!就这么简单!! procedure postText(hWnd: HWND; Text: string); //文本框赋值var //Ret: LongInt; //mText: PChar; Buf: Integer;begin //GetMem(mText, Length(Text)); //StrCopy(mText, PChar(Text)); //try Buf := LongInt(pchar(Text)); sendMessage(hWnd, WM_SETTEXT, 0, Buf); sleep(20); //finally //FreeMem(mText,sizeof(text)); //end;end;procedure postText_cb(hWnd: HWND; Text: string); //组合框赋值var //Ret: LongInt; //mText: PChar; Buf: Integer;begin //GetMem(mText, Length(Text)); //StrCopy(mText, PChar(Text)); //try Buf := LongInt(pchar(Text)); //sendMessage(hWnd, CB_SELECTSTRING, -1, Buf); sendMessage(hWnd, CB_SELECTSTRING, -1, Buf); sleep(20); //finally //FreeMem(mText,sizeof(text)); //end;end; function EnumChildWindowsPro(Handle:HWND;ConInfor:LPARAM):boolean;stdcall; //遍历窗口 begin if not (Handle > 0) then begin result := false; exit; end; mypro[i_win]:=handle; i_win:=i_win+1;//转换参数 result := true; end; function FindControl(Parent:HWND;ClassName,ControlName:String):HWND;//方便调用EnumChildWindows函数var tConInfor:ControlInfor;begin tConInfor.ClassName:=ClassName; tConInfor.ControlName:=ControlName; EnumChildWindows(Parent,@EnumChildWindowsPro,LongInt(@tConInfor)); Result:=hControl;end;//数字function posttext2(mhd:hwnd;mstring:string):integer; //另一个文本框赋值函数var s:string; hd1:hwnd; ch: byte; i: Integer; pcText:array[0..254] of char;begin s:=mstring; hd1:=mhd; //全选文本框 //sendmessagea(hd1, EM_SETSEL, 0, -1); postmessagea(hd1, EM_SETSEL, 0, -1); Sleep(25); postmessagea(hd1, WM_CLEAR, 0, 0); Sleep(25); //开始发送 lstrcpy(pcText,PChar(s)); i := 0; while i<=254 do begin if pcText[i]<>#0 then begin ch := byte(pctext[i]); if Windows.IsDBCSLeadByte(ch) then begin postmessagea(hd1, WM_CHAR, ch, 0); Inc(i); sleep(20); postmessagea(hd1, WM_CHAR, byte(pctext[i]), 0); Sleep(20); end else postmessagea(hd1, WM_CHAR, Word(ch), 0); Sleep(20); Inc(i); end else break; end;result:=1;end;//文本赋值 与上面的区别在sendmessagea函数function posttext1(mhd:hwnd;mstring:string):integer;var s:string; hd1:hwnd; ch: byte; i: Integer; pcText:array[0..254] of char;begin s:=mstring; hd1:=mhd; //全选文本框 sendmessagea(hd1, EM_SETSEL, 0, -1); Sleep(25); sendmessagea(hd1, WM_CLEAR, 0, 0); Sleep(25); //开始发送 lstrcpy(pcText,PChar(s)); i := 0; while i<=254 do begin if pcText[i]<>#0 then begin ch := byte(pctext[i]); if Windows.IsDBCSLeadByte(ch) then begin sendmessagea(hd1, WM_CHAR, ch, 0); Inc(i); sleep(25); sendmessagea(hd1, WM_CHAR, byte(pctext[i]), 0); Sleep(25); end else sendmessagea(hd1, WM_CHAR, Word(ch), 0); Sleep(25); Inc(i); end else break; end;result:=1; end;//建议用前三个函数处理赋值。中间的两个函数用来遍历窗体。 参数没有默认值问题? 为什么我这样写也是错的? delphi 怎么实现 签名处显示个人公章 ME下D7做的程序XP下用不成吗? ADOConnection如何连接Sybase数据库,请教! 请问怎么实现在不同的分辨率下,打开的窗口界面一样大 简单问题__给双字赋值 逻辑分离中界面和业务单元是一对一的吗? 如何设置一个表的ID字段.急急急!!! 急:服务程序访问SQL数据库 delphi:在Caption属性前加标“&”号设立加速键,我并没有发觉有什么不同,加速到底指的是什么??? 帮翻译一段VC的代码,谢谢啊。
我再重申一下我的问题吧!我只想求一段 用DELPHI 可以向另一个程序中的文本框、下拉框和子窗口中的文本框 等输入自己想要的信息
这样一个小例子!
就这么简单!!
var
//Ret: LongInt;
//mText: PChar;
Buf: Integer;
begin
//GetMem(mText, Length(Text));
//StrCopy(mText, PChar(Text));
//try
Buf := LongInt(pchar(Text));
sendMessage(hWnd, WM_SETTEXT, 0, Buf);
sleep(20);
//finally
//FreeMem(mText,sizeof(text));
//end;
end;
procedure postText_cb(hWnd: HWND; Text: string); //组合框赋值
var
//Ret: LongInt;
//mText: PChar;
Buf: Integer;
begin
//GetMem(mText, Length(Text));
//StrCopy(mText, PChar(Text));
//try
Buf := LongInt(pchar(Text));
//sendMessage(hWnd, CB_SELECTSTRING, -1, Buf);
sendMessage(hWnd, CB_SELECTSTRING, -1, Buf);
sleep(20);
//finally
//FreeMem(mText,sizeof(text));
//end;
end;
function EnumChildWindowsPro(Handle:HWND;ConInfor:LPARAM):boolean;stdcall; //遍历窗口
begin
if not (Handle > 0) then
begin
result := false;
exit;
end;
mypro[i_win]:=handle;
i_win:=i_win+1;//转换参数 result := true; end; function FindControl(Parent:HWND;ClassName,ControlName:String):HWND;
//方便调用EnumChildWindows函数
var
tConInfor:ControlInfor;
begin
tConInfor.ClassName:=ClassName;
tConInfor.ControlName:=ControlName;
EnumChildWindows(Parent,@EnumChildWindowsPro,LongInt(@tConInfor));
Result:=hControl;
end;//数字
function posttext2(mhd:hwnd;mstring:string):integer; //另一个文本框赋值函数
var
s:string;
hd1:hwnd;
ch: byte;
i: Integer;
pcText:array[0..254] of char;
begin
s:=mstring;
hd1:=mhd;
//全选文本框
//sendmessagea(hd1, EM_SETSEL, 0, -1);
postmessagea(hd1, EM_SETSEL, 0, -1);
Sleep(25);
postmessagea(hd1, WM_CLEAR, 0, 0);
Sleep(25);
//开始发送
lstrcpy(pcText,PChar(s));
i := 0;
while i<=254 do
begin
if pcText[i]<>#0 then
begin
ch := byte(pctext[i]);
if Windows.IsDBCSLeadByte(ch) then
begin
postmessagea(hd1, WM_CHAR, ch, 0);
Inc(i);
sleep(20);
postmessagea(hd1, WM_CHAR, byte(pctext[i]), 0);
Sleep(20);
end
else
postmessagea(hd1, WM_CHAR, Word(ch), 0);
Sleep(20);
Inc(i);
end
else break;
end;
result:=1;
end;//文本赋值 与上面的区别在sendmessagea函数
function posttext1(mhd:hwnd;mstring:string):integer;
var
s:string;
hd1:hwnd;
ch: byte;
i: Integer;
pcText:array[0..254] of char;
begin
s:=mstring;
hd1:=mhd;
//全选文本框
sendmessagea(hd1, EM_SETSEL, 0, -1);
Sleep(25);
sendmessagea(hd1, WM_CLEAR, 0, 0);
Sleep(25);
//开始发送
lstrcpy(pcText,PChar(s));
i := 0;
while i<=254 do
begin
if pcText[i]<>#0 then
begin
ch := byte(pctext[i]);
if Windows.IsDBCSLeadByte(ch) then
begin
sendmessagea(hd1, WM_CHAR, ch, 0);
Inc(i);
sleep(25);
sendmessagea(hd1, WM_CHAR, byte(pctext[i]), 0);
Sleep(25);
end
else
sendmessagea(hd1, WM_CHAR, Word(ch), 0);
Sleep(25);
Inc(i);
end
else break;
end;
result:=1;
end;//建议用前三个函数处理赋值。中间的两个函数用来遍历窗体。