2 * SHDOCVW - Internet Explorer main frame window
4 * Copyright 2006 Mike McCormack (for CodeWeavers)
5 * Copyright 2006 Jacek Caban (for CodeWeavers)
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw
);
42 static const WCHAR szIEWinFrame
[] = { 'I','E','F','r','a','m','e',0 };
44 static LRESULT
iewnd_OnCreate(HWND hwnd
, LPCREATESTRUCTW lpcs
)
46 SetWindowLongPtrW(hwnd
, 0, (LONG_PTR
) lpcs
->lpCreateParams
);
50 static LRESULT
iewnd_OnSize(InternetExplorer
*This
, INT width
, INT height
)
52 if(This
->doc_host
.hwnd
)
53 SetWindowPos(This
->doc_host
.hwnd
, NULL
, 0, 0, width
, height
,
54 SWP_NOZORDER
| SWP_NOACTIVATE
);
59 static LRESULT
iewnd_OnDestroy(InternetExplorer
*This
)
63 This
->frame_hwnd
= NULL
;
64 PostQuitMessage(0); /* FIXME */
69 static LRESULT CALLBACK
70 ie_window_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
72 InternetExplorer
*This
= (InternetExplorer
*) GetWindowLongPtrW(hwnd
, 0);
77 return iewnd_OnCreate(hwnd
, (LPCREATESTRUCTW
)lparam
);
79 return iewnd_OnDestroy(This
);
81 return iewnd_OnSize(This
, LOWORD(lparam
), HIWORD(lparam
));
83 return process_dochost_task(&This
->doc_host
, lparam
);
85 return DefWindowProcW(hwnd
, msg
, wparam
, lparam
);
88 void register_iewindow_class(void)
92 memset(&wc
, 0, sizeof wc
);
93 wc
.cbSize
= sizeof(wc
);
95 wc
.lpfnWndProc
= ie_window_proc
;
97 wc
.cbWndExtra
= sizeof(InternetExplorer
*);
98 wc
.hInstance
= shdocvw_hinstance
;
99 wc
.hIcon
= LoadIconW(GetModuleHandleW(0), MAKEINTRESOURCEW(IDI_APPICON
));
100 wc
.hIconSm
= LoadImageW(GetModuleHandleW(0), MAKEINTRESOURCEW(IDI_APPICON
), IMAGE_ICON
,
101 GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), LR_SHARED
);
102 wc
.hCursor
= LoadCursorW(0, MAKEINTRESOURCEW(IDC_ARROW
));
103 wc
.hbrBackground
= 0;
104 wc
.lpszClassName
= szIEWinFrame
;
105 wc
.lpszMenuName
= NULL
;
107 RegisterClassExW(&wc
);
110 void unregister_iewindow_class(void)
112 UnregisterClassW(szIEWinFrame
, shdocvw_hinstance
);
115 static void create_frame_hwnd(InternetExplorer
*This
)
117 /* Windows uses "Microsoft Internet Explorer" */
118 static const WCHAR wszWineInternetExplorer
[] =
119 {'W','i','n','e',' ','I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r',0};
121 This
->frame_hwnd
= CreateWindowExW(
123 szIEWinFrame
, wszWineInternetExplorer
,
124 WS_CLIPCHILDREN
| WS_CAPTION
| WS_SYSMENU
| WS_THICKFRAME
125 | WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
,
126 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
127 NULL
, NULL
/* FIXME */, shdocvw_hinstance
, This
);
130 static IWebBrowser2
*create_ie_window(LPCSTR cmdline
)
132 IWebBrowser2
*wb
= NULL
;
134 InternetExplorer_Create(NULL
, &IID_IWebBrowser2
, (void**)&wb
);
138 IWebBrowser2_put_Visible(wb
, VARIANT_TRUE
);
141 IWebBrowser2_GoHome(wb
);
146 if(!strncasecmp(cmdline
, "-nohome", 7))
149 V_VT(&var_url
) = VT_BSTR
;
151 len
= MultiByteToWideChar(CP_ACP
, 0, cmdline
, -1, NULL
, 0);
152 V_BSTR(&var_url
) = SysAllocStringLen(NULL
, len
);
153 MultiByteToWideChar(CP_ACP
, 0, cmdline
, -1, V_BSTR(&var_url
), len
);
155 /* navigate to the first page */
156 IWebBrowser2_Navigate2(wb
, &var_url
, NULL
, NULL
, NULL
, NULL
);
158 SysFreeString(V_BSTR(&var_url
));
164 HRESULT
InternetExplorer_Create(IUnknown
*pOuter
, REFIID riid
, void **ppv
)
166 InternetExplorer
*ret
;
169 TRACE("(%p %s %p)\n", pOuter
, debugstr_guid(riid
), ppv
);
171 ret
= heap_alloc_zero(sizeof(InternetExplorer
));
174 ret
->doc_host
.disp
= (IDispatch
*)WEBBROWSER2(ret
);
175 DocHost_Init(&ret
->doc_host
, (IDispatch
*)WEBBROWSER2(ret
));
177 InternetExplorer_WebBrowser_Init(ret
);
179 create_frame_hwnd(ret
);
180 ret
->doc_host
.frame_hwnd
= ret
->frame_hwnd
;
182 hres
= IWebBrowser2_QueryInterface(WEBBROWSER2(ret
), riid
, ppv
);
191 /******************************************************************
192 * IEWinMain (SHDOCVW.101)
194 * Only returns on error.
196 DWORD WINAPI
IEWinMain(LPSTR szCommandLine
, int nShowWindow
)
198 IWebBrowser2
*wb
= NULL
;
202 TRACE("%s %d\n", debugstr_a(szCommandLine
), nShowWindow
);
204 if(*szCommandLine
== '-' || *szCommandLine
== '/') {
205 if(!strcasecmp(szCommandLine
+1, "regserver"))
206 return register_iexplore(TRUE
);
207 if(!strcasecmp(szCommandLine
+1, "unregserver"))
208 return register_iexplore(FALSE
);
213 hres
= register_class_object(TRUE
);
219 if(strcasecmp(szCommandLine
, "-embedding"))
220 wb
= create_ie_window(szCommandLine
);
222 /* run the message loop for this thread */
223 while (GetMessageW(&msg
, 0, 0, 0))
225 TranslateMessage(&msg
);
226 DispatchMessageW(&msg
);
230 IWebBrowser2_Release(wb
);
232 register_class_object(FALSE
);