如何取得窗体中某控件的handle呢?下面这段程序是一个QQ的炸弹的主程序,其中
hmemo1:=GetDlgItem(hparent,$00000000);这句应该是得到输入字的memo控件的hwnd,而我用spy+查看到windows handle呢,是每次运行都在变化的,倒是有一个instance handle倒是不变的,但我用那个数值替换$00000000时,程序却得不到Handle,不知道为什么?这个hmemo1:=GetDlgItem(hparent,$00000000);中的$00400000倒底是要看哪个项呢????????
procedure TForm1.Button1Click(Sender: TObject);
begin
timer1.Enabled:=true;
end;procedure TForm1.Timer1Timer(Sender: TObject);
var hbutton,hbutton1,hmemo,hmemo1:HWND;
begin
repeat
hparent:=findwindowex(0,hparent,'#32770',nil);
hbutton:=findwindowEX(hparent,0,nil,'发送(&S)');
until hbutton<>0;
hbutton1:=findwindowex(hparent,0,nil,'聊天模式(&T)');
if hbutton1<>0 then
sendmessage(hbutton1,BM_CLICK,0,0);
hmemo1:=GetDlgItem(hparent,$00000000);
hmemo:=getwindow(hmemo1,GW_CHILD);
if hmemo<>0 then
begin
if checkbox1.Checked then
begin
if i>combobox1.Items.Count-1 then
i:=0;
edit1.Text:=combobox1.Items.Strings[i];
edit1.SelectAll;
edit1.CopyToClipboard;
sendmessage(hmemo,WM_SETTEXT,0,0);
sendmessage(hmemo,WM_PASTE,0,0);
sendmessage(hbutton,BM_CLICK,0,0);
i:=i+1;
end;
if checkbox1.Checked=false then
begin
edit1.Text:=combobox1.Text;
edit1.SelectAll;
edit1.CopyToClipboard;
sendmessage(hmemo,WM_SETTEXT,0,0);
sendmessage(hmemo,WM_PASTE,0,0);
sendmessage(hbutton,BM_CLICK,0,0);
end;
end;
end;
hmemo1:=GetDlgItem(hparent,$00000000);这句应该是得到输入字的memo控件的hwnd,而我用spy+查看到windows handle呢,是每次运行都在变化的,倒是有一个instance handle倒是不变的,但我用那个数值替换$00000000时,程序却得不到Handle,不知道为什么?这个hmemo1:=GetDlgItem(hparent,$00000000);中的$00400000倒底是要看哪个项呢????????
procedure TForm1.Button1Click(Sender: TObject);
begin
timer1.Enabled:=true;
end;procedure TForm1.Timer1Timer(Sender: TObject);
var hbutton,hbutton1,hmemo,hmemo1:HWND;
begin
repeat
hparent:=findwindowex(0,hparent,'#32770',nil);
hbutton:=findwindowEX(hparent,0,nil,'发送(&S)');
until hbutton<>0;
hbutton1:=findwindowex(hparent,0,nil,'聊天模式(&T)');
if hbutton1<>0 then
sendmessage(hbutton1,BM_CLICK,0,0);
hmemo1:=GetDlgItem(hparent,$00000000);
hmemo:=getwindow(hmemo1,GW_CHILD);
if hmemo<>0 then
begin
if checkbox1.Checked then
begin
if i>combobox1.Items.Count-1 then
i:=0;
edit1.Text:=combobox1.Items.Strings[i];
edit1.SelectAll;
edit1.CopyToClipboard;
sendmessage(hmemo,WM_SETTEXT,0,0);
sendmessage(hmemo,WM_PASTE,0,0);
sendmessage(hbutton,BM_CLICK,0,0);
i:=i+1;
end;
if checkbox1.Checked=false then
begin
edit1.Text:=combobox1.Text;
edit1.SelectAll;
edit1.CopyToClipboard;
sendmessage(hmemo,WM_SETTEXT,0,0);
sendmessage(hmemo,WM_PASTE,0,0);
sendmessage(hbutton,BM_CLICK,0,0);
end;
end;
end;
解决方案 »
- delphi 关于网页框架里的表单提交
- 请教P2P的打洞问题?
- 如何捕获DLL中的异常
- 这几个sql语句在delphi中怎么用?
- ShellTreeView的显示的问题,还望大家多多指教!
- 关于在dbgrid的一个单元格中显示别的控件
- 某市XX区XX镇工业分布系统----请教做过类似项目的大侠指点一二,谢谢!
- 怎么在弹出一个对话框时让声卡发出“咚”的一声响?
- Error:::::::Project AmeChinese.exe raised exeception class EInvalidPointer with message 'Invalid pointer operation'.
- 急!请给予提示!!
- 寻求编程高手!!。
- 小小问题
这段程序本身运行是成功的,我只是不清楚hmemo1:=GetDlgItem(hparent,$00000000);这段程序怎么是$00000000呢?因为在spy中并没有这个呀。
Windows还提供了一个函数可以获得子控件的id,当然前提是知道子控件的句柄
id = GetWindowLong(hwndCtrl,GWL_ID);