unit quci;interfaceuses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, OleServer, XDICTGRB_TLB;type
    TForm1 = class(TForm,IXDictGrabSink)    mmo1: TMemo;
    GrabProxy1: TGrabProxy;procedure FormCreate(Sender: TObject);
private
{ Private declarations } 
public
{ Public declarations } 
function QueryWord(const WordString: WideString;lCursorX: Integer; 
lCursorY: Integer;const SentenceString: WideString;
var lLoc: Integer; var lStart: Integer): Integer; safecall; 
end; var 
Form1: TForm1; implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
GrabProxy1.GrabInterval :=1;
GrabProxy1.GrabMode :=XDictGrabMouse;
GrabProxy1.GrabEnabled :=true;
GrabProxy1.AdviseGrab(self); 
end;function TForm1.QueryWord(const WordString: WideString; lCursorX,
lCursorY: Integer; const SentenceString: WideString; var lLoc, 
lStart: Integer): Integer;
begin
mmo1.Text := mmo1.text+SentenceString+#13#10;
end;
end.我写了这一个小程序,做屏幕取词用的,在ie,txt都能生效,不过为什么在一个用VF做的软件就不能截取呢??是不是VF有特别的接口?

解决方案 »

  1.   

    網上有一個叫“GFDict.dll”的接口,你引用到自己的程序裡看看呢...procedure TMain_Frm.BitBtn3Click(Sender: TObject);
    begin
      Main_Frm.Hide;
      Frm_Mainfrm.Show;
      BitBtn1.Enabled:=True;
    end;procedure TMain_Frm.N1Click(Sender: TObject);
    var
       StrKye,StrHGpm:string;
    begin
       if ListView1.Selected<>nil then
       begin
           //Clipboard.AsText:=ListView1.Selected.Caption;
           strkye:=ListView1.Selected.Caption;
           StrHGpm:=ListView1.Selected.SubItems[0];
           Clipboard.AsText:=ListView1.Selected.Caption+ListView1.Selected.SubItems[0];
           SendMessage( ListView1.Selected.Handle,WM_COPY,0,0);
       end;
    end;procedure TMain_Frm.ListView1MouseDown(Sender: TObject;
      Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    var
      P: TPoint;
    begin
      if Button = mbright then
      begin
        GetCursorPos(p);
        PopupMenu1.Popup(p.X, p.Y);
      end;
    end;procedure TMain_Frm.N2Click(Sender: TObject);
    begin
      Memo1.CopyToClipboard;
      PopupMenu2.CleanupInstance;
      //Frm_ZiDianfrm.ShowModal;
      Frm_Mainfrm.N2.Click;
      //Memo1.PasteFromClipboard;
      //Clipboard.AsText:=Frm_ZiDianfrm.Edit1.Text;
    end;procedure TMain_Frm.Memo1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
      var
        P:TPoint;
    begin
       if Button=mbright then
       begin
           GetCursorPos(p);
           PopupMenu2.Popup(p.X,p.Y);
         end;
    end;
    ......
    end.
      

  2.   

    曾經給公司關務部編寫過一個基於中國海關品名的一個取詞程序,附上PP供LZ參考下......http://hi.csdn.net/attachment/201007/27/0_1280191490z55m.gif
      

  3.   

    我也做出了一个差不多的软件,不过先想表达的是不能再 Visual FoxPro 里面取词