From 3d57db0ea00b2a5ae766426bfee6ec9baae3b61a Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Sun, 21 Sep 2003 13:51:20 +0000 Subject: [PATCH] Exception Handling svn path=/trunk/; revision=6111 --- reactos/subsys/system/explorer/explorer.cpp | 2 +- .../system/explorer/shell/mainframe.cpp | 4 ++ .../system/explorer/taskbar/startmenu.cpp | 46 +++++++++---------- .../system/explorer/utility/shellclasses.cpp | 5 ++ .../subsys/system/explorer/utility/window.cpp | 4 +- 5 files changed, 33 insertions(+), 28 deletions(-) diff --git a/reactos/subsys/system/explorer/explorer.cpp b/reactos/subsys/system/explorer/explorer.cpp index ac711e6fc24..70b083e164a 100644 --- a/reactos/subsys/system/explorer/explorer.cpp +++ b/reactos/subsys/system/explorer/explorer.cpp @@ -132,7 +132,7 @@ int explorer_main(HINSTANCE hInstance, HWND hwndDesktop, int cmdshow) try { InitInstance(hInstance); } catch(COMException& e) { - HandleException(e, g_Globals._hMainWnd); + HandleException(e, hwndDesktop); return -1; } diff --git a/reactos/subsys/system/explorer/shell/mainframe.cpp b/reactos/subsys/system/explorer/shell/mainframe.cpp index 4f2c3c8d74b..89357df13ac 100644 --- a/reactos/subsys/system/explorer/shell/mainframe.cpp +++ b/reactos/subsys/system/explorer/shell/mainframe.cpp @@ -432,6 +432,10 @@ int MainFrame::Command(int id, int code) ShellAbout(_hwnd, ResString(IDS_TITLE), NULL, 0); break; + case ID_EXPLORER_FAQ: + launch_file(_hwnd, TEXT("http://www.sky.franken.de/explorer/"), SW_SHOWNORMAL); + break; + default: /*TODO: if (wParam >= PM_FIRST_LANGUAGE && wParam <= PM_LAST_LANGUAGE) STRING_SelectLanguageByNumber(wParam - PM_FIRST_LANGUAGE); diff --git a/reactos/subsys/system/explorer/taskbar/startmenu.cpp b/reactos/subsys/system/explorer/taskbar/startmenu.cpp index a1945b8e5fc..2580750ca8a 100644 --- a/reactos/subsys/system/explorer/taskbar/startmenu.cpp +++ b/reactos/subsys/system/explorer/taskbar/startmenu.cpp @@ -96,24 +96,28 @@ LRESULT StartMenu::Init(LPCREATESTRUCT pcs) { WaitCursor wait; - AddEntries(); + try { + AddEntries(); - if (super::Init(pcs)) - return 1; + if (super::Init(pcs)) + return 1; - // create buttons for registered entries in _entries - if (_entries.empty()) { - AddButton(ResString(IDS_EMPTY), 0, false, (UINT)-1, WS_VISIBLE|WS_CHILD|BS_OWNERDRAW|WS_DISABLED); - } else { - for(ShellEntryMap::const_iterator it=_entries.begin(); it!=_entries.end(); ++it) { - const StartMenuEntry& sme = it->second; - bool hasSubmenu = false; + // create buttons for registered entries in _entries + if (_entries.empty()) { + AddButton(ResString(IDS_EMPTY), 0, false, (UINT)-1, WS_VISIBLE|WS_CHILD|BS_OWNERDRAW|WS_DISABLED); + } else { + for(ShellEntryMap::const_iterator it=_entries.begin(); it!=_entries.end(); ++it) { + const StartMenuEntry& sme = it->second; + bool hasSubmenu = false; - if (sme._entry && (sme._entry->_data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) - hasSubmenu = true; + if (sme._entry && (sme._entry->_data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) + hasSubmenu = true; - AddButton(sme._title, sme._hIcon, hasSubmenu, it->first); + AddButton(sme._title, sme._hIcon, hasSubmenu, it->first); + } } + } catch(COMException& e) { + HandleException(e, pcs->hwndParent); // destroys the start menu window while switching focus } return 0; @@ -125,11 +129,7 @@ void StartMenu::AddEntries() StartMenuDirectory& smd = *it; ShellDirectory& dir = smd._dir; - try { - dir.smart_scan(); - } catch(COMException& e) { - HandleException(e, g_Globals._hMainWnd); - } + dir.smart_scan(); AddShellEntries(dir, -1, smd._subfolders); } @@ -626,10 +626,10 @@ void StartMenuRoot::TrackStartmenu() try { DispatchMessage(&msg); } catch(COMException& e) { - HandleException(e, g_Globals._hMainWnd); + HandleException(e, _hwnd); } } catch(COMException& e) { - HandleException(e, g_Globals._hMainWnd); + HandleException(e, _hwnd); } } } @@ -858,11 +858,7 @@ void RecentStartMenu::AddEntries() StartMenuDirectory& smd = *it; ShellDirectory& dir = smd._dir; - try { - dir.smart_scan(); - } catch(COMException& e) { - HandleException(e, g_Globals._hMainWnd); - } + dir.smart_scan(); dir.sort_directory(SORT_DATE); AddShellEntries(dir, 16, smd._subfolders); //TODO: read max. count of entries from registry diff --git a/reactos/subsys/system/explorer/utility/shellclasses.cpp b/reactos/subsys/system/explorer/utility/shellclasses.cpp index 5870716ed3f..f0ea01afdd4 100644 --- a/reactos/subsys/system/explorer/utility/shellclasses.cpp +++ b/reactos/subsys/system/explorer/utility/shellclasses.cpp @@ -64,7 +64,12 @@ LPWSTR wcscpyn(LPWSTR dest, LPCWSTR source, size_t count) void HandleException(COMException& e, HWND hwnd) { + SetLastError(0); + MessageBox(hwnd, e.ErrorMessage(), TEXT("ShellClasses COM Exception"), MB_ICONHAND|MB_OK); + + if (GetLastError() == ERROR_INVALID_WINDOW_HANDLE) + MessageBox(0, e.ErrorMessage(), TEXT("ShellClasses COM Exception"), MB_ICONHAND|MB_OK); } diff --git a/reactos/subsys/system/explorer/utility/window.cpp b/reactos/subsys/system/explorer/utility/window.cpp index ad3b5709279..cc3f4a0bf10 100644 --- a/reactos/subsys/system/explorer/utility/window.cpp +++ b/reactos/subsys/system/explorer/utility/window.cpp @@ -492,10 +492,10 @@ int Window::MessageLoop() try { DispatchMessage(&msg); } catch(COMException& e) { - HandleException(e, g_Globals._hMainWnd); + HandleException(e, 0); } } catch(COMException& e) { - HandleException(e, g_Globals._hMainWnd); + HandleException(e, 0); } }