Brucelee
asked on
Retreive a marked text
How can I get the text marked in MS Word, notepad etc.
Example...
I mark the word in .doc file with mouse, click the button in my delphi aplication (dictionary), and the aplication searches through database.
Example...
I mark the word in .doc file with mouse, click the button in my delphi aplication (dictionary), and the aplication searches through database.
Do you use Word as an OLE container ?
If you don't mind Copying the text, i.e., mark and type CTRL C,
you can use TClipboard by adding the unit Clipbrd in the uses clause and using the property AsText to get the marked text.
Here is an example that fills a edit text with a marked text in Word, Notepad, any Browsers, etc... :
>>>>>
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Clipbrd, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Clip : TClipboard;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
Clip := TClipBoard.Create;
end;
procedure TForm1.Button1Click(Sender : TObject);
begin
Edit1.Text := Clip.AsText;
end;
end.
I hope this helps ...
you can use TClipboard by adding the unit Clipbrd in the uses clause and using the property AsText to get the marked text.
Here is an example that fills a edit text with a marked text in Word, Notepad, any Browsers, etc... :
>>>>>
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Clipbrd, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Clip : TClipboard;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
Clip := TClipBoard.Create;
end;
procedure TForm1.Button1Click(Sender
begin
Edit1.Text := Clip.AsText;
end;
end.
I hope this helps ...
ASKER
The idea is OK. But I need it to be more automatic. CTRL C is the unwanted action that I want to step over.
Thanx, Slaven
Thanx, Slaven
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Further details are available should you need them.