这个功能主要是从其它程序上的edit控件上取得一个文本数据,符合条件后向该窗口另外一个控件上发送CTRL+H消息.在这里对大家先感谢吧,分放到80,小弟很菜,最好是有例子,多谢.

解决方案 »

  1.   

    Windows句柄、消息,请参考相关资料吧
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      h:  HWND;
      h1: HWND;
      n: Integer;
      buf: array[0..20] of char;
    begin
      h := FindWindow(PChar('TForm1'), PChar('RcvFrm')); // 获得主窗口
      h1 := FindWindowEx(h, 0, PChar('TEdit'), nil); // 获得第一个Edit框的句柄
                                                     
      n := 20;
      SendMessage(h1, WM_GETTEXT, n, LPARAM(@buf)); // 发送消息 获取内容  ShowMessage(buf);
    end;
      

  3.   

    procedure TForm1.Button3Click(Sender: TObject);
    var
      hw:Thandle;
      he: Thandle;
      s :pansichar;
    begin
      getmem(s,256);
      hw := findwindow('TForm2','Form2');
      he := findwindowex(hw,0,'TEdit','Edit1');
      getwindowtext(hw,s,256);
      showmessage(s);
      he := findwondowex(hw,0,'ComponentClassname','ComponentName');
      sendmessage(he,WM_KEYDOWN,VK_CONTROL,0);
      sendmessage(he,WM_KEYDOWN,Ord('H'),0);
      sendmessage(he,WM_KEYUP,Ord('H'),0);
      sendmessage(he,WM_KEYUP,VK_CONTROL,0);
    end;