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
);
40 static const WCHAR szIEWinFrame
[] = { 'I','E','F','r','a','m','e',0 };
42 static LRESULT
iewnd_OnCreate(HWND hwnd
, LPCREATESTRUCTW lpcs
)
44 SetWindowLongPtrW(hwnd
, 0, (LONG_PTR
) lpcs
->lpCreateParams
);
48 static LRESULT
iewnd_OnSize(InternetExplorer
*This
, INT width
, INT height
)
50 if(This
->doc_host
.hwnd
)
51 SetWindowPos(This
->doc_host
.hwnd
, NULL
, 0, 0, width
, height
,
52 SWP_NOZORDER
| SWP_NOACTIVATE
);
57 static LRESULT
iewnd_OnDestroy(InternetExplorer
*This
)
61 This
->frame_hwnd
= NULL
;
62 PostQuitMessage(0); /* FIXME */
67 static LRESULT CALLBACK
68 ie_window_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
70 InternetExplorer
*This
= (InternetExplorer
*) GetWindowLongPtrW(hwnd
, 0);
75 return iewnd_OnCreate(hwnd
, (LPCREATESTRUCTW
)lparam
);
77 return iewnd_OnDestroy(This
);
79 return iewnd_OnSize(This
, LOWORD(lparam
), HIWORD(lparam
));
81 return DefWindowProcW(hwnd
, msg
, wparam
, lparam
);
84 void register_iewindow_class(void)
88 memset(&wc
, 0, sizeof wc
);
90 wc
.lpfnWndProc
= ie_window_proc
;
92 wc
.cbWndExtra
= sizeof(InternetExplorer
*);
93 wc
.hInstance
= shdocvw_hinstance
;
95 wc
.hCursor
= LoadCursorW(0, MAKEINTRESOURCEW(IDI_APPLICATION
));
97 wc
.lpszClassName
= szIEWinFrame
;
98 wc
.lpszMenuName
= NULL
;
103 void unregister_iewindow_class(void)
105 UnregisterClassW(szIEWinFrame
, shdocvw_hinstance
);
108 static void create_frame_hwnd(InternetExplorer
*This
)
110 /* Windows uses "Microsoft Internet Explorer" */
111 static const WCHAR wszWineInternetExplorer
[] =
112 {'W','i','n','e',' ','I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r',0};
114 This
->frame_hwnd
= CreateWindowExW(
116 szIEWinFrame
, wszWineInternetExplorer
,
117 WS_CLIPCHILDREN
| WS_CAPTION
| WS_SYSMENU
| WS_THICKFRAME
118 | WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
,
119 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
120 NULL
, NULL
/* FIXME */, shdocvw_hinstance
, This
);
123 static IWebBrowser2
*create_ie_window(LPCSTR cmdline
)
125 IWebBrowser2
*wb
= NULL
;
127 InternetExplorer_Create(NULL
, &IID_IWebBrowser2
, (void**)&wb
);
131 IWebBrowser2_put_Visible(wb
, VARIANT_TRUE
);
134 IWebBrowser2_GoHome(wb
);
139 if(!strncasecmp(cmdline
, "-nohome", 7))
142 V_VT(&var_url
) = VT_BSTR
;
144 len
= MultiByteToWideChar(CP_ACP
, 0, cmdline
, -1, NULL
, 0);
145 V_BSTR(&var_url
) = SysAllocStringLen(NULL
, len
);
146 MultiByteToWideChar(CP_ACP
, 0, cmdline
, -1, V_BSTR(&var_url
), len
);
148 /* navigate to the first page */
149 IWebBrowser2_Navigate2(wb
, &var_url
, NULL
, NULL
, NULL
, NULL
);
151 SysFreeString(V_BSTR(&var_url
));
157 HRESULT
InternetExplorer_Create(IUnknown
*pOuter
, REFIID riid
, void **ppv
)
159 InternetExplorer
*ret
;
162 TRACE("(%p %s %p)\n", pOuter
, debugstr_guid(riid
), ppv
);
164 ret
= shdocvw_alloc(sizeof(InternetExplorer
));
167 ret
->doc_host
.disp
= (IDispatch
*)WEBBROWSER2(ret
);
168 DocHost_Init(&ret
->doc_host
, (IDispatch
*)WEBBROWSER2(ret
));
170 InternetExplorer_WebBrowser_Init(ret
);
172 create_frame_hwnd(ret
);
173 ret
->doc_host
.frame_hwnd
= ret
->frame_hwnd
;
175 hres
= IWebBrowser2_QueryInterface(WEBBROWSER2(ret
), riid
, ppv
);
184 /******************************************************************
185 * IEWinMain (SHDOCVW.101)
187 * Only returns on error.
189 DWORD WINAPI
IEWinMain(LPSTR szCommandLine
, int nShowWindow
)
191 IWebBrowser2
*wb
= NULL
;
195 TRACE("%s %d\n", debugstr_a(szCommandLine
), nShowWindow
);
197 if(*szCommandLine
== '-' || *szCommandLine
== '/') {
198 if(!strcasecmp(szCommandLine
+1, "regserver"))
199 return register_iexplore(TRUE
);
200 if(!strcasecmp(szCommandLine
+1, "unregserver"))
201 return register_iexplore(FALSE
);
206 hres
= register_class_object(TRUE
);
212 if(strcasecmp(szCommandLine
, "-embedding"))
213 wb
= create_ie_window(szCommandLine
);
215 /* run the message loop for this thread */
216 while (GetMessageW(&msg
, 0, 0, 0))
218 TranslateMessage(&msg
);
219 DispatchMessageW(&msg
);
223 IWebBrowser2_Release(wb
);
225 register_class_object(FALSE
);