Commit 81563234 authored by Alexander Nicolaysen Sørnes's avatar Alexander Nicolaysen Sørnes Committed by Alexandre Julliard

shdocvw: Add Favorites menu to IE.

parent 515eb3d7
......@@ -50,6 +50,11 @@ IDR_BROWSE_MAIN_MENU MENU
MENUITEM SEPARATOR
MENUITEM "&Properties...", ID_BROWSE_PROPERTIES
}
POPUP "&Favorites"
{
MENUITEM "&Add to Favorites..." ID_BROWSE_ADDFAV
MENUITEM SEPARATOR
}
POPUP "&Help"
{
MENUITEM "&About Internet Explorer...", ID_BROWSE_ABOUT
......
......@@ -430,19 +430,11 @@ static HRESULT WINAPI InternetExplorer_put_MenuBar(IWebBrowser2 *iface, VARIANT_
TRACE("(%p)->(%x)\n", This, Value);
if((menu = GetMenu(This->frame_hwnd)))
DestroyMenu(menu);
menu = NULL;
if(Value)
menu = LoadMenuW(shdocvw_hinstance, MAKEINTRESOURCEW(IDR_BROWSE_MAIN_MENU));
menu = This->menu;
if(!SetMenu(This->frame_hwnd, menu))
{
DestroyMenu(menu);
return HRESULT_FROM_WIN32(GetLastError());
}
return S_OK;
}
......
......@@ -34,6 +34,9 @@
#include "shdocvw.h"
#include "mshtmcid.h"
#include "shellapi.h"
#include "winreg.h"
#include "shlwapi.h"
#include "intshcut.h"
#include "wine/debug.h"
......@@ -75,6 +78,87 @@ void adjust_ie_docobj_rect(HWND frame, RECT* rc)
}
}
static HMENU get_fav_menu(HMENU menu)
{
return GetSubMenu(menu, 1);
}
static void add_fav_to_menu(HMENU menu, LPWSTR title)
{
MENUITEMINFOW item;
item.cbSize = sizeof(item);
item.fMask = MIIM_FTYPE | MIIM_STRING;
item.fType = MFT_STRING;
item.dwTypeData = title;
InsertMenuItemW(menu, GetMenuItemCount(menu), TRUE, &item);
}
static void add_favs_to_menu(HMENU menu, LPCWSTR dir)
{
WCHAR path[MAX_PATH*2];
const WCHAR urlext[] = {'*','.','u','r','l',0};
WCHAR* filename;
HANDLE findhandle;
WIN32_FIND_DATAW finddata;
IUniformResourceLocatorW* urlobj;
IPersistFile* urlfile;
HRESULT res;
lstrcpyW(path, dir);
PathAppendW(path, urlext);
findhandle = FindFirstFileW(path, &finddata);
if(findhandle == INVALID_HANDLE_VALUE)
return;
res = CoCreateInstance(&CLSID_InternetShortcut, NULL, CLSCTX_INPROC_SERVER, &IID_IUniformResourceLocatorW, (PVOID*)&urlobj);
if(SUCCEEDED(res))
res = IUnknown_QueryInterface(urlobj, &IID_IPersistFile, (PVOID*)&urlfile);
if(SUCCEEDED(res))
{
filename = path + lstrlenW(path) - lstrlenW(urlext);
do
{
WCHAR* fileext;
lstrcpyW(filename, finddata.cFileName);
if(FAILED(IPersistFile_Load(urlfile, path, 0)))
continue;
fileext = filename + lstrlenW(filename) - lstrlenW(urlext) + 1;
*fileext = 0;
add_fav_to_menu(menu, filename);
} while(FindNextFileW(findhandle, &finddata));
}
if(urlfile)
IPersistFile_Release(urlfile);
if(urlobj)
IUnknown_Release(urlobj);
FindClose(findhandle);
}
static HMENU create_ie_menu(void)
{
HMENU menu = LoadMenuW(shdocvw_hinstance, MAKEINTRESOURCEW(IDR_BROWSE_MAIN_MENU));
WCHAR path[MAX_PATH];
if(SHGetFolderPathW(NULL, CSIDL_COMMON_FAVORITES, NULL, SHGFP_TYPE_CURRENT, path) == S_OK)
add_favs_to_menu(get_fav_menu(menu), path);
if(SHGetFolderPathW(NULL, CSIDL_FAVORITES, NULL, SHGFP_TYPE_CURRENT, path) == S_OK)
add_favs_to_menu(get_fav_menu(menu), path);
return menu;
}
static INT_PTR CALLBACK ie_dialog_open_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
static InternetExplorer* This;
......@@ -167,6 +251,8 @@ static LRESULT iewnd_OnCreate(HWND hwnd, LPCREATESTRUCTW lpcs)
InternetExplorer* This = (InternetExplorer*)lpcs->lpCreateParams;
SetWindowLongPtrW(hwnd, 0, (LONG_PTR) lpcs->lpCreateParams);
This->menu = create_ie_menu();
This->status_hwnd = CreateStatusWindowW(CCS_NODIVIDER|WS_CHILD|WS_VISIBLE, NULL, hwnd, IDC_BROWSE_STATUSBAR);
SendMessageW(This->status_hwnd, SB_SIMPLE, TRUE, 0);
......
......@@ -37,3 +37,5 @@
#define ID_BROWSE_PRINT_PREVIEW 277
#define ID_BROWSE_PROPERTIES 262
#define ID_BROWSE_ABOUT 336
#define ID_BROWSE_ADDFAV 1200
......@@ -190,6 +190,7 @@ struct InternetExplorer {
HWND frame_hwnd;
HWND status_hwnd;
HMENU menu;
DocHost doc_host;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment