pour finir, j'ai fais cette solution, pas parfaite, mais suffisante:
Elle a le defaut de retourner les URL de tous les tab de la fenêtre.
URLs := getURLOwnerOfActiveX(_getParentHwnd())
function _getParentHwnd(): integer;
var c: TWinControl;
begin
c := self;
result := c.Handle;
while c.parent <> nil do begin
c := c.parent;
result := c.Handle;
end;
end;
uses
SHDocVw, strUtils, ActiveX, UIntList;
function getURLOwnerOfActiveX(aParentHWND : integer):TStringList;
// return The URL of the web page displaying the ActiveX Form
// aParentHWND: the Handle of the ActiveX Form. (NOT of the parent of the ActiveX Form)
//
// list all the (not local) URL (tab) of the browser showing the ActiveX.
// tested with IE: 6,7
var
SW: TShellWindows;
SWD: IDispatch;
WebBrowser: IWebbrowser2;
c: integer; //count
Handle : THandle;
WindowsTree : TIntList;
begin
result := TStringList.create;
//
// From the hanlde of the Form (ActiveX), we create the list of his parent.
//
// see http://msdn.microsoft.com/en-us/library/ms633510.aspx // (Diff. between parent and owner. Why we cannot use getParent() )
//
WindowsTree := TintList.Create();
try
//
// We list the windows using explorer. (local file or IE)
//
SW := TShellWindows.Create(nil);
try
//result.Add('WB Tree');
for c := 0 to SW.Count - 1 do //all shell windows
begin
SWD := SW.Item(c); //Get Interface Dispatch
if SWD = nil then Continue;
//if the windows is a IE browser
SWD.QueryInterface(iWebBrowser2, WebBrowser);
if (WebBrowser=nil) then continue;
//Browsing?
if WebBrowser.LocationURL = '' then Continue;
//Drop the Windows Explorer windows (local file)
if AnsiStartsText('file://',WebBrowser.LocationURL) then Continue;
//
// This browser is the parent of the ActiveX
//
if (WindowsTree.IndexOf(WebBrowser.HWND) >= 0) then begin
result.Add(WebBrowser.LocationURL); //Add URL form browser to list
end;
j'ai vu dans mon ProjectName_TLB.pas que l'implementation de mon ActiveForm descend de TOleControl (qui implement IOleClientSite) et non de TActiveForm.
Mais j'ignore comment je pourrait l'utiliser. (le getInterface ne me retourne pas de IOleClientSite) et de plus, l'implementation de TOleControl ne gère pas les paramètres (abstract implementation). Et je suis un peu perdu avec cette histoire de double déclaration de mon activeForm...
Loda
<hr size="2" width="100%" />Se poser les bonnes questions est le premier pas pour trouver les bonnes réponses.