⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myie.cpp

📁 wince42 开发的IE, 640X480, xscale平台,没有实现flash插件
💻 CPP
📖 第 1 页 / 共 5 页
字号:
// myie.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "myie.h"
#include <commctrl.h>

#include "..\comm\urldef.h"

/////////////mod by ljf
const TBBUTTON s_tbBtns[] = 
{  
	{6, ID_FOCUS_URL, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
	{0, ID_GO_BACK, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},    
    {1, ID_GO_FORWARD, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
    {2, ID_VIEW_STOP, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
    {3, ID_VIEW_REFRESH, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
    {0, IDC_STATIC, 0, TBSTYLE_SEP, 0, 0, 0, -1},
    {7, ID_FIND, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
    {4, ID_GO_HOME, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
    {5, ID_INTERNET_OPTIONS, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
	{0, IDC_STATIC, 0, TBSTYLE_SEP, 0, 0, 0, -1},
	{0, IDC_STATIC, 0, TBSTYLE_SEP, 0, 0, 0, -1},
	{8, ID_CLOSE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
};

const int s_iBtns = sizeof(s_tbBtns)/sizeof(TBBUTTON);

static TCHAR szTypedUrls[] = _T("Software\\Microsoft\\Internet Explorer\\TypedURLs");

#define MAXURLS         25
#define ID_COMBOEDIT        1001        //ID for the edit box of a combo box
#define PROGRESSPANEWIDTH  100
#define MESSAGEPANEWIDTH    100
#define ICONPANEWIDTH           20
#define SECURITYPANEWIDTH        40

// command bar
#define ID_BAND_CMD				20
#define ID_BAND_TOOL				21
#define ID_BAND_ADDR				22
#define ID_ADDRESSBAR				23
#define ID_COMMANDBAND				25
#define ID_STATUSBAR                            26
// bitmaps
#define IDB_ANIMATION                   106
#define IDB_FAVIMG                          107

//#include "..\comm\HeadCtrl.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.cpp

Abstract:  Implements the main window, the container for the webbrowser

Functions:

Notes: Most of the code resides here. The container and its interaction with the webbrowser control,
        commandbar, statusbar etc.


--*/
#include <windows.h>
// Include the automation definitions...
#include <exdisp.h>
#include <exdispid.h>
#include <mshtmdid.h> // AMBIENT_DLCONTROL

#include <objbase.h>

#include <tchar.h>

#include <wininet.h>
#include <afdfunc.h>	//ras stuff
//#include "pkfuncs.h"	// GetOwnerProcess
#include <mshtml.h>
#include <commctrl.h>
#include <commdlg.h>
#include "myie.h"
#include "resource.h"

#define INITGUID
#include "initguid.h"
//#include <hshell.h>

//#define START_FULLSCREEN // Remove this if you don't want IESIMPLE to be full-screen at startup mod ljf 1

DEFINE_GUID(CLSID_WebBrowser,       0x8856F961L, 0x340A, 0x11D0, 0xA9, 0x6B, 0x00, 0xC0, 0x4F, 0xD7, 0x05, 0xA2);
DEFINE_GUID(IID_IWebBrowser,        0xEAB22AC1L, 0x30C1, 0x11CF, 0xA7, 0xEB, 0x00, 0x00, 0xC0, 0x5B, 0xAE, 0x0B);
DEFINE_GUID(IID_IWebBrowser2,       0xD30C1661L, 0xCDAF, 0x11D0, 0x8A, 0x3E, 0x00, 0xC0, 0x4F, 0xC9, 0xE2, 0x6E);
DEFINE_GUID(DIID_DWebBrowserEvents, 0xEAB22AC2L, 0x30C1, 0x11CF, 0xA7, 0xEB, 0x00, 0x00, 0xC0, 0x5B, 0xAE, 0x0B);
DEFINE_GUID(DIID_DWebBrowserEvents2, 0x34A715A0L, 0x6587, 0x11D0, 0x92, 0x4A, 0x00, 0x20, 0xAF, 0xC7, 0xAC, 0x4D);
DEFINE_GUID(IID_IWebBrowserApp,     0x0002DF05L, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);

const GUID SID_SDocHost = { 0xc6504990, 0xd43e, 0x11cf, { 0x89, 0x3b, 0x00, 0xaa, 0x00, 0xbd, 0xce, 0x1a}};

#define MAX(a,b)  (a > b) ? a : b
#define MIN(a,b)  (a > b) ? b : a

LONG        glThreadCount	= 0;
HWND		ghWndAddressEdit= NULL;
HANDLE      ghExitEvent		= NULL;
HINSTANCE   g_hInstance		= NULL;
DWORD      g_dwMainWindowStackSize = 0x20000;

void GetProxyOption();


static HRESULT FindString();
HRESULT HandleNewWindow2(LPTSTR lpszUrl, DISPPARAMS FAR* pdparams,CString szTitle,int nType=0,short nShouldAuth=0);
BOOL RegisterMainWnd();


DWORD WINAPI NewWindow(LPVOID pParam)
{

    CMainWnd *pWnd = (CMainWnd *)pParam;
    MSG msg;
    BOOL fRet;

    HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);

    fRet = pWnd->Create();

    SetEvent(pWnd->hEvent);

    if (!fRet)
    {
        pWnd->_pBrowser = NULL;
        return 0;
    }

    while (GetMessage( &msg, NULL, 0, 0 ) )
    {
        if(msg.message == WM_QUIT)
            break;

        if (!pWnd->PreTranslateMessage(&msg) && !(msg.message == WM_CHAR && msg.wParam == VK_TAB))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    pWnd->Release();

    CoUninitialize();

    InterlockedDecrement(&glThreadCount);
    SetEvent(ghExitEvent);

    return msg.wParam;
}
#include "..\comm\CommonAPI.h"
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPTSTR lpCmdLine, int nCmdShow)
{	
	g_hinst = hInst;
	int m_nURLType = 0;
	short bAuth = 0;	
	CString m_szTitle;
	m_szTitle = _T("浏览器");
	if( lpCmdLine && *lpCmdLine )
	{
		wchar_t* pp = wcschr(lpCmdLine,_T(' '));
		if( pp )
		{
			wchar_t buf[50]={0};
			wcsncpy(buf,lpCmdLine,pp-lpCmdLine);			
			m_nURLType = _wtoi(buf);			
			if( (0 > m_nURLType) || (MAX_URL_COUNT < m_nURLType) )
			{					
				return 0;
			}else
			{			
				m_szTitle = ++pp;
				bAuth = 1;
			}
		}
	}
	//printf("--------------------%d\n",m_nURLType);
	if( m_nURLType )
	{
		if( !ReadJumpURL(m_nURLType) )
		{			
			MessageBox(0,_T("该模块正在开发当中。。。。。。。"),_T("提示"),0);
			return 0;
		}		
		if( 40 == m_nURLType )
			bAuth = 0;
		//printf("m_nURLType=%d\n",m_nURLType);
		if( 38 != m_nURLType && 40 != m_nURLType)
		{
		CBaseDBOper db;
		if( !db.QryUserInfo(g_info) )
		{
			//MessageBox(0,_T("内部错误!"),_T("提示"),0);			
			return 0;
		}
		}
	}
	//printf("--------------------%d\n",m_nURLType);
	CString sName;
	sName.Format(_T("myie class ty%d"),m_nURLType);
	HANDLE hdl = CreateMutex( NULL, FALSE, sName );
	if( GetLastError()==ERROR_ALREADY_EXISTS )
	{
		//printf("err\n");
		CloseHandle(hdl);
		HWND hh = FindWindow(TEXT("IESIMPLE"),0);
		if( hh )
		{
			//SendMessage(hh,WM_CLOSE,0,0);//
			SetForegroundWindow(hh);
		}
		return 0;
	}
	//printf("m_nURLType=%d\n",m_nURLType);
	////////邮件
	if( 1 == m_nURLType )
	{
		CMsgNotify vc;
		vc.SetNotifyMsg( mtNewEmail , 0 );
	}
	//5	社区服务/小区公告	
	if( 5 == m_nURLType )
	{
		CMsgNotify vc;
		vc.SetNotifyMsg( mtNewBulletion , 0 );
	}
	//7	社区服务/预约服务	
	if( 7 == m_nURLType )
	{
		CMsgNotify vc;
		vc.SetNotifyMsg( mtNewCommityReply , 0 );
	}
	//2	客服中心
	if( 2 == m_nURLType )
	{
		CMsgNotify vc;
		vc.SetNotifyMsg( mtNewClientCenterReply , 0 );
	}
    INITCOMMONCONTROLSEX iccsex;
    HKEY hKey;
    DWORD dwSize = sizeof(DWORD);
    MSG msg;

    // HKCU is where IE\Main settings are
    if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("SOFTWARE\\Microsoft\\Internet Explorer\\Main"), 0, 0, &hKey))
    {
            RegQueryValueEx(hKey, TEXT("StackRes"), NULL, NULL, (LPBYTE)&g_dwMainWindowStackSize, &dwSize);
            RegCloseKey(hKey);
    }

    // provide a default stack size if the one given is too small or too large. 
    if(g_dwMainWindowStackSize < 0x10000 || g_dwMainWindowStackSize > 0x80000)
    {
            // default to 128k
            g_dwMainWindowStackSize = 0x20000;
    }
    RETAILMSG(1,(L"IESIMPLE Using Stack size: %x", g_dwMainWindowStackSize));


    HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
    if (FAILED(hr))
    {
		CloseHandle(hdl);
        return FALSE;
    }



	if (!RegisterMainWnd())
	{
		CloseHandle(hdl);
        return FALSE;
	}
    
    ghExitEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
    if (!ghExitEvent)
    {
		CloseHandle(hdl);
        return FALSE;
    }

    iccsex.dwSize = sizeof(INITCOMMONCONTROLSEX);
    iccsex.dwICC = ICC_COOL_CLASSES;

    InitCommonControlsEx(&iccsex);

    g_hInstance = hInst;

    // Create  a message queue on this thread
    PeekMessage(&msg, NULL, 0,0,PM_NOREMOVE);

    if(HandleNewWindow2(NULL, NULL,m_szTitle,m_nURLType,bAuth))
    {
        goto Cleanup;
    }


    while (glThreadCount > 0)
    {
		//printf("glThreadCount.........%d\n",glThreadCount);
        WaitForSingleObject(ghExitEvent, INFINITE);
    }
    
Cleanup:    
    CoUninitialize();

    RETAILMSG(1, (L"IESIMPLE exited. Cmdline was: %s\r\n",lpCmdLine ? lpCmdLine : L""));
	//printf("close handle and exit.........\n");
	CloseHandle(hdl);

    return TRUE;
}


CMainWnd::CMainWnd()
{
    _ulRefs = 1;
    _hWnd = NULL;
    _pBrowser = NULL;
    _pObject = NULL;
    _pCP = NULL;
    _lpszUrl = NULL;
    _fFullScreen = FALSE;
    _fEmpty = FALSE;
    _szTitle[0] = 0;

    _wZoom = 2; // default zoom
    _wDLCCounter = 0; // counter for Download Completes

	_fShowStatusBar = TRUE;

	bShouldAuthor = 0;
	bFirstTime = 1;
	m_nURLType = 0;
	m_szTitle = _T("电子邮件");
}

CMainWnd::~CMainWnd()
{

RETAILMSG(1,(L"IESIMPLE Exiting ~CMainWnd\r\n"));

        if(_pBrowser)
            _pBrowser->Release();


}   

BOOL RegisterMainWnd()
{
    WNDCLASS        wc;
    wc.style         = 0;
    wc.lpfnWndProc   = (WNDPROC)CMainWnd::MainWndProc;
    wc.cbClsExtra    = 0;
    wc.cbWndExtra    = 0;
    wc.hInstance     = g_hInstance;
    wc.hIcon         = NULL; // LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_IE));
    wc.hCursor       = NULL;//LoadCursor(NULL, IDC_ARROW);???
    wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_WINDOW);
    wc.lpszMenuName  = NULL;
    wc.lpszClassName = TEXT("IESIMPLE");

    if (!(RegisterClass(&wc)))
        return FALSE;

    return TRUE;
}
void CMainWnd::OnWindowSize()
{
}
//#include "..\comm\headctrl.h"
BOOL CMainWnd::Create()
{
	_hWndProgress = NULL;
	_hWndStatus = NULL;
	_hWndCmdband = NULL;
	_hWndToolBar = NULL;
	_hWndAddressCombo = NULL;
	_hWndAddressEdit = NULL; 
	int iWidth = GetSystemMetrics(SM_CXSCREEN);
	int iHeight = GetSystemMetrics(SM_CYSCREEN)-32;

    RECT rcArea={0,0,iWidth,iHeight};

    DWORD dwStyle =
		WS_VISIBLE ;// | WS_OVERLAPPED| WS_THICKFRAME;// | WS_SYSMENU;
		/*|WS_OVERLAPPED|WS_BORDER|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX*/
	if( 0 != m_nURLType )
		dwStyle |= WS_POPUP;
	else
		dwStyle |= WS_OVERLAPPED | WS_THICKFRAME;
//		dwStyle |= WS_SYSMENU;
    DWORD dwExStyle = WS_EX_NODRAG/*WS_EX_OVERLAPPEDWINDOW*/;

    HMENU hMenu = NULL;

//    SystemParametersInfo(SPI_GETWORKAREA, 0, &rcArea, 0);

	BSTR title = SysAllocString(m_szTitle);
    _hWnd = ::CreateWindowEx(dwExStyle,
                             TEXT("IESIMPLE"),
                             (WCHAR *)title,//LoadString(g_hInstance, IDS_IE, NULL, 0),
                             dwStyle,
                             rcArea.left,// + 20,
                             rcArea.top,// + 20,
                             rcArea.right - rcArea.left,// - 40,
                             rcArea.bottom - rcArea.top,// - 30,
                             NULL, hMenu, g_hInstance, 0);	
	//resizeTo(rcArea.right - rcArea.left,rcArea.bottom - rcArea.top);
	SysFreeString(title);
    if (!_hWnd)
        return FALSE;

	m_draw.m_hwnd = _hWnd;
	m_draw.SetDT(OTHER_TOOLBAR);
	wcscpy(m_draw.m_title,m_szTitle);

	//	m_head.Create(
    SetWindowLong(_hWnd, GWL_USERDATA, (DWORD)this);
    GetWindowRect(_hWnd, &_rcWnd);

	// create a progress bar
	_rcProgress.left = (_rcWnd.right - _rcWnd.left)/3;//5;
	_rcProgress.right = _rcProgress.left + (_rcWnd.right - _rcWnd.left)/3;
	_rcProgress.top = (_rcWnd.bottom-_rcWnd.top)/2;//5;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -