thanks ken, that works, but when i tried to make it a bit more efficient, i ran into some trouble.
observe: (by the way, i allocated an extra byte to the window memory)
Code:
LRESULT CALLBACK cBen::cBenProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
cBen *it;
if (GetWindowLong(hwnd,0))
it=(cBen *)GetWindowLong(hwnd,GWL_USERDATA);
switch (msg)
{
case WM_NCCREATE:
LPCREATESTRUCT lpc;
lpc=(LPCREATESTRUCT)lParam;
SetWindowLong(hwnd,GWL_USERDATA,(LONG)lpc->lpCreateParams);
SetWindowLong(hwnd,0,1);
return DefWindowProc(hwnd,msg,wParam,lParam);
case WM_CLOSE:
it->value=5;
DestroyWindow(hwnd);
return 0;
case WM_DESTROY:
return 0;
default:
return DefWindowProc(hwnd,msg,wParam,lParam);
}
}
clearly, i'm trying to make it so i only ever have to retrieve a pointer once during the function. but the line:
causes one of those annoying access violations.
Code:
First-chance exception in class.exe: 0xC0000005: Access Violation.
If im not mistaken, the pointer i retrieved points to somewhere i shouldn't be changing. however, it works fine when the pointer is retrieved within the WM_CLOSE message capture, and the code has not been modified, just moved. so what is going on?
damn i hate this static crap! if only the wndproc could avoid being static, then it would be easy. are you sure it has to be so difficult?