This is the window test harness for embedding.

r/a=valeski@netscape.com
bug number: 43054
This commit is contained in:
dougt%netscape.com 2000-06-20 03:22:47 +00:00
Родитель a25ed10135
Коммит 84c5ec9099
10 изменённых файлов: 1088 добавлений и 0 удалений

Двоичные данные
embedding/tests/winEmbed/SMALL.ICO Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 318 B

Просмотреть файл

@ -0,0 +1,8 @@
// stdafx.cpp : source file that includes just the standard includes
// winEmbed.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file

Просмотреть файл

@ -0,0 +1,32 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
// C RunTime Header Files
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
// Local Header Files
// TODO: reference additional headers your program requires here
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)

Просмотреть файл

@ -0,0 +1,480 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Doug Turner <dougt@netscape.com>
*/
#include "WebBrowser.h"
#include "nsCWebBrowser.h"
#include "nsWidgetsCID.h"
#include "nsIGenericFactory.h"
#include "nsString.h"
#include "nsXPIDLString.h"
#include "nsIURI.h"
#include "nsIWebProgress.h"
#include "nsIWebNavigation.h"
#include "nsIDocShell.h"
#include "nsIContentViewer.h"
#include "nsIContentViewerFile.h"
//*****************************************************************************
//*** WebBrowser: Object Management
//*****************************************************************************
WebBrowser::WebBrowser()
{
NS_INIT_REFCNT();
}
WebBrowser::~WebBrowser()
{
}
nsresult
WebBrowser::Init(nsNativeWidget widget)
{
nsresult rv;
mWebBrowser = do_CreateInstance(NS_WEBBROWSER_PROGID, &rv);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIBaseWindow> webBrowserWin = do_QueryInterface(mWebBrowser);
rv = webBrowserWin->InitWindow( widget,
nsnull,
0,
32,
450,
450);
mWebBrowser->SetTopLevelWindow(this);
webBrowserWin->Create();
nsCOMPtr <nsIDocShell> rootDocShell;
mWebBrowser->GetDocShell(getter_AddRefs(rootDocShell));
rootDocShell->SetAllowPlugins(PR_TRUE);
webBrowserWin->SetVisibility(PR_TRUE);
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mWebBrowser));
webNav->LoadURI(NS_ConvertASCIItoUCS2("http://people.netscape.com/dougt").GetUnicode());
return rv;
}
nsresult
WebBrowser::GoTo(char* url)
{
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mWebBrowser));
return webNav->LoadURI(NS_ConvertASCIItoUCS2(url).GetUnicode());
}
nsresult
WebBrowser::Resize(int x, int y, int cx, int cy)
{
nsCOMPtr<nsIBaseWindow> webBrowserWin = do_QueryInterface(mWebBrowser);
return webBrowserWin->SetPositionAndSize(x, y, cx, cy, true);
}
nsresult
WebBrowser::Print(void)
{
nsCOMPtr <nsIDocShell> rootDocShell;
mWebBrowser->GetDocShell(getter_AddRefs(rootDocShell));
nsIContentViewer *pContentViewer = nsnull;
nsresult res = rootDocShell->GetContentViewer(&pContentViewer);
if (NS_SUCCEEDED(res))
{
nsCOMPtr<nsIContentViewerFile> spContentViewerFile = do_QueryInterface(pContentViewer);
spContentViewerFile->Print(PR_TRUE, nsnull);
NS_RELEASE(pContentViewer);
}
return NS_OK;
}
// an empty implementation.
//*****************************************************************************
// WebBrowser::nsISupports
//*****************************************************************************
NS_IMPL_ADDREF(WebBrowser)
NS_IMPL_RELEASE(WebBrowser)
NS_INTERFACE_MAP_BEGIN(WebBrowser)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebBrowserChrome)
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
NS_INTERFACE_MAP_ENTRY(nsIBaseWindow)
NS_INTERFACE_MAP_ENTRY(nsIPrompt)
NS_INTERFACE_MAP_END
//*****************************************************************************
// WebBrowser::nsIInterfaceRequestor
//*****************************************************************************
NS_IMETHODIMP WebBrowser::GetInterface(const nsIID &aIID, void** aInstancePtr)
{
return QueryInterface(aIID, aInstancePtr);
}
//*****************************************************************************
// WebBrowser::nsIWebBrowserChrome
//*****************************************************************************
NS_IMETHODIMP WebBrowser::SetJSStatus(const PRUnichar* aStatus)
{
return NS_OK;
}
NS_IMETHODIMP WebBrowser::SetJSDefaultStatus(const PRUnichar* aStatus)
{
return NS_OK;
}
NS_IMETHODIMP WebBrowser::SetOverLink(const PRUnichar* aLink)
{
return NS_OK;
}
NS_IMETHODIMP WebBrowser::GetWebBrowser(nsIWebBrowser** aWebBrowser)
{
NS_ERROR("Haven't Implemented this yet");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP WebBrowser::SetWebBrowser(nsIWebBrowser* aWebBrowser)
{
NS_ERROR("Haven't Implemented this yet");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP WebBrowser::GetChromeMask(PRUint32* aChromeMask)
{
NS_ERROR("Haven't Implemented this yet");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP WebBrowser::SetChromeMask(PRUint32 aChromeMask)
{
NS_ERROR("Haven't Implemented this yet");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP WebBrowser::GetNewBrowser(PRUint32 chromeMask, nsIWebBrowser **webBrowser)
{
NS_ERROR("Haven't Implemented this yet");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP WebBrowser::FindNamedBrowserItem(const PRUnichar* aName,
nsIDocShellTreeItem ** aWebBrowser)
{
NS_ERROR("Haven't Implemented this yet");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP WebBrowser::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY)
{
NS_ERROR("Haven't Implemented this yet");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP WebBrowser::ShowAsModal(void)
{
NS_ERROR("Haven't Implemented this yet");
return NS_ERROR_FAILURE;
}
//*****************************************************************************
// WebBrowser::nsIWebProgressListener
//*****************************************************************************
NS_IMETHODIMP WebBrowser::OnProgressChange(nsIChannel *channel, PRInt32 curSelfProgress, PRInt32 maxSelfProgress, PRInt32 curTotalProgress, PRInt32 maxTotalProgress)
{
return NS_OK;
}
NS_IMETHODIMP WebBrowser::OnChildProgressChange(nsIChannel *channel, PRInt32 curSelfProgress, PRInt32 curTotalProgress)
{
return NS_OK;
}
NS_IMETHODIMP WebBrowser::OnStatusChange(nsIChannel *channel, PRInt32 progressStatusFlags)
{
return NS_OK;
}
NS_IMETHODIMP WebBrowser::OnChildStatusChange(nsIChannel *channel, PRInt32 progressStatusFlags)
{
return NS_OK;
}
NS_IMETHODIMP WebBrowser::OnLocationChange(nsIURI *location)
{
return NS_OK;
}
//*****************************************************************************
// WebBrowser::nsIBaseWindow
//*****************************************************************************
NS_IMETHODIMP WebBrowser::InitWindow(nativeWindow aParentNativeWindow,
nsIWidget* parentWidget, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy)
{
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP WebBrowser::Create()
{
NS_ASSERTION(PR_FALSE, "You can't call this");
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP WebBrowser::Destroy()
{
NS_ASSERTION(PR_FALSE, "You can't call this");
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP WebBrowser::SetPosition(PRInt32 x, PRInt32 y)
{
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP WebBrowser::GetPosition(PRInt32* x, PRInt32* y)
{
NS_ENSURE_ARG_POINTER(x && y);
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP WebBrowser::SetSize(PRInt32 cx, PRInt32 cy, PRBool fRepaint)
{
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP WebBrowser::GetSize(PRInt32* cx, PRInt32* cy)
{
NS_ENSURE_ARG_POINTER(cx && cy);
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP WebBrowser::SetPositionAndSize(PRInt32 x, PRInt32 y, PRInt32 cx,
PRInt32 cy, PRBool fRepaint)
{
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP WebBrowser::GetPositionAndSize(PRInt32* x, PRInt32* y, PRInt32* cx,
PRInt32* cy)
{
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP WebBrowser::Repaint(PRBool aForce)
{
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP WebBrowser::GetParentWidget(nsIWidget** aParentWidget)
{
NS_ENSURE_ARG_POINTER(aParentWidget);
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP WebBrowser::SetParentWidget(nsIWidget* aParentWidget)
{
NS_ASSERTION(PR_FALSE, "You can't call this");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP WebBrowser::GetParentNativeWindow(nativeWindow* aParentNativeWindow)
{
NS_ENSURE_ARG_POINTER(aParentNativeWindow);
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP WebBrowser::SetParentNativeWindow(nativeWindow aParentNativeWindow)
{
NS_ASSERTION(PR_FALSE, "You can't call this");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP WebBrowser::GetVisibility(PRBool* aVisibility)
{
NS_ENSURE_ARG_POINTER(aVisibility);
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP WebBrowser::SetVisibility(PRBool aVisibility)
{
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP WebBrowser::GetMainWidget(nsIWidget** aMainWidget)
{
NS_ENSURE_ARG_POINTER(aMainWidget);
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP WebBrowser::SetFocus()
{
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP WebBrowser::FocusAvailable(nsIBaseWindow* aCurrentFocus,
PRBool* aTookFocus)
{
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP WebBrowser::GetTitle(PRUnichar** aTitle)
{
return NS_OK;
}
NS_IMETHODIMP WebBrowser::SetTitle(const PRUnichar* aTitle)
{
return NS_OK;
}
//*****************************************************************************
// WebBrowser::nsIPrompt
//*****************************************************************************
NS_IMETHODIMP WebBrowser::Alert(const PRUnichar *dialogTitle, const PRUnichar *text)
{
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP WebBrowser::Confirm(const PRUnichar *dialogTitle, const PRUnichar *text, PRBool *_retval)
{
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP WebBrowser::ConfirmCheck(const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval)
{
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP WebBrowser::Prompt(const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *passwordRealm, PRUint32 savePassword, const PRUnichar *defaultText, PRUnichar **result, PRBool *_retval)
{
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP WebBrowser::PromptUsernameAndPassword(const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *passwordRealm, PRUint32 savePassword, PRUnichar **user, PRUnichar **pwd, PRBool *_retval)
{
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP WebBrowser::PromptPassword(const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *passwordRealm, PRUint32 savePassword, PRUnichar **user, PRBool *_retval)
{
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP WebBrowser::Select(const PRUnichar *dialogTitle, const PRUnichar *text, PRUint32 count, const PRUnichar **selectList, PRInt32 *outSelection, PRBool *_retval)
{
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP WebBrowser::UniversalDialog(const PRUnichar *inTitleMessage, const PRUnichar *inDialogTitle, const PRUnichar *inMsg, const PRUnichar *inCheckboxMsg, const PRUnichar *inButton0Text, const PRUnichar *inButton1Text, const PRUnichar *inButton2Text, const PRUnichar *inButton3Text, const PRUnichar *inEditfield1Msg, const PRUnichar *inEditfield2Msg, PRUnichar **inoutEditfield1Value, PRUnichar **inoutEditfield2Value, const PRUnichar *inIConURL, PRBool *inoutCheckboxState, PRInt32 inNumberButtons, PRInt32 inNumberEditfields, PRInt32 inEditField1Password, PRInt32 *outButtonPressed)
{
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,69 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Doug Turner <dougt@netscape.com>
*/
#ifndef __WebBrowser__
#define __WebBrowser__
// Helper Classes
#include "nsCOMPtr.h"
// Interfaces Needed
#include "nsIWidget.h"
#include "nsIWebBrowser.h"
#include "nsIWebBrowserChrome.h"
#include "nsIBaseWindow.h"
#include "nsIWebProgressListener.h"
#include "nsIInterfaceRequestor.h"
#include "nsIPrompt.h"
class WebBrowser : public nsIWebBrowserChrome,
public nsIWebProgressListener,
public nsIBaseWindow,
public nsIPrompt,
public nsIInterfaceRequestor
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIWEBBROWSERCHROME
NS_DECL_NSIWEBPROGRESSLISTENER
NS_DECL_NSIBASEWINDOW
NS_DECL_NSIPROMPT
NS_DECL_NSIINTERFACEREQUESTOR
nsresult Init(nsNativeWidget widget);
nsresult GoTo(char* url);
nsresult Print(void);
WebBrowser();
virtual ~WebBrowser();
protected:
nsCOMPtr<nsIWidget> mWindow;
nsCOMPtr<nsIWebBrowser> mWebBrowser;
};
#endif /* __WebBrowser__ */

Просмотреть файл

@ -0,0 +1,56 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is Mozilla Communicator client code,
# released March 31, 1998.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1999 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..
MAKE_OBJ_TYPE = EXE
MODULE = winEmbed
PROGRAM = .\$(OBJDIR)\$(MODULE).exe
RESFILE = $(MODULE).res
OBJS = \
.\$(OBJDIR)\winEmbed.obj \
.\$(OBJDIR)\WebBrowser.obj \
.\$(OBJDIR)\StdAfx.obj \
$(NULL)
LLIBS= \
$(DIST)\lib\baseembed_s.lib \
$(DIST)\lib\xpcom.lib \
$(LIBNSPR) \
$(NULL)
WIN_LIBS= \
ole32.lib \
comdlg32.lib \
shell32.lib \
version.lib \
$(NULL)
include <$(DEPTH)\config\rules.mak>
install:: $(PROGRAM)
$(MAKE_INSTALL) $(PROGRAM) $(DIST)\bin
clobber_all::
$(RM) $(DIST)\bin\$(MODULE).exe

Просмотреть файл

@ -0,0 +1,31 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by winEmbed.rc
//
#define IDC_MYICON 2
#define IDD_WINEMBED_DIALOG 102
#define IDD_ABOUTBOX 103
#define IDS_APP_TITLE 103
#define IDM_ABOUT 104
#define MOZ_OpenURI 104
#define IDM_EXIT 105
#define IDS_HELLO 106
#define IDI_WINEMBED 107
#define IDI_SMALL 108
#define IDC_WINEMBED 109
#define IDR_MAINFRAME 128
#define MOZ_EDIT_URI 1001
#define MOZ_Open 32771
#define MOZ_Print 32772
#define IDC_STATIC -1
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 129
#define _APS_NEXT_COMMAND_VALUE 32773
#define _APS_NEXT_CONTROL_VALUE 1002
#define _APS_NEXT_SYMED_VALUE 110
#endif
#endif

Двоичные данные
embedding/tests/winEmbed/winEmbed.ICO Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.1 KiB

Просмотреть файл

@ -0,0 +1,286 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Doug Turner <dougt@netscape.com>
*/
#include "stdafx.h"
#include "resource.h"
#include "WebBrowser.h"
WebBrowser *mozBrowser = nsnull;
extern nsresult NS_InitEmbedding(const char *aPath);
extern nsresult NS_TermEmbedding();
#define MAX_LOADSTRING 100
// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text
// Foward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK OpenURI(HWND, UINT, WPARAM, LPARAM);
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
MSG msg;
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_WINEMBED, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
NS_InitEmbedding(nsnull);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
NS_TermEmbedding();
return msg.wParam;
}
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage is only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_WINEMBED);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = (LPCSTR)IDC_WINEMBED;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
return RegisterClassEx(&wcex);
}
//
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // Store instance handle in our global variable
hWnd = CreateWindow( szWindowClass,
szTitle,
WS_OVERLAPPEDWINDOW,
0,
0,
450,
450,
NULL,
NULL,
hInstance,
NULL);
if (!hWnd)
{
return FALSE;
}
mozBrowser = new WebBrowser();
if (! mozBrowser)
return FALSE;
NS_ADDREF(mozBrowser);
if ( NS_FAILED( mozBrowser->Init(hWnd) ) )
return FALSE;
RECT rect;
GetClientRect(hWnd, &rect);
rect.top += 32;
mozBrowser->SetPositionAndSize(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, true);
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR szHello[MAX_LOADSTRING];
LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_EXIT:
DestroyWindow(hWnd);
break;
case MOZ_Open:
DialogBox(hInst, (LPCTSTR)MOZ_OpenURI, hWnd, (DLGPROC)OpenURI);
break;
case MOZ_Print:
if (mozBrowser)
mozBrowser->Print();
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_SIZE:
RECT rect;
GetClientRect(hWnd, &rect);
rect.top += 32;
if (mozBrowser)
mozBrowser->SetPositionAndSize(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, true);
break;
case WM_PAINT:
// this draws that silly text at the top of the window.
hdc = BeginPaint(hWnd, &ps);
RECT rt;
GetClientRect(hWnd, &rt);
rt.bottom = 32;
FrameRect(hdc, &rt, CreateSolidBrush( 0x00 ) );
rt.top = 4;
DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
// Mesage handler for about box.
LRESULT CALLBACK OpenURI(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK)
{
char szBuf[1000];
GetDlgItemText(hDlg, MOZ_EDIT_URI, szBuf, 1000);
EndDialog(hDlg, LOWORD(wParam));
mozBrowser->GoTo(szBuf);
return TRUE;
}
else if (LOWORD(wParam) == IDNO)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}

Просмотреть файл

@ -0,0 +1,126 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
#include "resource.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_WINEMBED ICON DISCARDABLE "winEmbed.ICO"
IDI_SMALL ICON DISCARDABLE "SMALL.ICO"
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDC_WINEMBED MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "Open URL...", MOZ_Open
MENUITEM "Print Page", MOZ_Print
MENUITEM "E&xit", IDM_EXIT
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
MOZ_OpenURI DIALOG DISCARDABLE 22, 17, 230, 75
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Open URL"
FONT 8, "System"
BEGIN
ICON IDI_WINEMBED,IDC_MYICON,8,4,20,20
DEFPUSHBUTTON "OK",IDOK,182,55,30,11,WS_GROUP
PUSHBUTTON "Cancel",IDNO,146,55,30,11,WS_GROUP
EDITTEXT MOZ_EDIT_URI,34,33,182,14,ES_AUTOHSCROLL
LTEXT "URL:",IDC_STATIC,13,34,17,8
END
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""windows.h""\r\n"
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""resource.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
IDS_APP_TITLE "winEmbed"
IDS_HELLO "Embedding Mozilla is fun!!"
IDC_WINEMBED "WINEMBED"
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED