How to change the HTML content of CPPWebBrowser under BCB

zhaozj2021-02-17  73

Void __fastcall tform1 :: sethtml (tcppWebBrowser * Webbrowser, Ansistring HTML) {istream * stream; hglobal hhtmltext; ipersiststreaminit * psi;

IF (webbrowser-> docuument == null) return; hhtmltext = GlobalAlloc (gptr, html.length () 1); if (0 == hhtmltext) {ShowMessage ("GlobalAlloc Error"; Return;}

CopyMemory (hhtmltext, html.c_str (), html.length ());

Olecheck (CreateStreamonhglobal (HHTMLText, True, & Stream);

Try {olecheck (WebBrowser-> Document-> queryinterface (__UUIDOF (iPersistStreaminit), (void **) & psi); try {olecheck (psi-> initnew ()); olecheck (psi-> load (stream));} Catch (...) {delete psi;}} catch (...) {delete stream; delete stream;

转载请注明原文地址:https://www.9cbs.com/read-31124.html

New Post(0)