Nomadic советует:
[...]
... {$R HTMLdlg.res} ... procedure TForm1.ToolButton1Click(Sender: TObject); var Disp: IDispatch; Doc: IHTMLDocument2; Wnd: IHTMLWindow2; hr: HResult; hinstMSHTML: Longint; pfnShowHTMLDialog: SHOWHTMLDIALOGFN; szTemp: array [0..MAX_PATH-1] of Char; bstr: array [0..MAX_PATH-1] of WideChar; pmk: IMoniker; varArgs, varReturn: OleVariant; begin Disp:=IE4.Document; hr:=Disp.QueryInterface(IID_IHTMLDocument2, Doc); Disp._Release; if (hr=S_OK) then begin hinstMSHTML:=LoadLibrary('MSHTML.DLL'); if (hinstMSHTML>0) then begin pfnShowHTMLDialog:=GetProcAddress(hinstMSHTML, 'ShowHTMLDialog'); if Assigned(pfnShowHTMLDialog) then begin StrCopy(szTemp, 'res://'); GetModuleFileName(hInstance, szTemp + lstrlen(szTemp), Length(szTemp) - lstrlen(szTemp)); StrCat(szTemp, '/HTML_RESOURCE'); MultiByteToWideChar(CP_ACP, 0, szTemp, -1, bstr, length(bstr)); CreateUrlMoniker(nil, bstr, pmk); if Assigned(pmk) then begin Wnd:=Doc.Get_parentWindow; VarArgs:=VarArrayOf([Wnd, Doc, 'VARIANT']); varReturn:=Unassigned; hr:=pfnShowHTMLDialog(0, pmk, varArgs, nil, varReturn); //Wnd._Release; //pmk._Release; if SUCCEEDED(hr) then ShowMessage(varReturn); end; end; FreeLibrary(hinstMSHTML); end; // Doc._Release; end; end; [...] |
uses ActiveX; const CGID_FuckIE4: TGUID = '{ed016940-bd5b-11cf-ba4e-00c04fd70816}'; // UNDOCUMENTED CGID_MSHTML: TGUID = '{DE4BA900-59CA-11CF-9592-444553540000}'; // DOCUMENTED IE5+ IDM_FIND = 67; procedure TfWebReport.acReportFindExecute(Sender: TObject); var A, B: OleVariant; Target: IOleCommandTarget; OleCmd: TOLECMD; begin // wbMain - это TWebBrowser Target := wbMain.Document as IOLECommandTarget; with OleCmd do begin cmdId := IDM_FIND; cmdf := 0; end; Target.QueryStatus(@CGID_MSHTML, 1, @OleCmd, NIL); if (OleCmd.cmdf and OLECMDF_SUPPORTED) <> 0 then // We have IE5+ use documented manner Target.Exec(@CGID_MSHTML, IDM_FIND, OLECMDEXECOPT_DODEFAULT, A, B) else // We have not IE5+ :-(, use undocumented feature Target.Exec(@CGID_FuckIE4, 1, OLECMDEXECOPT_DODEFAULT, A, B); end; |
[001720]