Exception Handling

svn path=/trunk/; revision=6111
This commit is contained in:
Martin Fuchs 2003-09-21 13:51:20 +00:00
parent 3c50c8c091
commit 3d57db0ea0
5 changed files with 33 additions and 28 deletions

View file

@ -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;
}

View file

@ -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);

View file

@ -96,6 +96,7 @@ LRESULT StartMenu::Init(LPCREATESTRUCT pcs)
{
WaitCursor wait;
try {
AddEntries();
if (super::Init(pcs))
@ -115,6 +116,9 @@ LRESULT StartMenu::Init(LPCREATESTRUCT pcs)
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);
}
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.sort_directory(SORT_DATE);
AddShellEntries(dir, 16, smd._subfolders); //TODO: read max. count of entries from registry

View file

@ -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);
}

View file

@ -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);
}
}