Hmm, this is what I was able to do so far:
Code:
// Create a pointer to store the window proc I'll get from SDL
typedef LRESULT (CALLBACK *pfnMyWinProc)(HWND, UINT, WPARAM, LPARAM);
pfnMyWinProc MyProc1;
// Declare my own WindowProc
LRESULT CALLBACK WndProc (HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam);
// This part is called just before we get into the game loop:
//--------------------------------------------------------------------------
// Get the wndProc
MyProc1 = (pfnMyWinProc)GetWindowLong(SDLWindowHandle, GWL_WNDPROC);
// Set the winProc
SetWindowLong(SDLWindowHandle, GWL_WNDPROC, WndProc);
// And heres my own WndProc
//--------------------------------------------------------------------------
LRESULT CALLBACK WndProc (HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
// Look for a WM_COMMAND, since thats where menu commands are
if (Message == WM_COMMAND)
MessageBox(NULL, "Hello", "Hello", MB_OK);
// Send it on to the old window proc
return MyProc1(hWnd, Message, wParam, lParam);
}
My problem is, I'm calling:
SetWindowLong(SDLWindowHandle, GWL_WNDPROC, WndProc);
Which is trying to assign my WndProc as the new value, which is the way I think it should work. That doesn't compile though, the third argument is supposed to be a long.
So, I figure I'll do this:
SetWindowLong(SDLWindowHandle, GWL_WNDPROC, (DWORD) WndProc);
By typecasting my wndProc to a DWORD (unsigned long). This compiles, but when run the program closes prematurely, probably because I stuffed the third parameter up.
How can I tell it to use my WndProc function? MSDN says the third parameter should be the address of the new proc, but it wants a long If I'm supposed to convert the address of the function to a long, then I'm not sure how