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
9efa93f3
Commit
9efa93f3
authored
Dec 09, 2018
by
chili
Browse files
use exception for GetMessage error
parent
bb3081ad
Changes
2
Hide whitespace changes
Inline
Side-by-side
hw3d/WinMain.cpp
View file @
9efa93f3
...
...
@@ -42,7 +42,7 @@ int CALLBACK WinMain(
// check if GetMessage call itself borked
if
(
gResult
==
-
1
)
{
return
-
1
;
throw
CHWND_LAST_EXCEPT
()
;
}
// wParam here is the value passed to PostQuitMessage
...
...
hw3d/Window.cpp
View file @
9efa93f3
...
...
@@ -109,11 +109,11 @@ LRESULT CALLBACK Window::HandleMsgSetup( HWND hWnd,UINT msg,WPARAM wParam,LPARAM
// extract ptr to window class from creation data
const
CREATESTRUCTW
*
const
pCreate
=
reinterpret_cast
<
CREATESTRUCTW
*>
(
lParam
);
Window
*
const
pWnd
=
static_cast
<
Window
*>
(
pCreate
->
lpCreateParams
);
// set WinAPI-managed user data to store ptr to window
class
// set WinAPI-managed user data to store ptr to window
instance
SetWindowLongPtr
(
hWnd
,
GWLP_USERDATA
,
reinterpret_cast
<
LONG_PTR
>
(
pWnd
)
);
// set message proc to normal (non-setup) handler now that setup is finished
SetWindowLongPtr
(
hWnd
,
GWLP_WNDPROC
,
reinterpret_cast
<
LONG_PTR
>
(
&
Window
::
HandleMsgThunk
)
);
// forward message to window
class
handler
// forward message to window
instance
handler
return
pWnd
->
HandleMsg
(
hWnd
,
msg
,
wParam
,
lParam
);
}
// if we get a message before the WM_NCCREATE message, handle with default handler
...
...
@@ -122,9 +122,9 @@ LRESULT CALLBACK Window::HandleMsgSetup( HWND hWnd,UINT msg,WPARAM wParam,LPARAM
LRESULT
CALLBACK
Window
::
HandleMsgThunk
(
HWND
hWnd
,
UINT
msg
,
WPARAM
wParam
,
LPARAM
lParam
)
noexcept
{
// retrieve ptr to window
class
// retrieve ptr to window
instance
Window
*
const
pWnd
=
reinterpret_cast
<
Window
*>
(
GetWindowLongPtr
(
hWnd
,
GWLP_USERDATA
));
// forward message to window
class
handler
// forward message to window
instance
handler
return
pWnd
->
HandleMsg
(
hWnd
,
msg
,
wParam
,
lParam
);
}
...
...
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