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 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(WEBBROWSER2(This
), &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(WEBBROWSER2(This
), &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, RGB(255,0,255), IMAGE_BITMAP
, LR_DEFAULTCOLOR
);
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(CCS_NODIVIDER
|WS_CHILD
|WS_VISIBLE
, NULL
, hwnd
, IDC_BROWSE_STATUSBAR
);
492 SendMessageW(This
->status_hwnd
, SB_SIMPLE
, TRUE
, 0);
499 static LRESULT
iewnd_OnSize(InternetExplorer
*This
, INT width
, INT height
)
501 HWND hwndRebar
= GetDlgItem(This
->frame_hwnd
, IDC_BROWSE_REBAR
);
502 INT barHeight
= SendMessageW(hwndRebar
, RB_GETBARHEIGHT
, 0, 0);
503 RECT docarea
= {0, 0, width
, height
};
505 SendMessageW(This
->status_hwnd
, WM_SIZE
, 0, 0);
507 adjust_ie_docobj_rect(This
->frame_hwnd
, &docarea
);
509 if(This
->doc_host
.hwnd
)
510 SetWindowPos(This
->doc_host
.hwnd
, NULL
, docarea
.left
, docarea
.top
, docarea
.right
, docarea
.bottom
,
511 SWP_NOZORDER
| SWP_NOACTIVATE
);
513 SetWindowPos(hwndRebar
, NULL
, 0, 0, width
, barHeight
, SWP_NOZORDER
| SWP_NOACTIVATE
);
518 static LRESULT
iewnd_OnNotify(InternetExplorer
*This
, WPARAM wparam
, LPARAM lparam
)
520 NMHDR
* hdr
= (NMHDR
*)lparam
;
522 if(hdr
->idFrom
== IDC_BROWSE_ADDRESSBAR
&& hdr
->code
== CBEN_ENDEDITW
)
524 NMCBEENDEDITW
* info
= (NMCBEENDEDITW
*)lparam
;
526 if(info
->fChanged
&& info
->iWhy
== CBENF_RETURN
&& info
->szText
)
531 V_BSTR(&vt
) = SysAllocString(info
->szText
);
533 IWebBrowser2_Navigate2(WEBBROWSER2(This
), &vt
, NULL
, NULL
, NULL
, NULL
);
535 SysFreeString(V_BSTR(&vt
));
544 static LRESULT
iewnd_OnDestroy(InternetExplorer
*This
)
546 HWND hwndRebar
= GetDlgItem(This
->frame_hwnd
, IDC_BROWSE_REBAR
);
547 HWND hwndToolbar
= GetDlgItem(hwndRebar
, IDC_BROWSE_TOOLBAR
);
548 HIMAGELIST list
= (HIMAGELIST
)SendMessageW(hwndToolbar
, TB_GETIMAGELIST
, 0, 0);
552 free_fav_menu_data(get_fav_menu(This
->menu
));
553 ImageList_Destroy(list
);
554 This
->frame_hwnd
= NULL
;
555 PostQuitMessage(0); /* FIXME */
560 static LRESULT CALLBACK
iewnd_OnCommand(InternetExplorer
*This
, HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
562 switch(LOWORD(wparam
))
565 DialogBoxParamW(shdocvw_hinstance
, MAKEINTRESOURCEW(IDD_BROWSE_OPEN
), hwnd
, ie_dialog_open_proc
, (LPARAM
)This
);
568 case ID_BROWSE_PRINT
:
569 if(This
->doc_host
.document
)
571 IOleCommandTarget
* target
;
573 if(FAILED(IUnknown_QueryInterface(This
->doc_host
.document
, &IID_IOleCommandTarget
, (LPVOID
*)&target
)))
576 IOleCommandTarget_Exec(target
, &CGID_MSHTML
, IDM_PRINT
, OLECMDEXECOPT_DODEFAULT
, NULL
, NULL
);
578 IOleCommandTarget_Release(target
);
583 IWebBrowser2_GoHome(WEBBROWSER2(This
));
586 case ID_BROWSE_ABOUT
:
587 ie_dialog_about(hwnd
);
591 if(LOWORD(wparam
) >= ID_BROWSE_GOTOFAV_FIRST
&& LOWORD(wparam
) <= ID_BROWSE_GOTOFAV_MAX
)
593 LPCWSTR url
= get_fav_url_from_id(get_fav_menu(This
->menu
), LOWORD(wparam
));
596 ie_navigate(This
, url
);
598 return DefWindowProcW(hwnd
, msg
, wparam
, lparam
);
603 static LRESULT CALLBACK
update_addrbar(InternetExplorer
*This
, LPARAM lparam
)
605 HWND hwndRebar
= GetDlgItem(This
->frame_hwnd
, IDC_BROWSE_REBAR
);
606 HWND hwndAddress
= GetDlgItem(hwndRebar
, IDC_BROWSE_ADDRESSBAR
);
607 HWND hwndEdit
= (HWND
)SendMessageW(hwndAddress
, CBEM_GETEDITCONTROL
, 0, 0);
608 LPCWSTR url
= (LPCWSTR
)lparam
;
610 SendMessageW(hwndEdit
, WM_SETTEXT
, 0, (LPARAM
)url
);
615 static LRESULT CALLBACK
616 ie_window_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
618 InternetExplorer
*This
= (InternetExplorer
*) GetWindowLongPtrW(hwnd
, 0);
623 return iewnd_OnCreate(hwnd
, (LPCREATESTRUCTW
)lparam
);
625 return iewnd_OnDestroy(This
);
627 return iewnd_OnSize(This
, LOWORD(lparam
), HIWORD(lparam
));
629 return iewnd_OnCommand(This
, hwnd
, msg
, wparam
, lparam
);
631 return iewnd_OnNotify(This
, wparam
, lparam
);
633 return process_dochost_task(&This
->doc_host
, lparam
);
634 case WM_UPDATEADDRBAR
:
635 return update_addrbar(This
, lparam
);
637 return DefWindowProcW(hwnd
, msg
, wparam
, lparam
);
640 void register_iewindow_class(void)
644 memset(&wc
, 0, sizeof wc
);
645 wc
.cbSize
= sizeof(wc
);
647 wc
.lpfnWndProc
= ie_window_proc
;
649 wc
.cbWndExtra
= sizeof(InternetExplorer
*);
650 wc
.hInstance
= shdocvw_hinstance
;
651 wc
.hIcon
= LoadIconW(GetModuleHandleW(0), MAKEINTRESOURCEW(IDI_APPICON
));
652 wc
.hIconSm
= LoadImageW(GetModuleHandleW(0), MAKEINTRESOURCEW(IDI_APPICON
), IMAGE_ICON
,
653 GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), LR_SHARED
);
654 wc
.hCursor
= LoadCursorW(0, MAKEINTRESOURCEW(IDC_ARROW
));
655 wc
.hbrBackground
= 0;
656 wc
.lpszClassName
= szIEWinFrame
;
657 wc
.lpszMenuName
= NULL
;
659 RegisterClassExW(&wc
);
662 void unregister_iewindow_class(void)
664 UnregisterClassW(szIEWinFrame
, shdocvw_hinstance
);
667 static void create_frame_hwnd(InternetExplorer
*This
)
669 This
->frame_hwnd
= CreateWindowExW(
671 szIEWinFrame
, wszWineInternetExplorer
,
672 WS_CLIPCHILDREN
| WS_CAPTION
| WS_SYSMENU
| WS_THICKFRAME
673 | WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
,
674 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
675 NULL
, NULL
/* FIXME */, shdocvw_hinstance
, This
);
678 static IWebBrowser2
*create_ie_window(LPCSTR cmdline
)
680 IWebBrowser2
*wb
= NULL
;
682 InternetExplorer_Create(NULL
, &IID_IWebBrowser2
, (void**)&wb
);
686 IWebBrowser2_put_Visible(wb
, VARIANT_TRUE
);
687 IWebBrowser2_put_MenuBar(wb
, VARIANT_TRUE
);
690 IWebBrowser2_GoHome(wb
);
696 if(!strncasecmp(cmdline
, "-nohome", 7))
698 while(*cmdline
== ' ' || *cmdline
== '\t')
700 cmdlen
= lstrlenA(cmdline
);
701 if(cmdlen
> 2 && cmdline
[0] == '"' && cmdline
[cmdlen
-1] == '"') {
706 V_VT(&var_url
) = VT_BSTR
;
708 len
= MultiByteToWideChar(CP_ACP
, 0, cmdline
, cmdlen
, NULL
, 0);
709 V_BSTR(&var_url
) = SysAllocStringLen(NULL
, len
);
710 MultiByteToWideChar(CP_ACP
, 0, cmdline
, cmdlen
, V_BSTR(&var_url
), len
);
712 /* navigate to the first page */
713 IWebBrowser2_Navigate2(wb
, &var_url
, NULL
, NULL
, NULL
, NULL
);
715 SysFreeString(V_BSTR(&var_url
));
721 static void WINAPI
DocHostContainer_GetDocObjRect(DocHost
* This
, RECT
* rc
)
723 GetClientRect(This
->frame_hwnd
, rc
);
724 adjust_ie_docobj_rect(This
->frame_hwnd
, rc
);
727 static HRESULT WINAPI
DocHostContainer_SetStatusText(DocHost
* This
, LPCWSTR text
)
729 InternetExplorer
* ie
= DOCHOST_THIS(This
);
730 return update_ie_statustext(ie
, text
);
733 static void WINAPI
DocHostContainer_SetURL(DocHost
* This
, LPCWSTR url
)
735 SendMessageW(This
->frame_hwnd
, WM_UPDATEADDRBAR
, 0, (LPARAM
)url
);
738 static const IDocHostContainerVtbl DocHostContainerVtbl
= {
739 DocHostContainer_GetDocObjRect
,
740 DocHostContainer_SetStatusText
,
741 DocHostContainer_SetURL
744 HRESULT
InternetExplorer_Create(IUnknown
*pOuter
, REFIID riid
, void **ppv
)
746 InternetExplorer
*ret
;
749 TRACE("(%p %s %p)\n", pOuter
, debugstr_guid(riid
), ppv
);
751 ret
= heap_alloc_zero(sizeof(InternetExplorer
));
754 ret
->doc_host
.disp
= (IDispatch
*)WEBBROWSER2(ret
);
755 DocHost_Init(&ret
->doc_host
, (IDispatch
*)WEBBROWSER2(ret
), &DocHostContainerVtbl
);
757 InternetExplorer_WebBrowser_Init(ret
);
759 HlinkFrame_Init(&ret
->hlink_frame
, (IUnknown
*)WEBBROWSER2(ret
), &ret
->doc_host
);
761 create_frame_hwnd(ret
);
762 ret
->doc_host
.frame_hwnd
= ret
->frame_hwnd
;
764 hres
= IWebBrowser2_QueryInterface(WEBBROWSER2(ret
), riid
, ppv
);
773 /******************************************************************
774 * IEWinMain (SHDOCVW.101)
776 * Only returns on error.
778 DWORD WINAPI
IEWinMain(LPSTR szCommandLine
, int nShowWindow
)
780 IWebBrowser2
*wb
= NULL
;
784 TRACE("%s %d\n", debugstr_a(szCommandLine
), nShowWindow
);
786 if(*szCommandLine
== '-' || *szCommandLine
== '/') {
787 if(!strcasecmp(szCommandLine
+1, "regserver"))
788 return register_iexplore(TRUE
);
789 if(!strcasecmp(szCommandLine
+1, "unregserver"))
790 return register_iexplore(FALSE
);
795 hres
= register_class_object(TRUE
);
801 if(strcasecmp(szCommandLine
, "-embedding"))
802 wb
= create_ie_window(szCommandLine
);
804 /* run the message loop for this thread */
805 while (GetMessageW(&msg
, 0, 0, 0))
807 TranslateMessage(&msg
);
808 DispatchMessageW(&msg
);
812 IWebBrowser2_Release(wb
);
814 register_class_object(FALSE
);