cs_bilal
Messages postés87Date d'inscriptiondimanche 2 février 2003StatutMembreDernière intervention 4 mars 2010
-
5 oct. 2007 à 00:19
cs_bilal
Messages postés87Date d'inscriptiondimanche 2 février 2003StatutMembreDernière intervention 4 mars 2010
-
7 oct. 2007 à 16:17
voici un code qui devrait fonctionner mais je suis bloqué a 2 lignes
je l'ai traduit pour le c++ builer 6, compilation 5/5
Exemple de récupération de Handle avec FindWindow et
FindWindowEx, et récupération de texte d'un Edit d'une
application externe
unit Unit1;
interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class (TForm)
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{------------------------------------------------------------
ATTENTION : S'il y a plusieurs instances de l'Explorateur ou
d'Internet Explorer, ce code prendra la première fenêtre dans
l'ordre Z, si l'on veut sélectionner la bonne fenêtre, il faut
utiliser un autre code
-------------------------------------------------------------}
//Récupération de l'URL en cours dans Internet Explorer
function GetCurrentInternetExplorerURL:string;
var Explorer,ClientWork,Toolbar,ComboBox,ComboBoxChild,Edit:HWND;
Mem:integer;
begin
//Retrouve le Handle de la fenêtre principale
Explorer: =FindWindow('IEFrame',nil);
if Explorer= 0 then
Result: =''
elsebegin
//Cherche le Handle de la fenêtre de travail
ClientWork:= FindWindowEx(Explorer,0,'WorkerA',nil);
if ClientWork =0 then
//Compatibilité XP / 98
ClientWork:= FindWindowEx(Explorer,0,'WorkerW',nil);
//Retrouve le Handle de la ToolBar
Toolbar:=FindWindowEx(ClientWork,0,'ReBarWindow32',nil);
//Cherche le Handle du ComboBox
ComboBox:=FindWindowEx(Toolbar,0,'ComboBoxEx32', nil);
ComboBoxChild:=FindWindowEx(ComboBox,0,'ComboBox',nil);
//Atteint l'Edit et envoie un message pour avoir le texte
Edit:=FindWindowEx(ComboBoxChild,0,'Edit',nil);
Mem:=SendMessage(Edit,WM_GETTEXTLENGTH,0,0)+1;
SetLength(Result,Mem);
//Envoi du message
SendMessage(Edit,WM_GETTEXT,Mem,Integer(@Result[1]));
end ;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption: = GetCurrentInternetExplorerURL;
end;
end.
tout est ok mais je n'obtient aucun resultat !!?
SetLength(Result,Mem);
//Envoi du message
SendMessage(Edit,WM_GETTEXT,Mem,Integer(@Result[1]));
j'ai traduit c'est 2 lignes mais toujours rien par :