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 { try {
InitInstance(hInstance); InitInstance(hInstance);
} catch(COMException& e) { } catch(COMException& e) {
HandleException(e, g_Globals._hMainWnd); HandleException(e, hwndDesktop);
return -1; return -1;
} }

View file

@ -432,6 +432,10 @@ int MainFrame::Command(int id, int code)
ShellAbout(_hwnd, ResString(IDS_TITLE), NULL, 0); ShellAbout(_hwnd, ResString(IDS_TITLE), NULL, 0);
break; break;
case ID_EXPLORER_FAQ:
launch_file(_hwnd, TEXT("http://www.sky.franken.de/explorer/"), SW_SHOWNORMAL);
break;
default: default:
/*TODO: if (wParam >= PM_FIRST_LANGUAGE && wParam <= PM_LAST_LANGUAGE) /*TODO: if (wParam >= PM_FIRST_LANGUAGE && wParam <= PM_LAST_LANGUAGE)
STRING_SelectLanguageByNumber(wParam - PM_FIRST_LANGUAGE); STRING_SelectLanguageByNumber(wParam - PM_FIRST_LANGUAGE);

View file

@ -96,24 +96,28 @@ LRESULT StartMenu::Init(LPCREATESTRUCT pcs)
{ {
WaitCursor wait; WaitCursor wait;
AddEntries(); try {
AddEntries();
if (super::Init(pcs)) if (super::Init(pcs))
return 1; return 1;
// create buttons for registered entries in _entries // create buttons for registered entries in _entries
if (_entries.empty()) { if (_entries.empty()) {
AddButton(ResString(IDS_EMPTY), 0, false, (UINT)-1, WS_VISIBLE|WS_CHILD|BS_OWNERDRAW|WS_DISABLED); AddButton(ResString(IDS_EMPTY), 0, false, (UINT)-1, WS_VISIBLE|WS_CHILD|BS_OWNERDRAW|WS_DISABLED);
} else { } else {
for(ShellEntryMap::const_iterator it=_entries.begin(); it!=_entries.end(); ++it) { for(ShellEntryMap::const_iterator it=_entries.begin(); it!=_entries.end(); ++it) {
const StartMenuEntry& sme = it->second; const StartMenuEntry& sme = it->second;
bool hasSubmenu = false; bool hasSubmenu = false;
if (sme._entry && (sme._entry->_data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) if (sme._entry && (sme._entry->_data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY))
hasSubmenu = true; 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; return 0;
@ -125,11 +129,7 @@ void StartMenu::AddEntries()
StartMenuDirectory& smd = *it; StartMenuDirectory& smd = *it;
ShellDirectory& dir = smd._dir; ShellDirectory& dir = smd._dir;
try { dir.smart_scan();
dir.smart_scan();
} catch(COMException& e) {
HandleException(e, g_Globals._hMainWnd);
}
AddShellEntries(dir, -1, smd._subfolders); AddShellEntries(dir, -1, smd._subfolders);
} }
@ -626,10 +626,10 @@ void StartMenuRoot::TrackStartmenu()
try { try {
DispatchMessage(&msg); DispatchMessage(&msg);
} catch(COMException& e) { } catch(COMException& e) {
HandleException(e, g_Globals._hMainWnd); HandleException(e, _hwnd);
} }
} catch(COMException& e) { } catch(COMException& e) {
HandleException(e, g_Globals._hMainWnd); HandleException(e, _hwnd);
} }
} }
} }
@ -858,11 +858,7 @@ void RecentStartMenu::AddEntries()
StartMenuDirectory& smd = *it; StartMenuDirectory& smd = *it;
ShellDirectory& dir = smd._dir; ShellDirectory& dir = smd._dir;
try { dir.smart_scan();
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

View file

@ -64,7 +64,12 @@ LPWSTR wcscpyn(LPWSTR dest, LPCWSTR source, size_t count)
void HandleException(COMException& e, HWND hwnd) void HandleException(COMException& e, HWND hwnd)
{ {
SetLastError(0);
MessageBox(hwnd, e.ErrorMessage(), TEXT("ShellClasses COM Exception"), MB_ICONHAND|MB_OK); 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 { try {
DispatchMessage(&msg); DispatchMessage(&msg);
} catch(COMException& e) { } catch(COMException& e) {
HandleException(e, g_Globals._hMainWnd); HandleException(e, 0);
} }
} catch(COMException& e) { } catch(COMException& e) {
HandleException(e, g_Globals._hMainWnd); HandleException(e, 0);
} }
} }