Commit 9efa93f3 authored by chili's avatar chili
Browse files

use exception for GetMessage error

parent bb3081ad
...@@ -42,7 +42,7 @@ int CALLBACK WinMain( ...@@ -42,7 +42,7 @@ int CALLBACK WinMain(
// check if GetMessage call itself borked // check if GetMessage call itself borked
if( gResult == -1 ) if( gResult == -1 )
{ {
return -1; throw CHWND_LAST_EXCEPT();
} }
// wParam here is the value passed to PostQuitMessage // wParam here is the value passed to PostQuitMessage
......
...@@ -109,11 +109,11 @@ LRESULT CALLBACK Window::HandleMsgSetup( HWND hWnd,UINT msg,WPARAM wParam,LPARAM ...@@ -109,11 +109,11 @@ LRESULT CALLBACK Window::HandleMsgSetup( HWND hWnd,UINT msg,WPARAM wParam,LPARAM
// extract ptr to window class from creation data // extract ptr to window class from creation data
const CREATESTRUCTW* const pCreate = reinterpret_cast<CREATESTRUCTW*>(lParam); const CREATESTRUCTW* const pCreate = reinterpret_cast<CREATESTRUCTW*>(lParam);
Window* const pWnd = static_cast<Window*>(pCreate->lpCreateParams); 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) ); SetWindowLongPtr( hWnd,GWLP_USERDATA,reinterpret_cast<LONG_PTR>(pWnd) );
// set message proc to normal (non-setup) handler now that setup is finished // set message proc to normal (non-setup) handler now that setup is finished
SetWindowLongPtr( hWnd,GWLP_WNDPROC,reinterpret_cast<LONG_PTR>(&Window::HandleMsgThunk) ); 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 ); return pWnd->HandleMsg( hWnd,msg,wParam,lParam );
} }
// if we get a message before the WM_NCCREATE message, handle with default handler // 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 ...@@ -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 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 )); 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 ); return pWnd->HandleMsg( hWnd,msg,wParam,lParam );
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment