mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 17:44:45 +00:00
Exception Handling
svn path=/trunk/; revision=6111
This commit is contained in:
parent
3c50c8c091
commit
3d57db0ea0
5 changed files with 33 additions and 28 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue