For some reason I get "Invalid window handle" error direct after GetMessage() loop ends but I'm not even passing a HWND to it so how come I get this error? :s
MSG Message;
while(GetMessage(&Message, NULL, 0, 0) != 0)
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
ShowError();
It's not anything wrong with ShowError as I use it in more than this app and doesn't get this error...
void ShowError()
{
DWORD ErrorCode = GetLastError();
if(ErrorCode == ERROR_SUCCESS) return;
LPTSTR lpszBuffer = NULL;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, ErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpszBuffer, 0, NULL);
MessageBox(NULL, lpszBuffer, NULL, MB_OK | MB_ICONERROR);
LocalFree(lpszBuffer);
}