2006-04-07 10:52:00 +02:00
|
|
|
/*
|
|
|
|
* SHDOCVW - Internet Explorer main frame window
|
|
|
|
*
|
|
|
|
* Copyright 2006 Mike McCormack (for CodeWeavers)
|
2006-04-21 12:13:53 +02:00
|
|
|
* Copyright 2006 Jacek Caban (for CodeWeavers)
|
2006-04-07 10:52:00 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2006-04-07 10:52:00 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
#include "exdisp.h"
|
|
|
|
#include "oleidl.h"
|
|
|
|
|
|
|
|
#include "shdocvw.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
|
|
|
|
|
|
|
|
static const WCHAR szIEWinFrame[] = { 'I','E','F','r','a','m','e',0 };
|
|
|
|
|
|
|
|
static LRESULT iewnd_OnCreate(HWND hwnd, LPCREATESTRUCTW lpcs)
|
|
|
|
{
|
2006-04-10 08:30:46 +02:00
|
|
|
SetWindowLongPtrW(hwnd, 0, (LONG_PTR) lpcs->lpCreateParams);
|
2006-04-07 10:52:00 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-04-21 12:13:53 +02:00
|
|
|
static LRESULT iewnd_OnSize(InternetExplorer *This, INT width, INT height)
|
2006-04-07 10:52:00 +02:00
|
|
|
{
|
2006-04-21 12:13:53 +02:00
|
|
|
if(This->doc_host.hwnd)
|
|
|
|
SetWindowPos(This->doc_host.hwnd, NULL, 0, 0, width, height,
|
|
|
|
SWP_NOZORDER | SWP_NOACTIVATE);
|
2006-04-07 10:52:00 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-04-21 12:13:53 +02:00
|
|
|
static LRESULT iewnd_OnDestroy(InternetExplorer *This)
|
2006-04-07 10:52:00 +02:00
|
|
|
{
|
|
|
|
TRACE("%p\n", This);
|
|
|
|
|
2006-04-21 12:13:53 +02:00
|
|
|
This->frame_hwnd = NULL;
|
|
|
|
PostQuitMessage(0); /* FIXME */
|
2006-04-07 10:52:00 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT CALLBACK
|
|
|
|
ie_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
2006-04-21 12:13:53 +02:00
|
|
|
InternetExplorer *This = (InternetExplorer*) GetWindowLongPtrW(hwnd, 0);
|
2006-04-07 10:52:00 +02:00
|
|
|
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_CREATE:
|
|
|
|
return iewnd_OnCreate(hwnd, (LPCREATESTRUCTW)lparam);
|
|
|
|
case WM_DESTROY:
|
|
|
|
return iewnd_OnDestroy(This);
|
|
|
|
case WM_SIZE:
|
|
|
|
return iewnd_OnSize(This, LOWORD(lparam), HIWORD(lparam));
|
2008-01-18 21:53:25 +01:00
|
|
|
case WM_DOCHOSTTASK:
|
|
|
|
return process_dochost_task(&This->doc_host, lparam);
|
2006-04-07 10:52:00 +02:00
|
|
|
}
|
|
|
|
return DefWindowProcW(hwnd, msg, wparam, lparam);
|
|
|
|
}
|
|
|
|
|
|
|
|
void register_iewindow_class(void)
|
|
|
|
{
|
|
|
|
WNDCLASSW wc;
|
|
|
|
|
|
|
|
memset(&wc, 0, sizeof wc);
|
|
|
|
wc.style = 0;
|
|
|
|
wc.lpfnWndProc = ie_window_proc;
|
|
|
|
wc.cbClsExtra = 0;
|
2006-04-21 12:13:53 +02:00
|
|
|
wc.cbWndExtra = sizeof(InternetExplorer*);
|
2006-04-07 10:52:00 +02:00
|
|
|
wc.hInstance = shdocvw_hinstance;
|
|
|
|
wc.hIcon = 0;
|
|
|
|
wc.hCursor = LoadCursorW(0, MAKEINTRESOURCEW(IDI_APPLICATION));
|
|
|
|
wc.hbrBackground = 0;
|
|
|
|
wc.lpszClassName = szIEWinFrame;
|
|
|
|
wc.lpszMenuName = NULL;
|
|
|
|
|
|
|
|
RegisterClassW(&wc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void unregister_iewindow_class(void)
|
|
|
|
{
|
|
|
|
UnregisterClassW(szIEWinFrame, shdocvw_hinstance);
|
|
|
|
}
|
|
|
|
|
2006-04-21 12:13:53 +02:00
|
|
|
static void create_frame_hwnd(InternetExplorer *This)
|
|
|
|
{
|
|
|
|
/* Windows uses "Microsoft Internet Explorer" */
|
|
|
|
static const WCHAR wszWineInternetExplorer[] =
|
|
|
|
{'W','i','n','e',' ','I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r',0};
|
|
|
|
|
|
|
|
This->frame_hwnd = CreateWindowExW(
|
|
|
|
WS_EX_WINDOWEDGE,
|
|
|
|
szIEWinFrame, wszWineInternetExplorer,
|
|
|
|
WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
|
|
|
|
| WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
NULL, NULL /* FIXME */, shdocvw_hinstance, This);
|
|
|
|
}
|
|
|
|
|
2007-09-09 20:19:03 +02:00
|
|
|
static IWebBrowser2 *create_ie_window(LPCSTR cmdline)
|
2006-04-07 10:52:00 +02:00
|
|
|
{
|
|
|
|
IWebBrowser2 *wb = NULL;
|
2006-04-21 12:13:53 +02:00
|
|
|
|
|
|
|
InternetExplorer_Create(NULL, &IID_IWebBrowser2, (void**)&wb);
|
|
|
|
if(!wb)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
IWebBrowser2_put_Visible(wb, VARIANT_TRUE);
|
|
|
|
|
2007-09-09 20:19:03 +02:00
|
|
|
if(!*cmdline) {
|
|
|
|
IWebBrowser2_GoHome(wb);
|
|
|
|
}else {
|
|
|
|
VARIANT var_url;
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
if(!strncasecmp(cmdline, "-nohome", 7))
|
|
|
|
cmdline += 7;
|
|
|
|
|
|
|
|
V_VT(&var_url) = VT_BSTR;
|
2006-04-07 10:52:00 +02:00
|
|
|
|
2007-09-09 20:19:03 +02:00
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, cmdline, -1, NULL, 0);
|
|
|
|
V_BSTR(&var_url) = SysAllocStringLen(NULL, len);
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, cmdline, -1, V_BSTR(&var_url), len);
|
2006-04-21 12:13:53 +02:00
|
|
|
|
2007-09-09 20:19:03 +02:00
|
|
|
/* navigate to the first page */
|
|
|
|
IWebBrowser2_Navigate2(wb, &var_url, NULL, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
SysFreeString(V_BSTR(&var_url));
|
|
|
|
}
|
2006-04-07 10:52:00 +02:00
|
|
|
|
2006-04-21 12:13:53 +02:00
|
|
|
return wb;
|
2006-04-07 10:52:00 +02:00
|
|
|
}
|
2006-04-19 20:33:32 +02:00
|
|
|
|
|
|
|
HRESULT InternetExplorer_Create(IUnknown *pOuter, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
InternetExplorer *ret;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p %s %p)\n", pOuter, debugstr_guid(riid), ppv);
|
|
|
|
|
2007-11-28 00:09:35 +01:00
|
|
|
ret = heap_alloc(sizeof(InternetExplorer));
|
2006-04-19 20:33:32 +02:00
|
|
|
ret->ref = 0;
|
|
|
|
|
|
|
|
ret->doc_host.disp = (IDispatch*)WEBBROWSER2(ret);
|
|
|
|
DocHost_Init(&ret->doc_host, (IDispatch*)WEBBROWSER2(ret));
|
|
|
|
|
|
|
|
InternetExplorer_WebBrowser_Init(ret);
|
|
|
|
|
2006-04-21 12:13:53 +02:00
|
|
|
create_frame_hwnd(ret);
|
|
|
|
ret->doc_host.frame_hwnd = ret->frame_hwnd;
|
2006-04-19 20:33:32 +02:00
|
|
|
|
|
|
|
hres = IWebBrowser2_QueryInterface(WEBBROWSER2(ret), riid, ppv);
|
|
|
|
if(FAILED(hres)) {
|
2007-11-28 00:09:35 +01:00
|
|
|
heap_free(ret);
|
2006-04-19 20:33:32 +02:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
2006-04-19 20:34:53 +02:00
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* IEWinMain (SHDOCVW.101)
|
|
|
|
*
|
|
|
|
* Only returns on error.
|
|
|
|
*/
|
|
|
|
DWORD WINAPI IEWinMain(LPSTR szCommandLine, int nShowWindow)
|
|
|
|
{
|
2006-04-21 12:14:57 +02:00
|
|
|
IWebBrowser2 *wb = NULL;
|
|
|
|
MSG msg;
|
2006-04-19 20:37:57 +02:00
|
|
|
HRESULT hres;
|
2006-04-19 20:34:53 +02:00
|
|
|
|
2007-11-02 19:51:53 +01:00
|
|
|
TRACE("%s %d\n", debugstr_a(szCommandLine), nShowWindow);
|
|
|
|
|
|
|
|
if(*szCommandLine == '-' || *szCommandLine == '/') {
|
|
|
|
if(!strcasecmp(szCommandLine+1, "regserver"))
|
|
|
|
return register_iexplore(TRUE);
|
|
|
|
if(!strcasecmp(szCommandLine+1, "unregserver"))
|
|
|
|
return register_iexplore(FALSE);
|
|
|
|
}
|
2006-04-19 20:34:53 +02:00
|
|
|
|
|
|
|
CoInitialize(NULL);
|
|
|
|
|
2006-04-19 20:37:57 +02:00
|
|
|
hres = register_class_object(TRUE);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
CoUninitialize();
|
|
|
|
ExitProcess(1);
|
|
|
|
}
|
|
|
|
|
2007-09-09 20:19:03 +02:00
|
|
|
if(strcasecmp(szCommandLine, "-embedding"))
|
|
|
|
wb = create_ie_window(szCommandLine);
|
2006-04-21 12:14:57 +02:00
|
|
|
|
|
|
|
/* run the message loop for this thread */
|
|
|
|
while (GetMessageW(&msg, 0, 0, 0))
|
|
|
|
{
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessageW(&msg);
|
|
|
|
}
|
2006-04-19 20:34:53 +02:00
|
|
|
|
2006-04-21 12:14:57 +02:00
|
|
|
if(wb)
|
|
|
|
IWebBrowser2_Release(wb);
|
2006-04-19 20:34:53 +02:00
|
|
|
|
2006-04-19 20:37:57 +02:00
|
|
|
register_class_object(FALSE);
|
|
|
|
|
|
|
|
CoUninitialize();
|
2006-04-19 20:34:53 +02:00
|
|
|
|
|
|
|
ExitProcess(0);
|
|
|
|
return 0;
|
|
|
|
}
|