Author: hbelusca
Date: Sun Aug 24 14:10:49 2014
New Revision: 63936
URL:
http://svn.reactos.org/svn/reactos?rev=63936&view=rev
Log:
[MPLAY32]
- Display formatted system messages in case of diverse failues.
- Add an error check for RegisterClassEx() and CreateWindow() in _tWinMain().
Patch by Ricardo Hanke.
CORE-7880 #resolve #comment Committed, thanks!
Modified:
trunk/reactos/base/applications/mplay32/mplay32.c
Modified: trunk/reactos/base/applications/mplay32/mplay32.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mplay32/…
==============================================================================
--- trunk/reactos/base/applications/mplay32/mplay32.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mplay32/mplay32.c [iso-8859-1] Sun Aug 24 14:10:49
2014
@@ -55,15 +55,26 @@
}
static VOID
+ShowLastWin32Error(HWND hwnd)
+{
+ DWORD dwError;
+ LPTSTR lpMessageBuffer;
+
+ dwError = GetLastError();
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL,
dwError, 0, (LPWSTR)&lpMessageBuffer, 0, NULL);
+ MessageBox(hwnd, lpMessageBuffer, szAppTitle, MB_OK | MB_ICONERROR);
+ LocalFree(lpMessageBuffer);
+}
+
+static VOID
SetImageList(HWND hwnd)
{
HIMAGELIST hImageList;
hImageList = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR24, 1, 1);
-
if (!hImageList)
{
- MessageBox(hwnd, _T("ImageList it is not created!"), NULL, MB_OK);
+ ShowLastWin32Error(hwnd);
return;
}
@@ -106,7 +117,7 @@
{
TCHAR szErrorMessage[256];
TCHAR szTempMessage[300];
-
+
if (mciGetErrorString(dwError, szErrorMessage, sizeof(szErrorMessage) /
sizeof(TCHAR)) == FALSE)
{
LoadString(hInstance, IDS_DEFAULTMCIERRMSG, szErrorMessage,
sizeof(szErrorMessage) / sizeof(TCHAR));
@@ -138,7 +149,7 @@
NULL);
if (!hTrackBar)
{
- MessageBox(hwnd, _T("TrackBar it is not created!"), NULL, MB_OK);
+ ShowLastWin32Error(hwnd);
return;
}
@@ -158,7 +169,7 @@
NULL);
if (!hToolBar)
{
- MessageBox(hwnd, _T("ToolBar it is not created!"), NULL, MB_OK);
+ ShowLastWin32Error(hwnd);
return;
}
@@ -194,7 +205,7 @@
return TRUE;
}
-
+
RegCloseKey(hKey);
}
@@ -545,7 +556,7 @@
{
HDROP drophandle;
TCHAR droppedfile[MAX_PATH];
-
+
drophandle = (HDROP)wParam;
DragQueryFile(drophandle, 0, droppedfile, sizeof(droppedfile) /
sizeof(TCHAR));
DragFinish(drophandle);
@@ -693,7 +704,7 @@
case IDM_DEVPROPS:
ShowDeviceProperties(hwnd);
break;
-
+
case IDM_VOLUMECTL:
ShellExecute(hwnd, NULL, _T("SNDVOL32.EXE"), NULL, NULL,
SW_SHOWNORMAL);
break;
@@ -743,7 +754,11 @@
WndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
WndClass.lpszMenuName = MAKEINTRESOURCE(IDR_MAINMENU);
- RegisterClassEx(&WndClass);
+ if (!RegisterClassEx(&WndClass))
+ {
+ ShowLastWin32Error(0);
+ return 0;
+ }
hwnd = CreateWindow(szClassName,
szAppTitle,
@@ -756,6 +771,11 @@
NULL,
hInstance,
NULL);
+ if (!hwnd)
+ {
+ ShowLastWin32Error(0);
+ return 0;
+ }
DragAcceptFiles(hwnd, TRUE);
@@ -780,5 +800,5 @@
DispatchMessage(&msg);
}
- return 0;
-}
+ return (INT)msg.wParam;
+}