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
41 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
47 #define DOCHOST_THIS(iface) DEFINE_THIS2(InternetExplorer,doc_host,iface)
49 static const WCHAR szIEWinFrame[] = { 'I','E','F','r','a','m','e',0 };
51 /* Windows uses "Microsoft Internet Explorer" */
52 static const WCHAR wszWineInternetExplorer[] =
53 {'W','i','n','e',' ','I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r',0};
55 HRESULT update_ie_statustext(InternetExplorer* This, LPCWSTR text)
57 if(!SendMessageW(This->status_hwnd, SB_SETTEXTW, MAKEWORD(SB_SIMPLEID, 0), (LPARAM)text))
63 static void adjust_ie_docobj_rect(HWND frame, RECT* rc)
65 HWND hwndRebar = GetDlgItem(frame, IDC_BROWSE_REBAR);
66 HWND hwndStatus = GetDlgItem(frame, IDC_BROWSE_STATUSBAR);
67 INT barHeight = SendMessageW(hwndRebar, RB_GETBARHEIGHT, 0, 0);
70 rc->bottom -= barHeight;
72 if(IsWindowVisible(hwndStatus))
76 GetClientRect(hwndStatus, &statusrc);
77 rc->bottom -= statusrc.bottom - statusrc.top;
81 static HMENU get_tb_menu(HMENU menu)
83 HMENU menu_view = GetSubMenu(menu, 1);
85 return GetSubMenu(menu_view, 0);
88 static HMENU get_fav_menu(HMENU menu)
90 return GetSubMenu(menu, 2);
93 static LPWSTR get_fav_url_from_id(HMENU menu, UINT id)
97 item.cbSize = sizeof(item);
98 item.fMask = MIIM_DATA;
100 if(!GetMenuItemInfoW(menu, id, FALSE, &item))
103 return (LPWSTR)item.dwItemData;
106 static void free_fav_menu_data(HMENU menu)
111 for(i = 0; (url = get_fav_url_from_id(menu, ID_BROWSE_GOTOFAV_FIRST + i)); i++)
115 static int get_menu_item_count(HMENU menu)
121 item.cbSize = sizeof(item);
122 item.fMask = MIIM_DATA | MIIM_SUBMENU;
124 for(i = 0; GetMenuItemInfoW(menu, i, TRUE, &item); i++)
127 count += get_menu_item_count(item.hSubMenu);
135 static void add_fav_to_menu(HMENU favmenu, HMENU menu, LPWSTR title, LPCWSTR url)
138 /* Subtract the number of standard elements in the Favorites menu */
139 int favcount = get_menu_item_count(favmenu) - 2;
142 if(favcount > (ID_BROWSE_GOTOFAV_MAX - ID_BROWSE_GOTOFAV_FIRST))
144 FIXME("Add support for more than %d Favorites\n", favcount);
148 urlbuf = heap_alloc((lstrlenW(url) + 1) * sizeof(WCHAR));
153 lstrcpyW(urlbuf, url);
155 item.cbSize = sizeof(item);
156 item.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_DATA | MIIM_ID;
157 item.fType = MFT_STRING;
158 item.dwTypeData = title;
159 item.wID = ID_BROWSE_GOTOFAV_FIRST + favcount;
160 item.dwItemData = (ULONG_PTR)urlbuf;
161 InsertMenuItemW(menu, -1, TRUE, &item);
164 static void add_favs_to_menu(HMENU favmenu, HMENU menu, LPCWSTR dir)
166 WCHAR path[MAX_PATH*2];
167 const WCHAR search[] = {'*',0};
170 WIN32_FIND_DATAW finddata;
171 IUniformResourceLocatorW* urlobj;
172 IPersistFile* urlfile;
176 PathAppendW(path, search);
178 findhandle = FindFirstFileW(path, &finddata);
180 if(findhandle == INVALID_HANDLE_VALUE)
183 res = CoCreateInstance(&CLSID_InternetShortcut, NULL, CLSCTX_INPROC_SERVER, &IID_IUniformResourceLocatorW, (PVOID*)&urlobj);
186 res = IUnknown_QueryInterface(urlobj, &IID_IPersistFile, (PVOID*)&urlfile);
190 filename = path + lstrlenW(path) - lstrlenW(search);
194 lstrcpyW(filename, finddata.cFileName);
196 if(finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
199 const WCHAR ignore1[] = {'.','.',0};
200 const WCHAR ignore2[] = {'.',0};
202 if(!lstrcmpW(filename, ignore1) || !lstrcmpW(filename, ignore2))
205 item.cbSize = sizeof(item);
206 item.fMask = MIIM_STRING | MIIM_SUBMENU;
207 item.dwTypeData = filename;
208 item.hSubMenu = CreatePopupMenu();
209 InsertMenuItemW(menu, -1, TRUE, &item);
210 add_favs_to_menu(favmenu, item.hSubMenu, path);
215 const WCHAR urlext[] = {'.','u','r','l',0};
217 if(lstrcmpiW(PathFindExtensionW(filename), urlext))
220 if(FAILED(IPersistFile_Load(urlfile, path, 0)))
223 urlobj->lpVtbl->GetURL(urlobj, &url);
228 fileext = filename + lstrlenW(filename) - lstrlenW(urlext);
230 add_fav_to_menu(favmenu, menu, filename, url);
232 } while(FindNextFileW(findhandle, &finddata));
236 IPersistFile_Release(urlfile);
239 IUnknown_Release(urlobj);
241 FindClose(findhandle);
244 static void add_tbs_to_menu(HMENU menu)
246 HUSKEY toolbar_handle;
247 WCHAR toolbar_key[] = {'S','o','f','t','w','a','r','e','\\',
248 'M','i','c','r','o','s','o','f','t','\\',
249 'I','n','t','e','r','n','e','t',' ',
250 'E','x','p','l','o','r','e','r','\\',
251 'T','o','o','l','b','a','r',0};
253 if(SHRegOpenUSKeyW(toolbar_key, KEY_READ, NULL, &toolbar_handle, TRUE) == ERROR_SUCCESS)
255 HUSKEY classes_handle;
256 WCHAR classes_key[] = {'S','o','f','t','w','a','r','e','\\',
257 'C','l','a','s','s','e','s','\\','C','L','S','I','D',0};
259 DWORD value_len = sizeof(guid)/sizeof(guid[0]);
262 if(SHRegOpenUSKeyW(classes_key, KEY_READ, NULL, &classes_handle, TRUE) != ERROR_SUCCESS)
264 SHRegCloseUSKey(toolbar_handle);
265 ERR("Failed to open key %s\n", debugstr_w(classes_key));
269 for(i = 0; SHRegEnumUSValueW(toolbar_handle, i, guid, &value_len, NULL, NULL, NULL, SHREGENUM_HKLM) == ERROR_SUCCESS; i++)
272 DWORD tb_name_len = sizeof(tb_name)/sizeof(tb_name[0]);
273 HUSKEY tb_class_handle;
276 value_len = sizeof(guid)/sizeof(guid[0]);
278 if(lstrlenW(guid) != 38)
280 TRACE("Found invalid IE toolbar entry: %s\n", debugstr_w(guid));
284 if(SHRegOpenUSKeyW(guid, KEY_READ, classes_handle, &tb_class_handle, TRUE) != ERROR_SUCCESS)
286 ERR("Failed to get class info for %s\n", debugstr_w(guid));
290 ret = SHRegQueryUSValueW(tb_class_handle, NULL, NULL, tb_name, &tb_name_len, TRUE, NULL, 0);
292 SHRegCloseUSKey(tb_class_handle);
294 if(ret != ERROR_SUCCESS)
296 ERR("Failed to get toolbar name for %s\n", debugstr_w(guid));
300 item.cbSize = sizeof(item);
301 item.fMask = MIIM_STRING;
302 item.dwTypeData = tb_name;
303 InsertMenuItemW(menu, GetMenuItemCount(menu), TRUE, &item);
306 SHRegCloseUSKey(classes_handle);
307 SHRegCloseUSKey(toolbar_handle);
311 static HMENU create_ie_menu(void)
313 HMENU menu = LoadMenuW(shdocvw_hinstance, MAKEINTRESOURCEW(IDR_BROWSE_MAIN_MENU));
314 HMENU favmenu = get_fav_menu(menu);
315 WCHAR path[MAX_PATH];
317 add_tbs_to_menu(get_tb_menu(menu));
319 if(SHGetFolderPathW(NULL, CSIDL_COMMON_FAVORITES, NULL, SHGFP_TYPE_CURRENT, path) == S_OK)
320 add_favs_to_menu(favmenu, favmenu, path);
322 if(SHGetFolderPathW(NULL, CSIDL_FAVORITES, NULL, SHGFP_TYPE_CURRENT, path) == S_OK)
323 add_favs_to_menu(favmenu, favmenu, path);
328 static void ie_navigate(InternetExplorer* This, LPCWSTR url)
332 V_VT(&variant) = VT_BSTR;
333 V_BSTR(&variant) = SysAllocString(url);
335 IWebBrowser2_Navigate2(&This->IWebBrowser2_iface, &variant, NULL, NULL, NULL, NULL);
337 SysFreeString(V_BSTR(&variant));
340 static INT_PTR CALLBACK ie_dialog_open_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
342 static InternetExplorer* This;
347 This = (InternetExplorer*)lparam;
348 EnableWindow(GetDlgItem(hwnd, IDOK), FALSE);
352 switch(LOWORD(wparam))
354 case IDC_BROWSE_OPEN_URL:
356 HWND hwndurl = GetDlgItem(hwnd, IDC_BROWSE_OPEN_URL);
357 int len = GetWindowTextLengthW(hwndurl);
359 EnableWindow(GetDlgItem(hwnd, IDOK), len ? TRUE : FALSE);
364 HWND hwndurl = GetDlgItem(hwnd, IDC_BROWSE_OPEN_URL);
365 int len = GetWindowTextLengthW(hwndurl);
371 V_VT(&url) = VT_BSTR;
372 V_BSTR(&url) = SysAllocStringLen(NULL, len);
374 GetWindowTextW(hwndurl, V_BSTR(&url), len + 1);
375 IWebBrowser2_Navigate2(&This->IWebBrowser2_iface, &url, NULL, NULL, NULL, NULL);
377 SysFreeString(V_BSTR(&url));
382 EndDialog(hwnd, wparam);
389 static void ie_dialog_about(HWND hwnd)
391 HICON icon = LoadImageW(GetModuleHandleW(0), MAKEINTRESOURCEW(IDI_APPICON), IMAGE_ICON, 48, 48, LR_SHARED);
393 ShellAboutW(hwnd, wszWineInternetExplorer, NULL, icon);
398 static void add_tb_separator(HWND hwnd)
402 ZeroMemory(&btn, sizeof(btn));
405 btn.fsStyle = BTNS_SEP;
406 SendMessageW(hwnd, TB_ADDBUTTONSW, 1, (LPARAM)&btn);
409 static void add_tb_button(HWND hwnd, int bmp, int cmd, int strId)
414 LoadStringW(shdocvw_hinstance, strId, buf, sizeof(buf)/sizeof(buf[0]));
418 btn.fsState = TBSTATE_ENABLED;
419 btn.fsStyle = BTNS_SHOWTEXT;
421 btn.iString = (INT_PTR)buf;
423 SendMessageW(hwnd, TB_ADDBUTTONSW, 1, (LPARAM)&btn);
426 static void create_rebar(HWND hwnd)
432 REBARBANDINFOW bandinf;
434 HIMAGELIST imagelist;
435 WCHAR idb_ietoolbar[] = {'I','D','B','_','I','E','T','O','O','L','B','A','R',0};
437 LoadStringW(shdocvw_hinstance, IDS_ADDRESS, addr, sizeof(addr)/sizeof(addr[0]));
439 hwndRebar = CreateWindowExW(WS_EX_TOOLWINDOW, REBARCLASSNAMEW, NULL, WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|RBS_VARHEIGHT|CCS_TOP|CCS_NODIVIDER, 0, 0, 0, 0, hwnd, (HMENU)IDC_BROWSE_REBAR, shdocvw_hinstance, NULL);
441 rebarinf.cbSize = sizeof(rebarinf);
443 rebarinf.himl = NULL;
444 rebarinf.cbSize = sizeof(rebarinf);
446 SendMessageW(hwndRebar, RB_SETBARINFO, 0, (LPARAM)&rebarinf);
448 hwndToolbar = CreateWindowExW(TBSTYLE_EX_MIXEDBUTTONS, TOOLBARCLASSNAMEW, NULL, TBSTYLE_FLAT | WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hwndRebar, (HMENU)IDC_BROWSE_TOOLBAR, shdocvw_hinstance, NULL);
450 imagelist = ImageList_LoadImageW(shdocvw_hinstance, idb_ietoolbar, 32, 0, CLR_NONE, IMAGE_BITMAP, LR_CREATEDIBSECTION);
452 SendMessageW(hwndToolbar, TB_SETIMAGELIST, 0, (LPARAM)imagelist);
453 SendMessageW(hwndToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
454 add_tb_button(hwndToolbar, 0, 0, IDS_TB_BACK);
455 add_tb_button(hwndToolbar, 1, 0, IDS_TB_FORWARD);
456 add_tb_button(hwndToolbar, 2, 0, IDS_TB_STOP);
457 add_tb_button(hwndToolbar, 3, 0, IDS_TB_REFRESH);
458 add_tb_button(hwndToolbar, 4, ID_BROWSE_HOME, IDS_TB_HOME);
459 add_tb_separator(hwndToolbar);
460 add_tb_button(hwndToolbar, 5, ID_BROWSE_PRINT, IDS_TB_PRINT);
461 SendMessageW(hwndToolbar, TB_SETBUTTONSIZE, 0, MAKELPARAM(55,50));
462 SendMessageW(hwndToolbar, TB_AUTOSIZE, 0, 0);
464 bandinf.cbSize = sizeof(bandinf);
465 bandinf.fMask = RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE;
466 bandinf.fStyle = RBBS_CHILDEDGE;
468 bandinf.cyMinChild = 52;
469 bandinf.hwndChild = hwndToolbar;
471 SendMessageW(hwndRebar, RB_INSERTBANDW, -1, (LPARAM)&bandinf);
473 hwndAddress = CreateWindowExW(0, WC_COMBOBOXEXW, NULL, WS_BORDER|WS_CHILD|WS_VISIBLE|CBS_DROPDOWN, 0, 0, 100,20,hwndRebar, (HMENU)IDC_BROWSE_ADDRESSBAR, shdocvw_hinstance, NULL);
475 bandinf.fMask |= RBBIM_TEXT;
476 bandinf.fStyle = RBBS_CHILDEDGE | RBBS_BREAK;
477 bandinf.lpText = addr;
478 bandinf.cyMinChild = 20;
479 bandinf.hwndChild = hwndAddress;
481 SendMessageW(hwndRebar, RB_INSERTBANDW, -1, (LPARAM)&bandinf);
484 static LRESULT iewnd_OnCreate(HWND hwnd, LPCREATESTRUCTW lpcs)
486 InternetExplorer* This = (InternetExplorer*)lpcs->lpCreateParams;
487 SetWindowLongPtrW(hwnd, 0, (LONG_PTR) lpcs->lpCreateParams);
489 This->menu = create_ie_menu();
491 This->status_hwnd = CreateStatusWindowW(WS_VISIBLE|WS_CHILD|SBT_NOBORDERS|CCS_NODIVIDER,
492 NULL, hwnd, IDC_BROWSE_STATUSBAR);
493 SendMessageW(This->status_hwnd, SB_SIMPLE, TRUE, 0);
500 static LRESULT iewnd_OnSize(InternetExplorer *This, INT width, INT height)
502 HWND hwndRebar = GetDlgItem(This->frame_hwnd, IDC_BROWSE_REBAR);
503 INT barHeight = SendMessageW(hwndRebar, RB_GETBARHEIGHT, 0, 0);
504 RECT docarea = {0, 0, width, height};
506 SendMessageW(This->status_hwnd, WM_SIZE, 0, 0);
508 adjust_ie_docobj_rect(This->frame_hwnd, &docarea);
510 if(This->doc_host.hwnd)
511 SetWindowPos(This->doc_host.hwnd, NULL, docarea.left, docarea.top, docarea.right, docarea.bottom,
512 SWP_NOZORDER | SWP_NOACTIVATE);
514 SetWindowPos(hwndRebar, NULL, 0, 0, width, barHeight, SWP_NOZORDER | SWP_NOACTIVATE);
519 static LRESULT iewnd_OnNotify(InternetExplorer *This, WPARAM wparam, LPARAM lparam)
521 NMHDR* hdr = (NMHDR*)lparam;
523 if(hdr->idFrom == IDC_BROWSE_ADDRESSBAR && hdr->code == CBEN_ENDEDITW)
525 NMCBEENDEDITW* info = (NMCBEENDEDITW*)lparam;
527 if(info->fChanged && info->iWhy == CBENF_RETURN && info->szText)
532 V_BSTR(&vt) = SysAllocString(info->szText);
534 IWebBrowser2_Navigate2(&This->IWebBrowser2_iface, &vt, NULL, NULL, NULL, NULL);
536 SysFreeString(V_BSTR(&vt));
545 static LRESULT iewnd_OnDestroy(InternetExplorer *This)
547 HWND hwndRebar = GetDlgItem(This->frame_hwnd, IDC_BROWSE_REBAR);
548 HWND hwndToolbar = GetDlgItem(hwndRebar, IDC_BROWSE_TOOLBAR);
549 HIMAGELIST list = (HIMAGELIST)SendMessageW(hwndToolbar, TB_GETIMAGELIST, 0, 0);
553 free_fav_menu_data(get_fav_menu(This->menu));
554 ImageList_Destroy(list);
555 This->frame_hwnd = NULL;
556 PostQuitMessage(0); /* FIXME */
561 static LRESULT iewnd_OnCommand(InternetExplorer *This, HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
563 switch(LOWORD(wparam))
566 DialogBoxParamW(shdocvw_hinstance, MAKEINTRESOURCEW(IDD_BROWSE_OPEN), hwnd, ie_dialog_open_proc, (LPARAM)This);
569 case ID_BROWSE_PRINT:
570 if(This->doc_host.document)
572 IOleCommandTarget* target;
574 if(FAILED(IUnknown_QueryInterface(This->doc_host.document, &IID_IOleCommandTarget, (LPVOID*)&target)))
577 IOleCommandTarget_Exec(target, &CGID_MSHTML, IDM_PRINT, OLECMDEXECOPT_DODEFAULT, NULL, NULL);
579 IOleCommandTarget_Release(target);
584 IWebBrowser2_GoHome(&This->IWebBrowser2_iface);
587 case ID_BROWSE_ABOUT:
588 ie_dialog_about(hwnd);
592 iewnd_OnDestroy(This);
596 if(LOWORD(wparam) >= ID_BROWSE_GOTOFAV_FIRST && LOWORD(wparam) <= ID_BROWSE_GOTOFAV_MAX)
598 LPCWSTR url = get_fav_url_from_id(get_fav_menu(This->menu), LOWORD(wparam));
601 ie_navigate(This, url);
603 return DefWindowProcW(hwnd, msg, wparam, lparam);
608 static LRESULT update_addrbar(InternetExplorer *This, LPARAM lparam)
610 HWND hwndRebar = GetDlgItem(This->frame_hwnd, IDC_BROWSE_REBAR);
611 HWND hwndAddress = GetDlgItem(hwndRebar, IDC_BROWSE_ADDRESSBAR);
612 HWND hwndEdit = (HWND)SendMessageW(hwndAddress, CBEM_GETEDITCONTROL, 0, 0);
613 LPCWSTR url = (LPCWSTR)lparam;
615 SendMessageW(hwndEdit, WM_SETTEXT, 0, (LPARAM)url);
620 static LRESULT CALLBACK
621 ie_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
623 InternetExplorer *This = (InternetExplorer*) GetWindowLongPtrW(hwnd, 0);
628 return iewnd_OnCreate(hwnd, (LPCREATESTRUCTW)lparam);
630 return iewnd_OnDestroy(This);
632 return iewnd_OnSize(This, LOWORD(lparam), HIWORD(lparam));
634 return iewnd_OnCommand(This, hwnd, msg, wparam, lparam);
636 return iewnd_OnNotify(This, wparam, lparam);
638 return process_dochost_task(&This->doc_host, lparam);
639 case WM_UPDATEADDRBAR:
640 return update_addrbar(This, lparam);
642 return DefWindowProcW(hwnd, msg, wparam, lparam);
645 void register_iewindow_class(void)
649 memset(&wc, 0, sizeof wc);
650 wc.cbSize = sizeof(wc);
652 wc.lpfnWndProc = ie_window_proc;
654 wc.cbWndExtra = sizeof(InternetExplorer*);
655 wc.hInstance = shdocvw_hinstance;
656 wc.hIcon = LoadIconW(GetModuleHandleW(0), MAKEINTRESOURCEW(IDI_APPICON));
657 wc.hIconSm = LoadImageW(GetModuleHandleW(0), MAKEINTRESOURCEW(IDI_APPICON), IMAGE_ICON,
658 GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED);
659 wc.hCursor = LoadCursorW(0, MAKEINTRESOURCEW(IDC_ARROW));
660 wc.hbrBackground = 0;
661 wc.lpszClassName = szIEWinFrame;
662 wc.lpszMenuName = NULL;
664 RegisterClassExW(&wc);
667 void unregister_iewindow_class(void)
669 UnregisterClassW(szIEWinFrame, shdocvw_hinstance);
672 static void create_frame_hwnd(InternetExplorer *This)
674 This->frame_hwnd = CreateWindowExW(
676 szIEWinFrame, wszWineInternetExplorer,
677 WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
678 | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
679 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
680 NULL, NULL /* FIXME */, shdocvw_hinstance, This);
683 static IWebBrowser2 *create_ie_window(LPCSTR cmdline)
685 IWebBrowser2 *wb = NULL;
687 InternetExplorer_Create(NULL, &IID_IWebBrowser2, (void**)&wb);
691 IWebBrowser2_put_Visible(wb, VARIANT_TRUE);
692 IWebBrowser2_put_MenuBar(wb, VARIANT_TRUE);
695 IWebBrowser2_GoHome(wb);
701 if(!strncasecmp(cmdline, "-nohome", 7))
703 while(*cmdline == ' ' || *cmdline == '\t')
705 cmdlen = lstrlenA(cmdline);
706 if(cmdlen > 2 && cmdline[0] == '"' && cmdline[cmdlen-1] == '"') {
711 V_VT(&var_url) = VT_BSTR;
713 len = MultiByteToWideChar(CP_ACP, 0, cmdline, cmdlen, NULL, 0);
714 V_BSTR(&var_url) = SysAllocStringLen(NULL, len);
715 MultiByteToWideChar(CP_ACP, 0, cmdline, cmdlen, V_BSTR(&var_url), len);
717 /* navigate to the first page */
718 IWebBrowser2_Navigate2(wb, &var_url, NULL, NULL, NULL, NULL);
720 SysFreeString(V_BSTR(&var_url));
726 static inline InternetExplorer *impl_from_DocHost(DocHost *iface)
728 return CONTAINING_RECORD(iface, InternetExplorer, doc_host);
731 static void WINAPI DocHostContainer_GetDocObjRect(DocHost* This, RECT* rc)
733 GetClientRect(This->frame_hwnd, rc);
734 adjust_ie_docobj_rect(This->frame_hwnd, rc);
737 static HRESULT WINAPI DocHostContainer_SetStatusText(DocHost* This, LPCWSTR text)
739 InternetExplorer* ie = impl_from_DocHost(This);
740 return update_ie_statustext(ie, text);
743 static void WINAPI DocHostContainer_SetURL(DocHost* This, LPCWSTR url)
745 SendMessageW(This->frame_hwnd, WM_UPDATEADDRBAR, 0, (LPARAM)url);
748 static HRESULT DocHostContainer_exec(DocHost* This, const GUID *cmd_group, DWORD cmdid, DWORD execopt, VARIANT *in,
753 static const IDocHostContainerVtbl DocHostContainerVtbl = {
754 DocHostContainer_GetDocObjRect,
755 DocHostContainer_SetStatusText,
756 DocHostContainer_SetURL,
757 DocHostContainer_exec
760 HRESULT InternetExplorer_Create(IUnknown *pOuter, REFIID riid, void **ppv)
762 InternetExplorer *ret;
765 TRACE("(%p %s %p)\n", pOuter, debugstr_guid(riid), ppv);
767 ret = heap_alloc_zero(sizeof(InternetExplorer));
770 ret->doc_host.disp = (IDispatch*)&ret->IWebBrowser2_iface;
771 DocHost_Init(&ret->doc_host, (IDispatch*)&ret->IWebBrowser2_iface, &DocHostContainerVtbl);
773 InternetExplorer_WebBrowser_Init(ret);
775 HlinkFrame_Init(&ret->hlink_frame, (IUnknown*)&ret->IWebBrowser2_iface, &ret->doc_host);
777 create_frame_hwnd(ret);
778 ret->doc_host.frame_hwnd = ret->frame_hwnd;
780 hres = IWebBrowser2_QueryInterface(&ret->IWebBrowser2_iface, riid, ppv);
789 /******************************************************************
790 * IEWinMain (SHDOCVW.101)
792 * Only returns on error.
794 DWORD WINAPI IEWinMain(LPSTR szCommandLine, int nShowWindow)
796 IWebBrowser2 *wb = NULL;
800 TRACE("%s %d\n", debugstr_a(szCommandLine), nShowWindow);
802 if(*szCommandLine == '-' || *szCommandLine == '/') {
803 if(!strcasecmp(szCommandLine+1, "regserver"))
804 return register_iexplore(TRUE);
805 if(!strcasecmp(szCommandLine+1, "unregserver"))
806 return register_iexplore(FALSE);
811 hres = register_class_object(TRUE);
817 if(strcasecmp(szCommandLine, "-embedding"))
818 wb = create_ie_window(szCommandLine);
820 /* run the message loop for this thread */
821 while (GetMessageW(&msg, 0, 0, 0))
823 TranslateMessage(&msg);
824 DispatchMessageW(&msg);
828 IWebBrowser2_Release(wb);
830 register_class_object(FALSE);