|
-
April 21st, 1999, 10:17 AM
#1
Subclassing error (127)
What's wrong with following code? It crashes at run time after one succeful
draw. The error code is 127. Which means the procedure (don't know if it's
the new procedure or the old one) can't be found.
Please help.
// declare
WNDPROC oldproc=NULL;
LRESULT CALLBACK NewWinProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM
lParam);
// code in main
........
oldproc = (WNDPROC)GetWindowLong(hWnd, GWL_WNDPROC);
SetWindowLong(hWnd, GWL_WNDPROC, (LONG)NewWinProc);
// subrouting
LRESULT CALLBACK NewWinProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM
lParam)
{
HDC hDC, hMemDC;
HBITMAP hBmp;
BITMAP bmpp;
int width, height;
if (Msg == WM_PAINT)
{
hDC = GetDC(hWnd);
hMemDC = CreateCompatibleDC(hDC);
hBmp = LoadImage(NULL, bmpNam, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); // bmpNam is global
SelectObject(hMemDC, hBmp);
GetObject(hBmp, 64, &bmpp);
width = bmpp.bmWidth;
height= bmpp.bmHeight;
BitBlt(hDC, x0, y0, width, height, hMemDC, 0, 0, SRCCOPY); // x0 & y0 are globals
DeleteDC(hMemDC);
DeleteObject(hBmp);
ReleaseDC(hWnd, hDC);
}
return CallWindowProc(oldproc, hWnd, Msg, wParam, lParam);
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|