Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Clark Lin
hw3d
Commits
e5933fa6
Commit
e5933fa6
authored
Dec 09, 2018
by
chili
Browse files
top level try...catch with messagebox
parent
9b321235
Changes
1
Hide whitespace changes
Inline
Side-by-side
hw3d/WinMain.cpp
View file @
e5933fa6
...
...
@@ -26,23 +26,39 @@ int CALLBACK WinMain(
LPSTR
lpCmdLine
,
int
nCmdShow
)
{
Window
wnd
(
800
,
300
,
"Donkey Fart Box"
);
try
{
Window
wnd
(
800
,
300
,
"Donkey Fart Box"
);
MSG
msg
;
BOOL
gResult
;
while
(
(
gResult
=
GetMessage
(
&
msg
,
nullptr
,
0
,
0
))
>
0
)
{
// TranslateMessage will post auxilliary WM_CHAR messages from key msgs
TranslateMessage
(
&
msg
);
DispatchMessage
(
&
msg
);
}
MSG
msg
;
BOOL
gResult
;
while
(
(
gResult
=
GetMessage
(
&
msg
,
nullptr
,
0
,
0
))
>
0
)
// check if GetMessage call itself borked
if
(
gResult
==
-
1
)
{
return
-
1
;
}
// wParam here is the value passed to PostQuitMessage
return
msg
.
wParam
;
}
catch
(
const
ChiliException
&
e
)
{
// TranslateMessage will post auxilliary WM_CHAR messages from key msgs
TranslateMessage
(
&
msg
);
DispatchMessage
(
&
msg
);
MessageBox
(
nullptr
,
e
.
what
(),
e
.
GetType
(),
MB_OK
|
MB_ICONEXCLAMATION
);
}
// check if GetMessage call itself borked
if
(
gResult
==
-
1
)
catch
(
const
std
::
exception
&
e
)
{
return
-
1
;
MessageBox
(
nullptr
,
e
.
what
(),
"Standard Exception"
,
MB_OK
|
MB_ICONEXCLAMATION
)
;
}
// wParam here is the value passed to PostQuitMessage
return
msg
.
wParam
;
catch
(
...
)
{
MessageBox
(
nullptr
,
"No details available"
,
"Unknown Exception"
,
MB_OK
|
MB_ICONEXCLAMATION
);
}
return
-
1
;
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment