mirror of
https://github.com/reactos/reactos.git
synced 2025-07-14 07:44:18 +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
|
#endif
|
||||||
|
|
||||||
// If there is given the command line option "-desktop", create desktop window anyways
|
// 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;
|
startup_desktop = TRUE;
|
||||||
|
|
||||||
if (!lstrcmp(lpCmdLine,TEXT("-nodesktop")))
|
if (_tcsstr(lpCmdLine,TEXT("-nodesktop")))
|
||||||
startup_desktop = FALSE;
|
startup_desktop = FALSE;
|
||||||
|
|
||||||
if (!lstrcmp(lpCmdLine,TEXT("-noexplorer"))) {
|
if (_tcsstr(lpCmdLine,TEXT("-noexplorer"))) {
|
||||||
nShowCmd = SW_HIDE;
|
nShowCmd = SW_HIDE;
|
||||||
startup_desktop = TRUE;
|
startup_desktop = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lstrcmp(lpCmdLine,TEXT("-noautostart")))
|
if (!_tcsstr(lpCmdLine,TEXT("-noautostart")))
|
||||||
autostart = false;
|
autostart = false;
|
||||||
|
|
||||||
g_Globals._hInstance = hInstance;
|
g_Globals._hInstance = hInstance;
|
||||||
|
|
|
@ -319,7 +319,11 @@ void ShellBrowserChild::InsertSubitems(HTREEITEM hParentItem, Entry* entry, IShe
|
||||||
|
|
||||||
SendMessage(_left_hwnd, WM_SETREDRAW, FALSE, 0);
|
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_ITEM tvItem;
|
||||||
TV_INSERTSTRUCT tvInsert;
|
TV_INSERTSTRUCT tvInsert;
|
||||||
|
@ -486,7 +490,11 @@ HRESULT ShellBrowserChild::OnDefaultCommand(IShellView* ppshv)
|
||||||
ShellDirectory* parent = (ShellDirectory*)TreeView_GetItemData(_left_hwnd, _last_sel);
|
ShellDirectory* parent = (ShellDirectory*)TreeView_GetItemData(_left_hwnd, _last_sel);
|
||||||
|
|
||||||
if (parent) {
|
if (parent) {
|
||||||
parent->smart_scan();
|
try {
|
||||||
|
parent->smart_scan();
|
||||||
|
} catch(COMException& e) {
|
||||||
|
return e.Error();
|
||||||
|
}
|
||||||
|
|
||||||
Entry* entry = parent->find_entry(pidl);
|
Entry* entry = parent->find_entry(pidl);
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,8 @@ QuickLaunchMap::~QuickLaunchMap()
|
||||||
QuickLaunchBar::QuickLaunchBar(HWND hwnd)
|
QuickLaunchBar::QuickLaunchBar(HWND hwnd)
|
||||||
: super(hwnd)
|
: super(hwnd)
|
||||||
{
|
{
|
||||||
|
_dir = NULL;
|
||||||
|
|
||||||
_next_id = IDC_FIRST_QUICK_ID;
|
_next_id = IDC_FIRST_QUICK_ID;
|
||||||
|
|
||||||
HWND hwndToolTip = (HWND) SendMessage(hwnd, TB_GETTOOLTIPS, 0, 0);
|
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);
|
_stprintf(path, _T("%s\\")QUICKLAUNCH_FOLDER, (LPCTSTR)app_data);
|
||||||
|
|
||||||
_dir = new ShellDirectory(Desktop(), path, _hwnd);
|
_dir = new ShellDirectory(Desktop(), path, _hwnd);
|
||||||
|
|
||||||
|
_dir->smart_scan();
|
||||||
} catch(COMException&) {
|
} catch(COMException&) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_dir->smart_scan();
|
|
||||||
|
|
||||||
ShellFolder desktop_folder;
|
ShellFolder desktop_folder;
|
||||||
WindowCanvas canvas(_hwnd);
|
WindowCanvas canvas(_hwnd);
|
||||||
|
|
|
@ -125,7 +125,11 @@ void StartMenu::AddEntries()
|
||||||
StartMenuDirectory& smd = *it;
|
StartMenuDirectory& smd = *it;
|
||||||
ShellDirectory& dir = smd._dir;
|
ShellDirectory& dir = smd._dir;
|
||||||
|
|
||||||
dir.smart_scan();
|
try {
|
||||||
|
dir.smart_scan();
|
||||||
|
} catch(COMException& e) {
|
||||||
|
HandleException(e, g_Globals._hMainWnd);
|
||||||
|
}
|
||||||
|
|
||||||
AddShellEntries(dir, -1, smd._subfolders);
|
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)
|
void StartMenu::CreateSubmenu(int id, int folder_id, CREATORFUNC creator)
|
||||||
{
|
{
|
||||||
StartMenuFolders new_folders;
|
try {
|
||||||
|
SpecialFolderPath folder(folder_id, _hwnd);
|
||||||
|
|
||||||
SpecialFolderPath folder(folder_id, _hwnd);
|
StartMenuFolders new_folders;
|
||||||
|
|
||||||
if (folder)
|
|
||||||
new_folders.push_back(folder);
|
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)
|
void StartMenu::CreateSubmenu(int id, int folder_id1, int folder_id2, CREATORFUNC creator)
|
||||||
{
|
{
|
||||||
StartMenuFolders new_folders;
|
StartMenuFolders new_folders;
|
||||||
|
|
||||||
SpecialFolderPath folder1(folder_id1, _hwnd);
|
try {
|
||||||
|
SpecialFolderPath folder1(folder_id1, _hwnd);
|
||||||
|
|
||||||
if (folder1)
|
|
||||||
new_folders.push_back(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);
|
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)
|
StartMenuRoot::StartMenuRoot(HWND hwnd)
|
||||||
: super(hwnd)
|
: super(hwnd)
|
||||||
{
|
{
|
||||||
// insert directory "All Users\Start Menu"
|
try {
|
||||||
ShellDirectory cmn_startmenu(Desktop(), SpecialFolderPath(CSIDL_COMMON_STARTMENU, _hwnd), _hwnd);
|
// insert directory "All Users\Start Menu"
|
||||||
_dirs.push_back(StartMenuDirectory(cmn_startmenu, false)); // don't add subfolders
|
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"
|
try {
|
||||||
ShellDirectory usr_startmenu(Desktop(), SpecialFolderPath(CSIDL_STARTMENU, _hwnd), _hwnd);
|
// insert directory "<user name>\Start Menu"
|
||||||
_dirs.push_back(StartMenuDirectory(usr_startmenu, false)); // don't add subfolders
|
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
|
// read size of logo bitmap
|
||||||
BITMAP bmp_hdr;
|
BITMAP bmp_hdr;
|
||||||
|
@ -839,7 +858,11 @@ void RecentStartMenu::AddEntries()
|
||||||
StartMenuDirectory& smd = *it;
|
StartMenuDirectory& smd = *it;
|
||||||
ShellDirectory& dir = smd._dir;
|
ShellDirectory& dir = smd._dir;
|
||||||
|
|
||||||
dir.smart_scan();
|
try {
|
||||||
|
dir.smart_scan();
|
||||||
|
} catch(COMException& e) {
|
||||||
|
HandleException(e, g_Globals._hMainWnd);
|
||||||
|
}
|
||||||
|
|
||||||
dir.sort_directory(SORT_DATE);
|
dir.sort_directory(SORT_DATE);
|
||||||
AddShellEntries(dir, 16, smd._subfolders); //TODO: read max. count of entries from registry
|
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;
|
IShellFolder* ptr;
|
||||||
|
|
||||||
|
if (!pidl)
|
||||||
|
CheckError(E_INVALIDARG);
|
||||||
|
|
||||||
if (pidl && pidl->mkid.cb)
|
if (pidl && pidl->mkid.cb)
|
||||||
CheckError(parent->BindToObject(pidl, 0, IID_IShellFolder, (LPVOID*)&ptr));
|
CheckError(parent->BindToObject(pidl, 0, IID_IShellFolder, (LPVOID*)&ptr));
|
||||||
else
|
else
|
||||||
|
|
|
@ -61,6 +61,11 @@ struct COMException
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HRESULT Error() const
|
||||||
|
{
|
||||||
|
return _hr;
|
||||||
|
}
|
||||||
|
|
||||||
LPCTSTR ErrorMessage() const
|
LPCTSTR ErrorMessage() const
|
||||||
{
|
{
|
||||||
if (_msg.empty()) {
|
if (_msg.empty()) {
|
||||||
|
@ -696,7 +701,8 @@ struct SpecialFolderPath : public ShellPath
|
||||||
{
|
{
|
||||||
SpecialFolderPath(int folder, HWND hwnd)
|
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)
|
SpecialFolderFSPath(int folder, HWND hwnd)
|
||||||
{
|
{
|
||||||
HRESULT hr = SHGetSpecialFolderLocation(hwnd, folder, &_p);
|
HRESULT hr = SHGetSpecialFolderLocation(hwnd, folder, &_p);
|
||||||
|
CheckError(hr);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue