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
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;
}
{
TCHAR szErrorMessage[256];
TCHAR szTempMessage[300];
-
+
if (mciGetErrorString(dwError, szErrorMessage, sizeof(szErrorMessage) / sizeof(TCHAR)) == FALSE)
{
LoadString(hInstance, IDS_DEFAULTMCIERRMSG, szErrorMessage, sizeof(szErrorMessage) / sizeof(TCHAR));
NULL);
if (!hTrackBar)
{
- MessageBox(hwnd, _T("TrackBar it is not created!"), NULL, MB_OK);
+ ShowLastWin32Error(hwnd);
return;
}
NULL);
if (!hToolBar)
{
- MessageBox(hwnd, _T("ToolBar it is not created!"), NULL, MB_OK);
+ ShowLastWin32Error(hwnd);
return;
}
return TRUE;
}
-
+
RegCloseKey(hKey);
}
{
HDROP drophandle;
TCHAR droppedfile[MAX_PATH];
-
+
drophandle = (HDROP)wParam;
DragQueryFile(drophandle, 0, droppedfile, sizeof(droppedfile) / sizeof(TCHAR));
DragFinish(drophandle);
case IDM_DEVPROPS:
ShowDeviceProperties(hwnd);
break;
-
+
case IDM_VOLUMECTL:
ShellExecute(hwnd, NULL, _T("SNDVOL32.EXE"), NULL, NULL, SW_SHOWNORMAL);
break;
WndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
WndClass.lpszMenuName = MAKEINTRESOURCE(IDR_MAINMENU);
- RegisterClassEx(&WndClass);
+ if (!RegisterClassEx(&WndClass))
+ {
+ ShowLastWin32Error(0);
+ return 0;
+ }
hwnd = CreateWindow(szClassName,
szAppTitle,
NULL,
hInstance,
NULL);
+ if (!hwnd)
+ {
+ ShowLastWin32Error(0);
+ return 0;
+ }
DragAcceptFiles(hwnd, TRUE);
DispatchMessage(&msg);
}
- return 0;
+ return (INT)msg.wParam;
}