如何取得窗体中某控件的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;

解决方案 »

  1.   

    hmemo1:=FindWindowEx(hparent,0,'RICHEDIT',nil);
      

  2.   

    to:xzhifei(星级饭桶(抵制日货)·飞)
    这段程序本身运行是成功的,我只是不清楚hmemo1:=GetDlgItem(hparent,$00000000);这段程序怎么是$00000000呢?因为在spy中并没有这个呀。
      

  3.   

    $00000000表示子控件在对话框控制中的id号,QQ里面那个增强型的RichEdit在对话框控制里的id永远都是0.
    Windows还提供了一个函数可以获得子控件的id,当然前提是知道子控件的句柄
    id = GetWindowLong(hwndCtrl,GWL_ID);