-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCxWinException.cpp
More file actions
52 lines (45 loc) · 1.33 KB
/
CxWinException.cpp
File metadata and controls
52 lines (45 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* \file CxWinException.cpp
* \brief
*/
#include "CxWinException.h"
//--------------------------------------------------------------------------------------------------
CxWinException::CxWinException(
LPCTSTR msg
) :
m_err(::GetLastError()),
m_msg(msg)
{
}
//--------------------------------------------------------------------------------------------------
/* virtual */
CxWinException::~CxWinException()
{
}
//--------------------------------------------------------------------------------------------------
LPCTSTR
CxWinException::What() const
{
return m_msg;
}
//--------------------------------------------------------------------------------------------------
VOID
CxWinException::vMessageBox() const
{
TCHAR buf1 [512] = {};
TCHAR buf2 [512] = {};
TCHAR buf3 [512] = {};
::lstrcpy(buf1, m_msg);
// Display Last Error information if it's useful
if (m_err != 0) {
DWORD dwFlags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS;
::FormatMessage(
dwFlags, NULL, m_err,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf2, 512, NULL);
::wsprintf(buf3, _T("%s\n\n %s\n\n"), buf1, buf2);
} else {
::wsprintf(buf3, _T("%s"), buf1);
}
::MessageBox(0, buf3, _T("CxWinException"), MB_OK | MB_ICONERROR);
}
//--------------------------------------------------------------------------------------------------