mirror of
https://github.com/reactos/reactos.git
synced 2025-01-05 22:12:46 +00:00
[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! svn path=/trunk/; revision=63936
This commit is contained in:
parent
cb9669d967
commit
c4ffcdd3ad
1 changed files with 30 additions and 10 deletions
|
@ -54,16 +54,27 @@ void DisableMenuItems(void)
|
||||||
EnableMenuItem(hMainMenu, IDM_DEVPROPS, MF_BYCOMMAND | MF_GRAYED);
|
EnableMenuItem(hMainMenu, IDM_DEVPROPS, MF_BYCOMMAND | MF_GRAYED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static VOID
|
||||||
SetImageList(HWND hwnd)
|
SetImageList(HWND hwnd)
|
||||||
{
|
{
|
||||||
HIMAGELIST hImageList;
|
HIMAGELIST hImageList;
|
||||||
|
|
||||||
hImageList = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR24, 1, 1);
|
hImageList = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR24, 1, 1);
|
||||||
|
|
||||||
if (!hImageList)
|
if (!hImageList)
|
||||||
{
|
{
|
||||||
MessageBox(hwnd, _T("ImageList it is not created!"), NULL, MB_OK);
|
ShowLastWin32Error(hwnd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +117,7 @@ ShowMCIError(HWND hwnd, DWORD dwError)
|
||||||
{
|
{
|
||||||
TCHAR szErrorMessage[256];
|
TCHAR szErrorMessage[256];
|
||||||
TCHAR szTempMessage[300];
|
TCHAR szTempMessage[300];
|
||||||
|
|
||||||
if (mciGetErrorString(dwError, szErrorMessage, sizeof(szErrorMessage) / sizeof(TCHAR)) == FALSE)
|
if (mciGetErrorString(dwError, szErrorMessage, sizeof(szErrorMessage) / sizeof(TCHAR)) == FALSE)
|
||||||
{
|
{
|
||||||
LoadString(hInstance, IDS_DEFAULTMCIERRMSG, szErrorMessage, sizeof(szErrorMessage) / sizeof(TCHAR));
|
LoadString(hInstance, IDS_DEFAULTMCIERRMSG, szErrorMessage, sizeof(szErrorMessage) / sizeof(TCHAR));
|
||||||
|
@ -138,7 +149,7 @@ InitControls(HWND hwnd)
|
||||||
NULL);
|
NULL);
|
||||||
if (!hTrackBar)
|
if (!hTrackBar)
|
||||||
{
|
{
|
||||||
MessageBox(hwnd, _T("TrackBar it is not created!"), NULL, MB_OK);
|
ShowLastWin32Error(hwnd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +169,7 @@ InitControls(HWND hwnd)
|
||||||
NULL);
|
NULL);
|
||||||
if (!hToolBar)
|
if (!hToolBar)
|
||||||
{
|
{
|
||||||
MessageBox(hwnd, _T("ToolBar it is not created!"), NULL, MB_OK);
|
ShowLastWin32Error(hwnd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +205,7 @@ IsSupportedFileExtension(LPTSTR lpFileName, LPTSTR lpDeviceName, LPDWORD dwSize)
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -545,7 +556,7 @@ MainWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
HDROP drophandle;
|
HDROP drophandle;
|
||||||
TCHAR droppedfile[MAX_PATH];
|
TCHAR droppedfile[MAX_PATH];
|
||||||
|
|
||||||
drophandle = (HDROP)wParam;
|
drophandle = (HDROP)wParam;
|
||||||
DragQueryFile(drophandle, 0, droppedfile, sizeof(droppedfile) / sizeof(TCHAR));
|
DragQueryFile(drophandle, 0, droppedfile, sizeof(droppedfile) / sizeof(TCHAR));
|
||||||
DragFinish(drophandle);
|
DragFinish(drophandle);
|
||||||
|
@ -693,7 +704,7 @@ MainWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
||||||
case IDM_DEVPROPS:
|
case IDM_DEVPROPS:
|
||||||
ShowDeviceProperties(hwnd);
|
ShowDeviceProperties(hwnd);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDM_VOLUMECTL:
|
case IDM_VOLUMECTL:
|
||||||
ShellExecute(hwnd, NULL, _T("SNDVOL32.EXE"), NULL, NULL, SW_SHOWNORMAL);
|
ShellExecute(hwnd, NULL, _T("SNDVOL32.EXE"), NULL, NULL, SW_SHOWNORMAL);
|
||||||
break;
|
break;
|
||||||
|
@ -743,7 +754,11 @@ _tWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPTSTR lpCmdLine, INT nCmdShow)
|
||||||
WndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
|
WndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
|
||||||
WndClass.lpszMenuName = MAKEINTRESOURCE(IDR_MAINMENU);
|
WndClass.lpszMenuName = MAKEINTRESOURCE(IDR_MAINMENU);
|
||||||
|
|
||||||
RegisterClassEx(&WndClass);
|
if (!RegisterClassEx(&WndClass))
|
||||||
|
{
|
||||||
|
ShowLastWin32Error(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
hwnd = CreateWindow(szClassName,
|
hwnd = CreateWindow(szClassName,
|
||||||
szAppTitle,
|
szAppTitle,
|
||||||
|
@ -756,6 +771,11 @@ _tWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPTSTR lpCmdLine, INT nCmdShow)
|
||||||
NULL,
|
NULL,
|
||||||
hInstance,
|
hInstance,
|
||||||
NULL);
|
NULL);
|
||||||
|
if (!hwnd)
|
||||||
|
{
|
||||||
|
ShowLastWin32Error(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
DragAcceptFiles(hwnd, TRUE);
|
DragAcceptFiles(hwnd, TRUE);
|
||||||
|
|
||||||
|
@ -780,5 +800,5 @@ _tWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPTSTR lpCmdLine, INT nCmdShow)
|
||||||
DispatchMessage(&msg);
|
DispatchMessage(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return (INT)msg.wParam;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue