Home > Back-end >  In Delphi use webbrowser how to make web page written content?
In Delphi use webbrowser how to make web page written content?

Time:09-29

In Delphi use webbrowser how to make web page written content??

Thanks to reply:

CodePudding user response:

Get the IHTMLDocument2 interface, and then can get

CodePudding user response:

According to the not use idhttp. Get?

CodePudding user response:

May I ask:
//the problem when interacting with Delphi and web pages, and Internet explorer. The document has no value,
//to realize automatic function, point to print the agree button in the web page of examination and approval,

Var

Wnd: HWND;
WndChild: HWND;

Doc: IHtmlDocument2;
IE: iwebbrowser2;
All: IHtmlElementCollection;
HtmlElement: IHtmlElement;
Len, I: integer;
Item: OleVariant;

The begin
Wnd:=FindWindow (' IEFrame ', 'print approval - Windows Internet Explorer);
WndChild:=FindWindowEx (Wnd, 0, 'Frame Tab, nil);
WndChild:=FindWindowEx (WndChild, 0, 'TabWindowClass, nil);
WndChild:=FindWindowEX (WndChild, 0, 'Shell DocObject View', nil);
WndChild:=FindWindowEX (WndChild, 0, 'Internet Explorer_Server, nil);//handle to find 'Internet Explorer_Server' class

If WndChild & lt;> 0 then
The begin

GetIEFromHWnd (WndChild, IE);


If (IE & lt;> Nil) then
The begin

Doc:=IE. Document as IHtmlDocument2;//here will make a mistake, doc the resulting value is 0, ie is value, somehow,
//note: web pages is to complete the print function of examination and approval, is dynamically generated web page, asp are there in the address bar? , open the web site source code, there is all the code, and in the other a dynamic web page can be run when debugging,

All:=doc. Links;
Len:=all. Length;

//...
----------------------------------------------

CodePudding user response:

Their top once, don't in IE and a Frame below, here is the Document again?

CodePudding user response:

Search on the net to the following content: can you translate this into Delphi, head!!!!!!


///////////////////////////////////////////////////////////////
IHTMLDocument2 * GetDocFromFrame (IHTMLDocument2 * pDoc2)
{
CComPtrCComPtr
Hr=pDoc2 - & gt; QueryInterface (IID_IHTMLDocument3, (void * *) & amp; PDoc3);
If (hr==S_OK)
{
CComBSTR bstrName (" FRAME ");//CComBSTR bstrName (" IFRAME ");
CComPtr PElemCollFrame;
Hr=pDoc3 - & gt; The getElementsByTagName (bstrName, & amp; PElemCollFrame);
If (hr!=S_OK) return NULL;

Long pLength;
Hr=pElemCollFrame - & gt; Get_length (& amp; PLength);
If (hr!=S_OK) return NULL;

for(int i=0; I{
IDispatch * pDispFrame=NULL;
CComVariant vIndex=I;
Hr=pElemCollFrame - & gt; The item (vIndex vIndex, & amp; PDispFrame);
If (hr!=S_OK) continue;

CComPtr PElemFrame;
Hr=pDispFrame - & gt; QueryInterface (IID_IHTMLElement, (void * *) & amp; PElemFrame);
If (hr!=S_OK) continue;

CComPtrHr=pElemFrame - & gt; QueryInterface (IID_IHTMLFrameBase2, (void * *) & amp; PFrameBase2);
If (hr!=S_OK) continue;

CComPtrHr=pFrameBase2 - & gt; Get_contentWindow (& amp; PWindow2);
If (hr==S_OK)
{
Hr=pWindow2 - & gt; The get_document (& amp; PDoc2Frame);
If (hr==S_OK)
{
Return pDoc2Frame;
}
}
}
PDispFrame - & gt; Release ();
}
return NULL;
}

CodePudding user response:

Strange, it's not that. The OleObject. Document. The body. The innerText?
  • Related