Use the Delphi development environment on the HTML interface to create

Source: Internet
Author: User

1 shdocvw_tlb is shdocvw. if no DLL Type Library is imported, change it to shdocvw (built-in Delphi), or select "Import Type Library" under the "project" menu ", in the displayed dialog box, select "Microsoft Internet controls" and click "create unit. But change the second webbrowser to webbrowser2. however, other projects will be replaced later.

2. Install embeddedwb_d2005_update12.zip, which includes ieconst and ieutil.

3. Install Zoc in the demo.

4. The installation path is the environment variable where the DCU path is added to Delphi.

 

Attached ZocCode:

Unit zocwebbrowser;

Interface

Uses
Variants,
Ieconst, ieutils, registry, windows, messages, sysutils, classes, graphics,
Controls, forms, dialogs, extctrls, olectrls, shdocvw_tlb,
ActiveX, shlobj, wininet, urlmon, shellapi, mshtml;

Type
// Zoc 2003-9-15 idochostuihandler
Tshowcontextmenuevent = function (const dwid: DWORD; const PPT: Ppoint;
Const pcmdtreserved: iunknown; const pdispreserved: idispatch): hresult of object;
Tgethostinfoevent = function (VAR pinfo: tdochostuiinfo): hresult of object;
Tshowuievent = function (const dwid: DWORD; const pactiveobject:
Ioleinplaceactiveobject;
Const pcommandtarget: iolecommandtarget; const pframe: ioleinplaceframe;
Const pdoc: ioleinplaceuiwindow): hresult of object;
Thideuievent = function: hresult of object;
Tupdateuievent = function: hresult of object;
Tenablemodelessevent = function (const fenable: bool): hresult of object;
Tondocwindowactivateevent = function (const factivate: bool): hresult of object;
Tonframewindowactivateevent = function (const factivate: bool): hresult of object;
Tresizeborderevent = function (const prcborder: prect;
Const puiwindow: ioleinplaceuiwindow;
Const framewindow: bool): hresult of object;
Ttranslateacceleratorevent = function (const lpmsg: PMSG; const pguid1_group: pguid;
Const ncmdid: DWORD): hresult of object;
Tgetoptionkeypathevent = function (VAR pchkey: polestr; const DW: DWORD): hresult
Object;
Tgetdroptargetevent = function (const pdroptarget: idroptarget;
Out ppdroptarget: idroptarget): hresult of object;
Tgetexternalevent = function (Out ppdispatch: idispatch): hresult of object;
Ttranslateurlevent = function (const dwtranslate: DWORD; const pchillin: polestr;
VaR ppchurchill: polestr): hresult of object;
Tfilterdataobjectevent = function (const PDO: idataobject;
Out ppdoret: idataobject): hresult of object;
// Zoc 2003-9-15 idochostuihandler

// Zoc 2003-9-15 idochostuihandler2
Tgetoverridekeypathevent = function (pchkey: polestr; DW: DWORD): hresult of object;
// Zoc 2003-9-15 idochostuihandler2

// Zoc 2003-9-15 idochostshowui
Tshowmessageevent = function (hwnd: thandle;
Lpstrtext: polestr; lpstrcaption: polestr; dwtype: longint; lpstrhelpfile: polestr;
Dwhelpcontext: longint; var plresult: lresult): hresult of object;
Tshowhelpevent = function (hwnd: thandle; pszhelpfile: polestr; ucommand: integer;
Dwdata: longint; ptmouse: tpoint;
VaR pdispatchobjecthit: idispatch): hresult of object;
// Zoc 2003-9-15 idochostshowui

Tzocwebbrowser = Class (twebbrowser2, idochostuihandler, idochostuihandler2,
Idochostshowui)
Private
// Zoc 2003-9-15 idochostuihandler
Fonenablemodeless: tenablemodelessevent;
Fonfilterdataobject: tfilterdataobjectevent;
Fongetdroptarget: tgetdroptargetevent;
Fongetexternal: tgetexternalevent;
Fongethostinfo: tgethostinfoevent;
Fongetoptionkeypath: tgetoptionkeypathevent;
Fonhideui: thideuievent;
Fonondocwindowactivate: tondocwindowactivateevent;
Fononframewindowactivate: tonframewindowactivateevent;
Fonresizeborder: tresizeborderevent;
Fonshowcontextmenu: tshowcontextmenuevent;
Fonshowui: tshowuievent;
Fontranslateaccelerator: ttranslateacceleratorevent;
Fontranslateurl: ttranslateurlevent;
Fonupdateui: tupdateuievent;
// Zoc 2003-9-15 idochostuihandler

// Zoc 2003-9-15 idochostuihandler2
Fongetoverridekeypath: tgetoverridekeypathevent;
// Zoc 2003-9-15 idochostuihandler2

// Zoc 2003-9-15 idochostshowui
Fonshowmessage: tshowmessageevent;
Fonshowhelp: tshowhelpevent;
// Zoc 2003-9-15 idochostshowui

Fuserinterfacevalue: Cardinal;
Fhelpfile: string;
Protected
{Protected Declarations}
// Zoc 2003-9-15 idochostuihandler
Function showcontextmenu (const dwid: DWORD; const PPT: Ppoint;
Const pcmdtreserved: iunknown; const pdispreserved: idispatch): hresult; stdcall;
Function gethostinfo (VAR pinfo: tdochostuiinfo): hresult; stdcall;
Function showui (const dwid: DWORD; const pactiveobject: ioleinplaceactiveobject;
Const pcommandtarget: iolecommandtarget; const pframe: ioleinplaceframe;
Const pdoc: ioleinplaceuiwindow): hresult; stdcall;
Function hideui: hresult; stdcall;
Function updateui: hresult; stdcall;
Function enablemodeless (const fenable: bool): hresult; stdcall;
Function ondocwindowactivate (const factivate: bool): hresult; stdcall;
Function onframewindowactivate (const factivate: bool): hresult; stdcall;
Function resizeborder (const prcborder: prect;
Const puiwindow: ioleinplaceuiwindow;
Const framewindow: bool): hresult; stdcall;
Function translateaccelerator (const lpmsg: PMSG; const pguid1_group: pguid;
Const n1_id: DWORD): hresult; stdcall;
Function getoptionkeypath (VAR pchkey: polestr; const DW: DWORD): hresult; stdcall;
Function getdroptarget (const pdroptarget: idroptarget;
Out ppdroptarget: idroptarget): hresult; stdcall;
Function getexternal (Out ppdispatch: idispatch): hresult; stdcall;
Function translateurl (const dwtranslate: DWORD; const pchillin: polestr;
VaR ppchurchill: polestr): hresult; stdcall;
Function filterdataobject (const PDO: idataobject;
Out ppdoret: idataobject): hresult; stdcall;
// Zoc 2003-9-15 idochostuihandler

// Zoc 2003-9-15 idochostuihandler2
Function getoverridekeypath (pchkey: polestr; DW: DWORD): hresult; stdcall;
// Zoc 2003-9-15 idochostuihandler2

// Zoc 2003-9-15 idochostshowui
Function showmessage (hwnd: thandle;
Lpstrtext: polestr; lpstrcaption: polestr; dwtype: longint; lpstrhelpfile: polestr;
Dwhelpcontext: longint; var plresult: lresult): hresult; stdcall;
Function showHelp (hwnd: thandle; pszhelpfile: polestr; ucommand: integer;
Dwdata: longint; ptmouse: tpoint;
VaR pdispatchobjecthit: idispatch): hresult; stdcall;
// Zoc 2003-9-15 idochostshowui

Public
{Public declarations}
Published
{Published Declarations}
Property helpfile: String read fhelpfile write fhelpfile;
// Zoc 2003-9-15 idochostuihandler
Property onshowcontextmenu: tshowcontextmenuevent read fonshowcontextmenu write
Fonshowcontextmenu;
Property ongethostinfo: tgethostinfoevent read fongethostinfo write fongethostinfo;
Property onshowui: tshowuievent read fonshowui write fonshowui;
Property onhideui: thideuievent read fonhideui write fonhideui;
Property onupdateui: tupdateuievent read fonupdateui write fonupdateui;
Property onenablemodeless: tenablemodelessevent read fonenablemodeless write
Fonenablemodeless;
Property onondocwindowactivate: tondocwindowactivateevent read fonondocwindowactivate
Write fonondocwindowactivate;
Property ononframewindowactivate: tonframewindowactivateevent read
Fononframewindowactivate write fononframewindowactivate;
Property onresizeborder: tresizeborderevent read fonresizeborder write
Fonresizeborder;
Property ontranslateaccelerator: ttranslateacceleratorevent read
Fontranslateaccelerator write fontranslateaccelerator;
Property ongetoptionkeypath: tgetoptionkeypathevent read fongetoptionkeypath write
Fongetoptionkeypath;
Property ongetdroptarget: tgetdroptargetevent read fongetdroptarget write
Fongetdroptarget;
Property ongetexternal: tgetexternalevent read fongetexternal write fongetexternal;
Property ontranslateurl: ttranslateurlevent read fontranslateurl write
Fontranslateurl;
Property onfilterdataobject: tfilterdataobjectevent read fonfilterdataobject write
Fonfilterdataobject;
// Zoc 2003-9-15 idochostuihandler

// Zoc 2003-9-15 idochostuihandler2
Property ongetoverridekeypath: tgetoverridekeypathevent read fongetoverridekeypath write fongetoverridekeypath;
// Zoc 2003-9-15 idochostuihandler2

// Zoc 2003-9-15 idochostshowui
Property onshowmessage: tshowmessageevent read fonshowmessage write fonshowmessage;
Property onshowhelp: tshowhelpevent read fonshowhelp write fonshowhelp;
// Zoc 2003-9-15 idochostshowui
End;

Procedure register;

Implementation

VaR
Saved8087cw: word;

// Zoc 2003-9-15 idochostuihandler

Function tzocwebbrowser. showcontextmenu (const dwid: DWORD; const PPT: Ppoint;
Const pcmdtreserved: iunknown; const pdispreserved: idispatch): hresult;
Begin
If assigned (fonshowcontextmenu) then
Result: = fonshowcontextmenu (dwid, PPT,
Pcmdtreserved, pdispreserved)
Else
Result: = s_false;
End;

Function tzocwebbrowser. gethostinfo (VAR pinfo: tdochostuiinfo): hresult;
Begin
Pinfo. cbsize: = sizeof (pinfo );
Pinfo. dwflags: = fuserinterfacevalue;
Pinfo. dwdoubleclick: = dochostuidblclk_default;
If assigned (fongethostinfo) then
Result: = fongethostinfo (pinfo)
Else
Result: = s_ OK;
End;

Function tzocwebbrowser. showui (const dwid: DWORD;
Const pactiveobject: ioleinplaceactiveobject;
Const pcommandtarget: iolecommandtarget; const pframe: ioleinplaceframe;
Const pdoc: ioleinplaceuiwindow): hresult;
Begin
If assigned (fonshowui) then
Result: = fonshowui (dwid, pactiveobject, pcommandtarget, pframe, pdoc)
Else
Result: = s_false;
End;

Function tzocwebbrowser. hideui: hresult;
Begin
If assigned (fonhideui) then
Result: = fonhideui
Else
Result: = s_false;
End;

Function tzocwebbrowser. updateui: hresult;
Begin
If assigned (fonupdateui) then
Result: = fonupdateui
Else
Result: = s_false;
End;

Function tzocwebbrowser. enablemodeless (const fenable: bool): hresult;
Begin
If assigned (fonenablemodeless) then
Result: = fonenablemodeless (fenable)
Else
Result: = s_false;
End;

Function tzocwebbrowser. ondocwindowactivate (const factivate: bool): hresult;
Begin
If assigned (fonondocwindowactivate) then
Result: = fonondocwindowactivate (factivate)
Else
Result: = s_false;
End;

Function tzocwebbrowser. onframewindowactivate (const factivate: bool): hresult;
Begin
If assigned (fononframewindowactivate) then
Result: = fononframewindowactivate (factivate)
Else
Result: = s_false;
End;

Function tzocwebbrowser. resizeborder (const prcborder: prect;
Const puiwindow: ioleinplaceuiwindow; const framewindow: bool): hresult;
Begin
If assigned (fonresizeborder) then
Result: = fonresizeborder (prcborder, puiwindow, framewindow)
Else
Result: = s_false;
End;

Function tzocwebbrowser. translateaccelerator (const lpmsg: PMSG;
Const pguid1_group: pguid; const n1_id: DWORD): hresult;
Begin
If assigned (fontranslateaccelerator) then
Result: = fontranslateaccelerator (lpmsg, pguid1_group, n1_id)
Else
Result: = s_false;
End;

Function tzocwebbrowser. getoptionkeypath (VAR pchkey: polestr; const DW: DWORD): hresult;
Begin
If assigned (fongetoptionkeypath) then
Result: = fongetoptionkeypath (pchkey, DW)
Else
Result: = s_false;
End;

Function tzocwebbrowser. getdroptarget (const pdroptarget: idroptarget;
Out ppdroptarget: idroptarget): hresult;
Begin
If assigned (fongetdroptarget) then
Result: = fongetdroptarget (pdroptarget, ppdroptarget)
Else
Result: = s_ OK;
End;

Function tzocwebbrowser. getexternal (Out ppdispatch: idispatch): hresult;
Begin
If assigned (fongetexternal) then
Result: = fongetexternal (ppdispatch)
Else
Result: = s_false;
End;

Function tzocwebbrowser. translateurl (const dwtranslate: DWORD;
Const pchurch Lin: polestr; var ppchurch lout: polestr): hresult;
Begin
If assigned (fontranslateurl) then
Result: = fontranslateurl (dwtranslate, pchillin, ppchillout)
Else
Result: = s_false;
End;

Function tzocwebbrowser. filterdataobject (const PDO: idataobject;
Out ppdoret: idataobject): hresult;
Begin
If assigned (fonfilterdataobject) then
Result: = fonfilterdataobject (PDO, ppdoret)
Else
Result: = s_false;
End;

// Zoc 2003-9-15 idochostuihandler

// Zoc 2003-9-15 idochostuihandler2

Function tzocwebbrowser. getoverridekeypath (pchkey: polestr;
DW: DWORD): hresult;
Begin
If assigned (fongetoverridekeypath) then result: = fongetoverridekeypath (pchkey, DW) else
Result: = s_ OK;
End;

// Zoc 2003-9-15 idochostuihandler2

// Zoc 2003-9-15 idochostshowui
Function tzocwebbrowser. showmessage (hwnd: thandle; lpstrtext: polestr;
Lpstrcaption: polestr; dwtype: longint; lpstrhelpfile: polestr;
Dwhelpcontext: longint; var plresult: lresult): hresult;
Begin
If assigned (fonshowmessage) then
Result: = fonshowmessage (hwnd, lpstrtext, lpstrcaption, dwtype, lpstrhelpfile, dwhelpcontext, plresult) else
Result: = s_false;
End;

Function tzocwebbrowser. showHelp (hwnd: thandle; pszhelpfile: polestr;
Ucommand: integer; dwdata: longint; ptmouse: tpoint;
VaR pdispatchobjecthit: idispatch): hresult;
Begin
Result: = s_ OK;
If assigned (fonshowhelp) then
Result: = fonshowhelp (hwnd, pszhelpfile, ucommand, dwdata, ptmouse, pdispatchobjecthit) else
If fhelpfile <> ''then htmlhelp (hwnd, pchar (fhelpfile), ucommand, dwdata) else
Result: = s_false;
End;

// Zoc 2003-9-15 idochostshowui

Procedure register;
Begin
Registercomponents ('eoc ', [tzocwebbrowser]);
End;

Initialization
Saved8087cw: = default8087cw;
{$ Ifdef ver120}
Bmsghandler: = false;
{$ Endif}
Oleinitialize (NiL );
Finalization
Set8087cw (saved8087cw );
Try
Oleuninitialize;
Else t end;

End.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.