📄 myie.h
字号:
#if !defined(AFX_MYIE_H__9D811CDD_CA05_4889_B0A0_5EFF05D1B0C0__INCLUDED_)
#define AFX_MYIE_H__9D811CDD_CA05_4889_B0A0_5EFF05D1B0C0__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "resource.h"
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Module Name: mainwnd.h
Abstract: Implements the main window, the container for the webbrowser
Functions:
Notes: This class implements the container and its interaction with the webbrowser control,
commandbar, statusbar etc.
--*/
#include "AddressBar.h"
#ifndef _MAINWND_H
#define _MAINWND_H_
#include "mshtmhst.h"
#include "interned.h"
//#include <Afxdisp.h>
#include <Exdisp.h>
#include "mydraw.h"
////////////for ime
#include <Sipapi.h>
#include <shellsdk.h>
#pragma comment(lib,"Aygshell.lib")
#define MAX_URL 2048
class CMainWnd :
public IOleContainer,
public IOleClientSite,
public IOleInPlaceSite,
public IServiceProvider,
public DWebBrowserEvents2,
public IDocHostUIHandler,
public IDocHostShowUI, // msgbox, help window
public IHTMLOMWindowServices // for window move, resize events
{
public:
CMainWnd();
~CMainWnd();
BOOL Create();
//IUnknown methods
STDMETHOD(QueryInterface) (REFIID riid, LPVOID * ppv)
{
if ((riid == IID_IOleContainer) || (riid == IID_IUnknown))
{
*ppv = (IOleContainer *) this;
}
else if (riid == IID_IOleClientSite)
{
*ppv = (IOleClientSite *)this;
}
else if (riid == IID_IOleInPlaceSite)
{
*ppv = (IOleInPlaceSite *)this;
}
else if (riid == IID_IOleWindow)
{
*ppv = (IOleWindow *)this;
}
else if ((riid == DIID_DWebBrowserEvents2) || (riid == IID_IDispatch))
{
*ppv = (DWebBrowserEvents2 *)this;
}
else if(riid == IID_IServiceProvider)
{
*ppv = (IServiceProvider *)this;
}
else if (riid == IID_IDocHostUIHandler)
{
*ppv = (IDocHostUIHandler *)this;
}
else if (riid == IID_IDocHostShowUI)
{
*ppv = (IDocHostShowUI *)this;
}
else if (riid == IID_IHTMLOMWindowServices)
{
*ppv = (IHTMLOMWindowServices *)this;
}
else
{
*ppv = NULL;
return E_NOINTERFACE;
}
AddRef();
return S_OK;
}
STDMETHOD_(ULONG, AddRef) (void)
{
InterlockedIncrement((LONG*)&_ulRefs);
return _ulRefs;
}
STDMETHOD_(ULONG, Release) (void)
{
ULONG ulRefs = _ulRefs;
if (InterlockedDecrement((LONG*)&_ulRefs) == 0)
{
delete this;
return 0;
}
return ulRefs - 1;
}
// IOleContainer methods
STDMETHOD(ParseDisplayName)(IBindCtx *, LPOLESTR, ULONG *, IMoniker **) { return E_NOTIMPL;}
STDMETHOD(EnumObjects)(DWORD, IEnumUnknown **)
{
return E_NOTIMPL;
}
STDMETHOD(LockContainer)(BOOL) { return S_OK;}
// IOleClientSite methods
STDMETHOD(SaveObject) (void) { return E_NOTIMPL;}
STDMETHOD(GetMoniker) (DWORD dwAssign, DWORD dwWhichMoniker, LPMONIKER * ppmk) { return E_NOTIMPL;}
STDMETHOD(GetContainer) (LPOLECONTAINER * ppContainer)
{
return E_NOINTERFACE;
}
STDMETHOD(ShowObject) (void) { return E_NOTIMPL;}
STDMETHOD(OnShowWindow) (BOOL fShow) { return E_NOTIMPL;}
STDMETHOD(RequestNewObjectLayout) (void) { return E_NOTIMPL;}
// IOleWindow methods
STDMETHOD(GetWindow)(HWND *phwnd)
{
*phwnd = _hWnd;
return S_OK;
}
STDMETHOD(ContextSensitiveHelp)(BOOL fEnterMode) { return E_NOTIMPL;}
// IOleInPlaceSite methods
STDMETHOD(CanInPlaceActivate) (void) { return S_OK;}
STDMETHOD(OnInPlaceActivate) (void)
{
_bInPlaceActive = TRUE;
return S_OK;
}
STDMETHOD(OnUIActivate) (void) { return E_NOTIMPL;}
STDMETHOD(GetWindowContext) (
LPOLEINPLACEFRAME FAR * lplpFrame,
LPOLEINPLACEUIWINDOW FAR * lplpDoc,
LPRECT lprcPosRect,
LPRECT lprcClipRect,
LPOLEINPLACEFRAMEINFO lpFrameInfo)
{
GetClientRect(_hWnd, lprcPosRect);
GetClientRect(_hWnd, lprcClipRect);
return S_OK;
}
STDMETHOD(Scroll) (SIZE scrollExtent) { return E_NOTIMPL;}
STDMETHOD(OnUIDeactivate) (BOOL fUndoable) { return E_NOTIMPL;}
STDMETHOD(OnInPlaceDeactivate) (void)
{
_bInPlaceActive = FALSE;
return S_OK;
}
STDMETHOD(DiscardUndoState) (void) { return E_NOTIMPL;}
STDMETHOD(DeactivateAndUndo) (void) { return E_NOTIMPL;}
STDMETHOD(OnPosRectChange) (LPCRECT lprcPosRect) { return E_NOTIMPL;}
// IServiceProvider
STDMETHOD(QueryService)(REFGUID guidService, REFIID riid, void **ppvObj)
{
if(guidService == IID_IHTMLOMWindowServices)
{
return QueryInterface(riid, ppvObj);
}
else
return E_FAIL;
}
//DWebBrowserEvents
//IDispatch methods
STDMETHOD(GetTypeInfoCount)(UINT FAR* pctinfo) { return E_NOTIMPL;}
STDMETHOD(GetTypeInfo)(UINT itinfo,LCID lcid,ITypeInfo FAR* FAR* pptinfo) { return E_NOTIMPL;}
STDMETHOD(GetIDsOfNames)(REFIID riid,OLECHAR FAR* FAR* rgszNames,UINT cNames,
LCID lcid, DISPID FAR* rgdispid) { return E_NOTIMPL;}
STDMETHOD(Invoke)(DISPID dispidMember,REFIID riid,LCID lcid,WORD wFlags,
DISPPARAMS FAR* pdispparams, VARIANT FAR* pvarResult,
EXCEPINFO FAR* pexcepinfo,UINT FAR* puArgErr);
// IDocHostUIHandler methods
STDMETHOD(EnableModeless)(BOOL fEnable) { return E_NOTIMPL; }
STDMETHOD(FilterDataObject)(IDataObject *pDO, IDataObject **ppDORet) { return E_NOTIMPL; }
STDMETHOD(GetDropTarget)(IDropTarget *pDropTarget, IDropTarget **ppDropTarget) { return E_NOTIMPL; }
STDMETHOD(GetExternal)(IDispatch **ppDispatch) { return E_NOTIMPL; }
STDMETHOD(GetHostInfo)(DOCHOSTUIINFO *pInfo);
STDMETHOD(GetOptionKeyPath)(LPOLESTR *pchKey, DWORD dw) { return E_NOTIMPL; }
STDMETHOD(HideUI)(void) { return E_NOTIMPL; }
STDMETHOD(OnDocWindowActivate)(BOOL fActivate) { return E_NOTIMPL; }
STDMETHOD(OnFrameWindowActivate)(BOOL fActivate) { return E_NOTIMPL; }
STDMETHOD(ResizeBorder)(LPCRECT prcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fFrameWindow) { return E_NOTIMPL; }
STDMETHOD(ShowContextMenu)(DWORD dwID, POINT *ppt, IUnknown *pcmdtReserved, IDispatch *pdispReserved) { return E_NOTIMPL; }
STDMETHOD(ShowUI)(DWORD dwID, IOleInPlaceActiveObject *pActiveObject,
IOleCommandTarget *pCommandTarget, IOleInPlaceFrame *pFrame,
IOleInPlaceUIWindow *pDoc) { return E_NOTIMPL; }
STDMETHOD(TranslateAccelerator)(LPMSG lpMsg, const GUID *pgudCmdGroup, DWORD nCmdID) { return E_NOTIMPL; }
STDMETHOD(TranslateUrl)(DWORD dwTranslate, OLECHAR *pchURLIn, OLECHAR **ppchURLOut) { return E_NOTIMPL; }
STDMETHOD(UpdateUI)(void) { return E_NOTIMPL; }
// IDocHostShowUI methods
STDMETHOD(ShowHelp)( HWND hwnd, LPOLESTR pszHelpFile, UINT uCommand,
DWORD dwData, POINT ptMouse, IDispatch *pDispatchObjectHit)
{ return E_NOTIMPL; }
STDMETHOD(ShowMessage)( HWND hwnd, LPOLESTR lpstrText, LPOLESTR lpstrCaption, DWORD dwType,
LPOLESTR lpstrHelpFile, DWORD dwHelpContext, LRESULT *plResult)
{
int res = MessageBox(hwnd, lpstrText, lpstrCaption, dwType);
if(plResult)
*plResult = res;
return S_OK;
}
// IHTMLOMWindowServices methods
STDMETHOD(moveTo)( LONG x, LONG y);
STDMETHOD(moveBy)( LONG x, LONG y);
STDMETHOD(resizeTo)( LONG x,LONG y);
STDMETHOD(resizeBy)( LONG x, LONG y);
public:
BOOL PreTranslateMessage(LPMSG pMsg);
VOID Close();
HWND GetWindow() { return _hWnd;}
LRESULT HandleCommand(WPARAM wParam, LPARAM lParam);
HANDLE hEvent;
IWebBrowser2 *_pBrowser;
static LRESULT CALLBACK MainWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
protected:
//Added for HTML Find Dialogs
HRESULT FindString();
VOID CMainWnd::ChangeFontSize(BOOL fInit);
BOOL RegisterMainWnd();
HWND CreateBrowser();
HRESULT Activate(IOleObject *pObject);
HRESULT InitEvents();
public:
LPTSTR _lpszUrl;
BOOL _fEmpty;
BOOL _fFullScreen;
RECT _rcWnd;
protected:
HACCEL _hAccelTbl; //a handle to the accelerator table
HWND _hWnd; //the main window
ULONG _ulRefs; //reference count for the interfaces supported by the container
HWND _hWndBrowser; //handle to the browser window
IOleObject *_pObject;
IConnectionPoint *_pCP;
IOleInPlaceActiveObject *_pIPActiveObj;
BOOL _bInPlaceActive;
DWORD _dwEventCookie;
TCHAR _szTitle[MAX_URL]; //title of the current document
RECT _rcProgress;
int _wZoom;
int _wDLCCounter;
BOOL _fShowStatusBar;
BOOL CreateCommandBar();
BOOL CreateIECommandBar(BOOL fCloseBox, TBBUTTON *tbBtns, int numButtons, long idMenu);
HWND _hWndStatus;
HWND _hWndProgress;
HWND _hWndCmdband;
HWND _hWndToolBar;
// HIMAGELIST _himlCmdBand;
HWND _hWndAddressCombo; //the combo box for typed urls
HWND _hWndAddressEdit; //the edit box of that combo box
VOID LoadTypedUrls();
VOID SaveUrlList(void);
BOOL _LoadBrowserHelperObjects(void);
VOID UpdateUrlList(LPCTSTR lpszUrl);
VOID SelChange();
static LRESULT CALLBACK AddressEditProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
BOOL _bTyped;
WNDPROC _lpfnAddressEditProc;
BOOL ShowStatusBar(BOOL fShow);
BOOL CreateStatusBar();
public:
short bShouldAuthor;
short bFirstTime;
CString m_szTitle;
CMyDraw m_draw;
int m_nURLType;
void DoNavigate();
void DoJump(IDispatch* pdoc);
void GetVersonInfo();
void OnWindowSize();
};
class CHtmlAnalyze
{
public:
CHtmlAnalyze();
virtual ~CHtmlAnalyze();
protected:
IDispatch* pDis;
protected:
IHTMLDocument2* GetDocument();
IHTMLElement* GetElement1(const char *id,const GUID iid=IID_IHTMLElement,BOOL bImg=0);
public:
IHTMLElement* GetElement(const char *id,const GUID iid=IID_IHTMLElement,BOOL bImg=0);
IHTMLInputHiddenElement* QueryInputHidden(const char* id);
IHTMLInputTextElement* QueryInputText(const char* id);
IHTMLImgElement* QueryImage(const char* id);
IHTMLTable* QueryTable(const char* id);
IHTMLButtonElement* QueryButton(const char* id);
IHTMLInputButtonElement* QueryInputButton(const char* id);
IHTMLFormElement* QueryForm(const char* id);
public:
void SetDocument(IDispatch*pdis);
};
#endif //_MAINWND_H_
#endif // !defined(AFX_MYIE_H__9D811CDD_CA05_4889_B0A0_5EFF05D1B0C0__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -