Bonjour,
J'ai essayé avec "Sendmessage ()", mais "WM_COPYDATA" n'accepte pas les
UNICODES.
Dans le "PRESSE-PAPIER", je mets le contenu de "Edit1.txt" mais je ne trouve
pas de fonction qui me permet de faire un "PASTE" d'un texte dans un
"HANDLE" de fenêtre.
Je joins les sources du programme et dans l'attente de vos nouvelles
Je vous souhaite une bonne journée.
___________________________________________________________________
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComObj;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure Button1Click(Sender: TObject);
private
Function SendCommand(Cmd: String) : Boolean;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function TForm1.SendCommand(Cmd: String) : boolean;
var
cds: TCopyDataStruct;
wnd, sender : HWND;
pData : array [0..255] of char;
Acad : OleVariant;
Caption : String;
begin;
Acad := GetActiveOleObject('AutoCAD.Application');
Caption := Acad.Caption;
wnd := FindWindow(Nil, PChar(Caption));
sender := Application.Handle;
if wnd <> 0 then
begin
StrPCopy(pData, Cmd + #13);
pData[Length(Cmd)+1] := #0;
cds.dwData := 1;
cds.cbData := SizeOf(pData);
cds.lpData := @pData;
Result := SendMessage(wnd, WM_COPYDATA, Sender, LParam(@cds)) <> 0;
SetWindowText(WND,'CA MARCHE');
//SetActiveWindow(WND);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
If Edit1.Text <> '' then
SendCommand(Edit1.Text);
end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
IF KEY = chr(13) then Button1Click(Edit1);
end;
end.
___________________________________________________________________