-
Notifications
You must be signed in to change notification settings - Fork 4
/
MWebBrowser.hpp
225 lines (205 loc) · 6.85 KB
/
MWebBrowser.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
// MWebBrowser.cpp --- simple Win32 Web Browser
// Copyright (C) 2019 Katayama Hirofumi MZ <[email protected]>
// This file is public domain software.
#ifndef MWEB_BROWSER_HPP_
#define MWEB_BROWSER_HPP_ 13 // Version 13
#define INITGUID
#include <windows.h>
#include <exdisp.h>
#include <mshtml.h>
#include <mshtmhst.h>
class MWebBrowser :
public IOleClientSite,
public IOleInPlaceSite,
public IStorage,
public IServiceProvider,
public IHttpSecurity,
public IDocHostUIHandler
{
public:
static MWebBrowser *Create(HWND hwndParent);
RECT PixelToHIMETRIC(const RECT& rc);
HWND GetControlWindow();
HWND GetIEServerWindow();
void MoveWindow(const RECT& rc);
void GoHome();
void GoBack();
void GoForward();
void Stop();
void StopDownload();
void Refresh();
HRESULT Navigate(const WCHAR *url = L"about:blank");
HRESULT Navigate2(const WCHAR *url, DWORD dwFlags = 0);
void Print(BOOL bBang = FALSE);
void PrintPreview();
void PageSetup();
void Destroy();
BOOL TranslateAccelerator(LPMSG pMsg);
IWebBrowser2 *GetIWebBrowser2();
IHTMLDocument2 *GetIHTMLDocument2();
void AllowInsecure(BOOL bAllow);
HRESULT Quit();
HRESULT get_Application(IDispatch **ppApplication) const;
HRESULT get_LocationURL(BSTR *bstrURL) const;
HRESULT get_mimeType(BSTR *bstrMIME) const;
HRESULT put_Silent(VARIANT_BOOL bSilent);
BOOL is_busy() const;
HRESULT ZoomUp();
HRESULT ZoomDown();
HRESULT Zoom100();
HRESULT ZoomPercents(LONG percents);
// IUnknown interface
STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
// IOleWindow interface
STDMETHODIMP GetWindow(HWND *phwnd);
STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode);
// IOleInPlaceSite interface
STDMETHODIMP CanInPlaceActivate();
STDMETHODIMP OnInPlaceActivate();
STDMETHODIMP OnUIActivate();
STDMETHODIMP GetWindowContext(
IOleInPlaceFrame **ppFrame,
IOleInPlaceUIWindow **ppDoc,
LPRECT lprcPosRect,
LPRECT lprcClipRect,
LPOLEINPLACEFRAMEINFO lpFrameInfo);
STDMETHODIMP Scroll(SIZE scrollExtant);
STDMETHODIMP OnUIDeactivate(BOOL fUndoable);
STDMETHODIMP OnInPlaceDeactivate();
STDMETHODIMP DiscardUndoState();
STDMETHODIMP DeactivateAndUndo();
STDMETHODIMP OnPosRectChange(LPCRECT lprcPosRect);
// IOleClientSite interface
STDMETHODIMP SaveObject();
STDMETHODIMP GetMoniker(
DWORD dwAssign,
DWORD dwWhichMoniker,
IMoniker **ppmk);
STDMETHODIMP GetContainer(IOleContainer **ppContainer);
STDMETHODIMP ShowObject();
STDMETHODIMP OnShowWindow(BOOL fShow);
STDMETHODIMP RequestNewObjectLayout();
// IStorage interface
STDMETHODIMP CreateStream(
const OLECHAR *pwcsName,
DWORD grfMode,
DWORD reserved1,
DWORD reserved2,
IStream **ppstm);
STDMETHODIMP OpenStream(
const OLECHAR *pwcsName,
void *reserved1,
DWORD grfMode,
DWORD reserved2,
IStream **ppstm);
STDMETHODIMP CreateStorage(
const OLECHAR *pwcsName,
DWORD grfMode,
DWORD reserved1,
DWORD reserved2,
IStorage **ppstg);
STDMETHODIMP OpenStorage(
const OLECHAR *pwcsName,
IStorage *pstgPriority,
DWORD grfMode,
SNB snbExclude,
DWORD reserved,
IStorage **ppstg);
STDMETHODIMP CopyTo(
DWORD ciidExclude,
const IID *rgiidExclude,
SNB snbExclude,
IStorage *pstgDest);
STDMETHODIMP MoveElementTo(
const OLECHAR *pwcsName,
IStorage *pstgDest,
const OLECHAR *pwcsNewName,
DWORD grfFlags);
STDMETHODIMP Commit(DWORD grfCommitFlags);
STDMETHODIMP Revert();
STDMETHODIMP EnumElements(
DWORD reserved1,
void *reserved2,
DWORD reserved3,
IEnumSTATSTG **ppenum);
STDMETHODIMP DestroyElement(const OLECHAR *pwcsName);
STDMETHODIMP RenameElement(
const OLECHAR *pwcsOldName,
const OLECHAR *pwcsNewName);
STDMETHODIMP SetElementTimes(
const OLECHAR *pwcsName,
const FILETIME *pctime,
const FILETIME *patime,
const FILETIME *pmtime);
STDMETHODIMP SetClass(REFCLSID clsid);
STDMETHODIMP SetStateBits(DWORD grfStateBits, DWORD grfMask);
STDMETHODIMP Stat(STATSTG *pstatstg, DWORD grfStatFlag);
// IServiceProvider interface
STDMETHODIMP QueryService(
REFGUID guidService,
REFIID riid,
void **ppvObject);
// IWindowForBindingUI interface
STDMETHODIMP GetWindow(REFGUID rguidReason, HWND *phwnd);
// IHttpSecurity interface
STDMETHODIMP OnSecurityProblem(DWORD dwProblem);
// IDocHostUIHandler interface
STDMETHODIMP ShowContextMenu(
DWORD dwID,
POINT *ppt,
IUnknown *pcmdtReserved,
IDispatch *pdispReserved);
STDMETHODIMP GetHostInfo(DOCHOSTUIINFO *pInfo);
STDMETHODIMP ShowUI(
DWORD dwID,
IOleInPlaceActiveObject *pActiveObject,
IOleCommandTarget *pCommandTarget,
IOleInPlaceFrame *pFrame,
IOleInPlaceUIWindow *pDoc);
STDMETHODIMP HideUI();
STDMETHODIMP UpdateUI();
STDMETHODIMP EnableModeless(BOOL fEnable);
STDMETHODIMP OnDocWindowActivate(BOOL fActivate);
STDMETHODIMP OnFrameWindowActivate(BOOL fActivate);
STDMETHODIMP ResizeBorder(
LPCRECT prcBorder,
IOleInPlaceUIWindow *pUIWindow,
BOOL fRameWindow);
STDMETHODIMP TranslateAccelerator(
LPMSG lpMsg,
const GUID *pguidCmdGroup,
DWORD nCmdID);
STDMETHODIMP GetOptionKeyPath(LPOLESTR *pchKey, DWORD dw);
STDMETHODIMP GetDropTarget(
IDropTarget *pDropTarget,
IDropTarget **ppDropTarget);
STDMETHODIMP GetExternal(IDispatch **ppDispatch);
STDMETHODIMP TranslateUrl(
DWORD dwTranslate,
OLECHAR *pchURLIn,
OLECHAR **ppchURLOut);
STDMETHODIMP FilterDataObject(IDataObject *pDO, IDataObject **ppDORet);
protected:
LONG m_nRefCount;
HWND m_hwndParent;
HWND m_hwndCtrl;
HWND m_hwndIEServer;
IWebBrowser2 *m_web_browser2;
IOleObject *m_ole_object;
IOleInPlaceObject *m_ole_inplace_object;
IDocHostUIHandler *m_pDocHostUIHandler;
RECT m_rc;
HRESULT m_hr;
BOOL m_bAllowInsecure;
LONG m_nZoomPercents;
MWebBrowser(HWND hwndParent);
virtual ~MWebBrowser();
HRESULT CreateBrowser(HWND hwndParent);
BOOL IsCreated() const;
private:
MWebBrowser(const MWebBrowser&);
MWebBrowser& operator=(const MWebBrowser&);
};
#endif // ndef MWEB_BROWSER_HPP_