2 Email : <lmathieson@optusnet.com.au>
4 This is prelimanary stuff - the controls need extra methods and events etc,
5 feel free to email with suggestions &/or patches.
7 Tested with wxWindows 2.3.2.
8 Built with MS Visual C++ 6.0 & DevStudio
9 Minor use of templates and STL
11 -----------------------------------------------------------
12 This sample illustrates using wxActiveX and wxIEHtmlWin too:
13 1. Host an arbitrary ActiveX control
14 1.1 - Capture and logging of all events from control
15 2. Specifically host the MSHTML Control
20 wxActiveX is used to host and siplay any activeX control, all the wxWindows developer
21 needs to know is either the ProgID or CLSID of the control in question.
34 - EVT_ACTIVEX(id, eventName, handler) (handler = void OnActiveX(wxActiveXEvent& event))
35 - EVT_ACTIVEX_DISPID(id, eventDispId, handler) (handler = void OnActiveX(wxActiveXEvent& event))
36 class wxActiveXEvent : public wxNotifyEvent
38 int ParamCount() const;
39 wxString ParamType(int idx);
40 wxString ParamName(int idx);
41 wxVariant operator[] (int idx) const; // parameter by index
42 wxVariant& operator[] (int idx);
43 wxVariant operator[] (wxString name) const; // named parameters
44 wxVariant& operator[] (wxString name);
49 wxActiveX::wxActiveX(wxWindow * parent, REFCLSID clsid, wxWindowID id = -1);
50 - Creates a activeX control identified by clsid
52 wxFrame *frame = new wxFrame(this, -1, "test");
53 wxActiveX *X = new wxActiveX(frame, CLSID_WebBrowser);
55 wxActiveX::wxActiveX(wxWindow * parent, wxString progId, wxWindowID id = -1);
56 - Creates a activeX control identified by progId
58 wxFrame *frame = new wxFrame(this, -1, "test");
59 wxActiveX *X = new wxActiveX(frame, "MSCAL.Calendar");
62 wxActiveX::~wxActiveX();
63 - Destroys the control
64 - disconnects all connection points
66 - int GetEventCount() const;
67 Number of events generated by control
69 - const FuncX& GetEvent(int idx) const;
70 Names, Params and Typeinfo for events
72 HRESULT wxActiveX::ConnectAdvise(REFIID riid, IUnknown *eventSink);
73 - Connects a event sink. Connections are automaticlly diconnected in the destructor
75 FS_DWebBrowserEvents2 *events = new FS_DWebBrowserEvents2(iecontrol);
76 hret = iecontrol->ConnectAdvise(DIID_DWebBrowserEvents2, events);
77 if (! SUCCEEDED(hret))
83 EVT_ACTIVEX(ID_MSHTML, "BeforeNavigate2", OnMSHTMLBeforeNavigate2X)
85 void wxIEFrame::OnMSHTMLBeforeNavigate2X(wxActiveXEvent& event)
87 wxString url = event["Url"];
89 int rc = wxMessageBox(url, "Allow open url ?", wxYES_NO);
92 event["Cancel"] = true;
98 wxIEHtmlWin is a specialisation of the wxActiveX control for hosting the MSHTML control.
109 wxIEHtmlWin::wxIEHtmlWin(wxWindow * parent, wxWindowID id = -1);
110 - Constructs and initialises the MSHTML control
111 - LoadUrl("about:blank") is called
113 wxIEHtmlWin::~wxIEHtmlWin();
114 - destroys the control
116 void wxIEHtmlWin::LoadUrl(const wxString&);
117 - Attempts to browse to the url, the control uses its internal (MS)
120 bool wxIEHtmlWin::LoadString(wxString html);
121 - Load the passed HTML string
123 bool wxIEHtmlWin::LoadStream(istream *strm);
124 - load the passed HTML stream. The control takes ownership of
125 the pointer, deleting when finished.
127 bool wxIEHtmlWin::LoadStream(wxInputStream *is);
128 - load the passed HTML stream. The control takes ownership of
129 the pointer, deleting when finished.
131 void wxIEHtmlWin::SetCharset(wxString charset);
132 - Sets the charset of the loaded document
134 void wxIEHtmlWin::SetEditMode(bool seton);
136 NOTE: This does work, but is bare bones - we need more events exposed before
137 this is usable as an HTML editor.
139 bool wxIEHtmlWin::GetEditMode();
140 - Returns the edit mode setting
142 wxString wxIEHtmlWin::GetStringSelection(bool asHTML = false);
143 - Returns the currently selected text (plain or HTML text)
145 wxString GetText(bool asHTML = false);
146 - Returns the body text (plain or HTML text)
149 Email : <lmathieson@optusnet.com.au>