mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
improved exception handling in start menu, especially for non-NT systems
svn path=/trunk/; revision=6097
This commit is contained in:
parent
f2fb2a7e5c
commit
c92e25be46
6 changed files with 70 additions and 26 deletions
|
@ -166,18 +166,18 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL
|
|||
#endif
|
||||
|
||||
// If there is given the command line option "-desktop", create desktop window anyways
|
||||
if (!lstrcmp(lpCmdLine,TEXT("-desktop")))
|
||||
if (_tcsstr(lpCmdLine,TEXT("-desktop")))
|
||||
startup_desktop = TRUE;
|
||||
|
||||
if (!lstrcmp(lpCmdLine,TEXT("-nodesktop")))
|
||||
if (_tcsstr(lpCmdLine,TEXT("-nodesktop")))
|
||||
startup_desktop = FALSE;
|
||||
|
||||
if (!lstrcmp(lpCmdLine,TEXT("-noexplorer"))) {
|
||||
if (_tcsstr(lpCmdLine,TEXT("-noexplorer"))) {
|
||||
nShowCmd = SW_HIDE;
|
||||
startup_desktop = TRUE;
|
||||
}
|
||||
|
||||
if (!lstrcmp(lpCmdLine,TEXT("-noautostart")))
|
||||
if (!_tcsstr(lpCmdLine,TEXT("-noautostart")))
|
||||
autostart = false;
|
||||
|
||||
g_Globals._hInstance = hInstance;
|
||||
|
|
|
@ -319,7 +319,11 @@ void ShellBrowserChild::InsertSubitems(HTREEITEM hParentItem, Entry* entry, IShe
|
|||
|
||||
SendMessage(_left_hwnd, WM_SETREDRAW, FALSE, 0);
|
||||
|
||||
entry->smart_scan();
|
||||
try {
|
||||
entry->smart_scan();
|
||||
} catch(COMException& e) {
|
||||
HandleException(e, g_Globals._hMainWnd);
|
||||
}
|
||||
|
||||
TV_ITEM tvItem;
|
||||
TV_INSERTSTRUCT tvInsert;
|
||||
|
@ -486,7 +490,11 @@ HRESULT ShellBrowserChild::OnDefaultCommand(IShellView* ppshv)
|
|||
ShellDirectory* parent = (ShellDirectory*)TreeView_GetItemData(_left_hwnd, _last_sel);
|
||||
|
||||
if (parent) {
|
||||
parent->smart_scan();
|
||||
try {
|
||||
parent->smart_scan();
|
||||
} catch(COMException& e) {
|
||||
return e.Error();
|
||||
}
|
||||
|
||||
Entry* entry = parent->find_entry(pidl);
|
||||
|
||||
|
|
|
@ -51,6 +51,8 @@ QuickLaunchMap::~QuickLaunchMap()
|
|||
QuickLaunchBar::QuickLaunchBar(HWND hwnd)
|
||||
: super(hwnd)
|
||||
{
|
||||
_dir = NULL;
|
||||
|
||||
_next_id = IDC_FIRST_QUICK_ID;
|
||||
|
||||
HWND hwndToolTip = (HWND) SendMessage(hwnd, TB_GETTOOLTIPS, 0, 0);
|
||||
|
@ -93,11 +95,12 @@ void QuickLaunchBar::AddShortcuts()
|
|||
_stprintf(path, _T("%s\\")QUICKLAUNCH_FOLDER, (LPCTSTR)app_data);
|
||||
|
||||
_dir = new ShellDirectory(Desktop(), path, _hwnd);
|
||||
|
||||
_dir->smart_scan();
|
||||
} catch(COMException&) {
|
||||
return;
|
||||
}
|
||||
|
||||
_dir->smart_scan();
|
||||
|
||||
ShellFolder desktop_folder;
|
||||
WindowCanvas canvas(_hwnd);
|
||||
|
|
|
@ -125,7 +125,11 @@ void StartMenu::AddEntries()
|
|||
StartMenuDirectory& smd = *it;
|
||||
ShellDirectory& dir = smd._dir;
|
||||
|
||||
dir.smart_scan();
|
||||
try {
|
||||
dir.smart_scan();
|
||||
} catch(COMException& e) {
|
||||
HandleException(e, g_Globals._hMainWnd);
|
||||
}
|
||||
|
||||
AddShellEntries(dir, -1, smd._subfolders);
|
||||
}
|
||||
|
@ -389,31 +393,38 @@ void StartMenu::CreateSubmenu(int id, const StartMenuFolders& new_folders, CREAT
|
|||
|
||||
void StartMenu::CreateSubmenu(int id, int folder_id, CREATORFUNC creator)
|
||||
{
|
||||
StartMenuFolders new_folders;
|
||||
try {
|
||||
SpecialFolderPath folder(folder_id, _hwnd);
|
||||
|
||||
SpecialFolderPath folder(folder_id, _hwnd);
|
||||
|
||||
if (folder)
|
||||
StartMenuFolders new_folders;
|
||||
new_folders.push_back(folder);
|
||||
|
||||
CreateSubmenu(id, new_folders, creator);
|
||||
CreateSubmenu(id, new_folders, creator);
|
||||
} catch(COMException&) {
|
||||
// ignore Exception and don't display anything
|
||||
}
|
||||
}
|
||||
|
||||
void StartMenu::CreateSubmenu(int id, int folder_id1, int folder_id2, CREATORFUNC creator)
|
||||
{
|
||||
StartMenuFolders new_folders;
|
||||
|
||||
SpecialFolderPath folder1(folder_id1, _hwnd);
|
||||
try {
|
||||
SpecialFolderPath folder1(folder_id1, _hwnd);
|
||||
|
||||
if (folder1)
|
||||
new_folders.push_back(folder1);
|
||||
} catch(COMException&) {
|
||||
}
|
||||
|
||||
SpecialFolderPath folder2(folder_id2, _hwnd);
|
||||
try {
|
||||
SpecialFolderPath folder2(folder_id2, _hwnd);
|
||||
|
||||
if (folder2)
|
||||
new_folders.push_back(folder2);
|
||||
} catch(COMException&) {
|
||||
}
|
||||
|
||||
CreateSubmenu(id, new_folders, creator);
|
||||
if (!new_folders.empty())
|
||||
CreateSubmenu(id, new_folders, creator);
|
||||
}
|
||||
|
||||
|
||||
|
@ -540,13 +551,21 @@ void StartMenuButton::DrawItem(LPDRAWITEMSTRUCT dis)
|
|||
StartMenuRoot::StartMenuRoot(HWND hwnd)
|
||||
: super(hwnd)
|
||||
{
|
||||
// insert directory "All Users\Start Menu"
|
||||
ShellDirectory cmn_startmenu(Desktop(), SpecialFolderPath(CSIDL_COMMON_STARTMENU, _hwnd), _hwnd);
|
||||
_dirs.push_back(StartMenuDirectory(cmn_startmenu, false)); // don't add subfolders
|
||||
try {
|
||||
// insert directory "All Users\Start Menu"
|
||||
ShellDirectory cmn_startmenu(Desktop(), SpecialFolderPath(CSIDL_COMMON_STARTMENU, _hwnd), _hwnd);
|
||||
_dirs.push_back(StartMenuDirectory(cmn_startmenu, false)); // don't add subfolders
|
||||
} catch(COMException&) {
|
||||
// ignore exception and don't show additional shortcuts
|
||||
}
|
||||
|
||||
// insert directory "<user name>\Start Menu"
|
||||
ShellDirectory usr_startmenu(Desktop(), SpecialFolderPath(CSIDL_STARTMENU, _hwnd), _hwnd);
|
||||
_dirs.push_back(StartMenuDirectory(usr_startmenu, false)); // don't add subfolders
|
||||
try {
|
||||
// insert directory "<user name>\Start Menu"
|
||||
ShellDirectory usr_startmenu(Desktop(), SpecialFolderPath(CSIDL_STARTMENU, _hwnd), _hwnd);
|
||||
_dirs.push_back(StartMenuDirectory(usr_startmenu, false)); // don't add subfolders
|
||||
} catch(COMException&) {
|
||||
// ignore exception and don't show additional shortcuts
|
||||
}
|
||||
|
||||
// read size of logo bitmap
|
||||
BITMAP bmp_hdr;
|
||||
|
@ -839,7 +858,11 @@ void RecentStartMenu::AddEntries()
|
|||
StartMenuDirectory& smd = *it;
|
||||
ShellDirectory& dir = smd._dir;
|
||||
|
||||
dir.smart_scan();
|
||||
try {
|
||||
dir.smart_scan();
|
||||
} catch(COMException& e) {
|
||||
HandleException(e, g_Globals._hMainWnd);
|
||||
}
|
||||
|
||||
dir.sort_directory(SORT_DATE);
|
||||
AddShellEntries(dir, 16, smd._subfolders); //TODO: read max. count of entries from registry
|
||||
|
|
|
@ -164,6 +164,9 @@ ShellFolder::ShellFolder(IShellFolder* parent, LPCITEMIDLIST pidl)
|
|||
{
|
||||
IShellFolder* ptr;
|
||||
|
||||
if (!pidl)
|
||||
CheckError(E_INVALIDARG);
|
||||
|
||||
if (pidl && pidl->mkid.cb)
|
||||
CheckError(parent->BindToObject(pidl, 0, IID_IShellFolder, (LPVOID*)&ptr));
|
||||
else
|
||||
|
|
|
@ -61,6 +61,11 @@ struct COMException
|
|||
{
|
||||
}
|
||||
|
||||
HRESULT Error() const
|
||||
{
|
||||
return _hr;
|
||||
}
|
||||
|
||||
LPCTSTR ErrorMessage() const
|
||||
{
|
||||
if (_msg.empty()) {
|
||||
|
@ -696,7 +701,8 @@ struct SpecialFolderPath : public ShellPath
|
|||
{
|
||||
SpecialFolderPath(int folder, HWND hwnd)
|
||||
{
|
||||
/*HRESULT hr = */SHGetSpecialFolderLocation(hwnd, folder, &_p);
|
||||
HRESULT hr = SHGetSpecialFolderLocation(hwnd, folder, &_p);
|
||||
CheckError(hr);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -745,6 +751,7 @@ struct SpecialFolderFSPath : public FileSysShellPath
|
|||
SpecialFolderFSPath(int folder, HWND hwnd)
|
||||
{
|
||||
HRESULT hr = SHGetSpecialFolderLocation(hwnd, folder, &_p);
|
||||
CheckError(hr);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue