Skip to content

Instantly share code, notes, and snippets.

@Fahrni
Last active May 28, 2016 06:00
Show Gist options
  • Save Fahrni/5a58f52c8c43eb3de2c5872fa7c696a2 to your computer and use it in GitHub Desktop.
Save Fahrni/5a58f52c8c43eb3de2c5872fa7c696a2 to your computer and use it in GitHub Desktop.
Base Class Window Procedure
EXTERNC ACLWINCB(LRESULT) ACLWindowDispatchProc
(
IN HWND hWnd,
IN UINT uMsg,
IN WPARAM wParam,
IN LPARAM lParam
)
{
UNALIGNED ACLWinBase* pWindow = NULL;
PWINMSGHNDLR pHandler = NULL;
LRESULT lResult = 1;
switch (uMsg)
{
case WM_CREATE:
{
// lparam is passed with a pointer to the "this" of our
// object. Grab it here and "attach" it to the window
// proc.
//
pWindow = (ACLWinBase*)(((LPCREATESTRUCT)lParam)->lpCreateParams);
pWindow->SetBoundWindow(hWnd);
break;
}
default:
{
// By default we're going to grab a pointer to the "this" we
// saved at Init time.
//
pWindow = ACLPrivateGetBoundWindow(hWnd);
break;
}
} // switch
if (pWindow)
{
lResult = pWindow->DispatchMessage(uMsg, wParam, lParam);
}
// If we couldn't get a window to dispatch to or the message returned 1
// then go ahead and call DefWindowProc.
//
if (pWindow == NULL || lResult == 1)
{
lResult = ::DefWindowProc(hWnd, uMsg, wParam, lParam);
}
return lResult;
} // ACLWindowDispatchProc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment