i need write windows application uses browser component in it. chose rad studio's c++ builder because have used in past, however, i'm not experienced in c++ programming in web-dev (i'm web-developer: js, php, etc...), so, encountered problems realization of project. hope, i'm missing basic c++ professional specialist solve quick thought.
built-in twebbroswer component has many disadvantages, made decision use chromium (https://github.com/hgourvest/dcef3). took time install , make work not in delphi, in c++ builder well, however, i've got project tchromium in form compiles , works fine @ moment: can navigate pages, execute js , more.
nevertheless, there 1 problem still cannot solve: accessing document's dom. in google search results found nothing helpful: 1 topic same problem , no answers (http://www.cyberforum.ru/cpp-builder/thread996496.html) , documentation.
in documentation has been said have use visitdom method purpose, have no idea how in c++ builder.
in c++ demo: https://code.google.com/p/chromiumembedded/source/browse/trunk/cef3/tests/cefclient/dom_test.cpp?r=689 see following code:
class clientdomvisitor : public cefdomvisitor { public: clientdomvisitor() { } virtual void visit(cefrefptr<cefdomdocument> document) override { // register click listener button. cefrefptr<cefdomnode> button = document->getelementbyid("button"); assert(button.get()); button->addeventlistener("click", new clientdomeventlistener(), false); } implement_refcounting(clientdomvisitor); }; then, in visitdom method:
visitdom(new clientdomvisitor) when i'm trying compile piece of code, errors occur (in c++ builder), such as:
[bcc32 error] unit1.cpp(184): e2303 type name expected later, i've tryied use advice topic (not domvisitor - stringvisitor, think, if make 1 of them work have no problems second one): https://groups.google.com/forum/#!msg/delphichromiumembedded/dckdckoclzw/-zguxoutxa4j written in delphi, i'm not sure if correctly translated code c++.
in unit1.h, i've added icefstringvisitor tform1 discussed , added visit method private declaration section:
class tform1 : public tform, icefstringvisitor { __published: // ide-managed components // ... i've hide part of code, nothing useful here ... tchromium *chromium1; void __fastcall chromium1beforebrowse(tobject *sender, const icefbrowser *browser, const icefframe *frame, const icefrequest *request, bool isredirect, bool result); void __fastcall chromium1loadend(tobject *sender, const icefbrowser *browser, const icefframe *frame, int httpstatuscode); private: // user declarations void __fastcall visit(const unicodestring str); public: // user declarations __fastcall tform1(tcomponent* owner); }; in unit1.cpp i've added:
void __fastcall tform1::visit(const unicodestring str) { showmessage(str); } void __fastcall tform1::chromium1loadend(tobject *sender, const icefbrowser *browser, const icefframe *frame, int httpstatuscode) { icefframe * ncframe = const_cast<icefframe *>(frame); // doesn't compile without const_cast ncframe->getsource(this); } this code compiles , runs, i'm getting error , application terminates:
pure virtual function called i'm tired struggling this. can experienced advice me how use of these visitdom, viewsource , other methods in rad studio c++ builder? in delpi, see, rather easy.
p.s. if somehow, in ceflib.hpp found following declaration:
__interface icefdomvisitor; typedef system::delphiinterface<icefdomvisitor> _di_icefdomvisitor; __interface interface_uuid("{8fd3d3a6-ea3a-4a72-8501-0276bd5c3d1d}") icefframe : public icefbase { public: virtual bool __fastcall isvalid(void) = 0 ; virtual void __fastcall undo(void) = 0 ; virtual void __fastcall redo(void) = 0 ; virtual void __fastcall cut(void) = 0 ; virtual void __fastcall copy(void) = 0 ; virtual void __fastcall paste(void) = 0 ; virtual void __fastcall del(void) = 0 ; virtual void __fastcall selectall(void) = 0 ; virtual void __fastcall viewsource(void) = 0 ; virtual void __fastcall getsource(const _di_icefstringvisitor visitor) = 0 ; virtual void __fastcall getsourceproc(const _di_tcefstringvisitorproc proc) = 0 ; virtual void __fastcall gettext(const _di_icefstringvisitor visitor) = 0 ; virtual void __fastcall gettextproc(const _di_tcefstringvisitorproc proc) = 0 ; virtual void __fastcall loadrequest(const _di_icefrequest request) = 0 ; virtual void __fastcall loadurl(const ustring url) = 0 ; virtual void __fastcall loadstring(const ustring str, const ustring url) = 0 ; virtual void __fastcall executejavascript(const ustring code, const ustring scripturl, int startline) = 0 ; virtual bool __fastcall ismain(void) = 0 ; virtual bool __fastcall isfocused(void) = 0 ; virtual ustring __fastcall getname(void) = 0 ; virtual __int64 __fastcall getidentifier(void) = 0 ; virtual _di_icefframe __fastcall getparent(void) = 0 ; virtual ustring __fastcall geturl(void) = 0 ; virtual _di_icefbrowser __fastcall getbrowser(void) = 0 ; virtual _di_icefv8context __fastcall getv8context(void) = 0 ; virtual void __fastcall visitdom(const _di_icefdomvisitor visitor) = 0 ; virtual void __fastcall visitdomproc(const _di_tcefdomvisitorproc proc) = 0 ; __property ustring name = {read=getname}; __property ustring url = {read=geturl}; __property _di_icefbrowser browser = {read=getbrowser}; __property _di_icefframe parent = {read=getparent}; };
Comments
Post a Comment