Re: Subclassing error (127)
For a WM_PAINT message, I believe you need to call BeginPaint(). This gets you the DC for the HWND. You also need to call EndPaint() before returning (don't do a ReleaseDC() on the HWND DC).
Regards,
Paul McKenzie
Re: Subclassing error (127)
Thanks Paul. Error 127 is fixed.
Now I got another problem: This library can only be used on one window.
When I use it on second window with another bmp, the first window also
got painted with the second bmp.
How do I create a different window procedure for the second window?
TIA
Re: Subclassing error (127)
You do the same for the second window as you would the first, but there are some things that I see with your code that will not work correctly if you try to do this.
When you subclassed the second window, where do you save the "oldproc" for the second window? You have one variable called oldproc and you are attempting to use it for more than one window.
You need to build a table of hWnds mapped to their oldProc's. When you subclass a window you should check the table to see a) if the window has been subclassed already and b) if not subclassed, get the hwnd and oldproc, pair them together, and store them in an array (or map, or whatever your favorite data structure is) keyed by the hWnd value.
When it's time to call the oldproc, you lookup the oldproc in the table by using the hwnd as a key, and call that oldproc. Remember, you're dealing with *multiple* windows, all with differing "oldprocs"!
When you unsubclass the window, remove the hwnd / oldproc pair from the table.
Hope this helps.
Regards,
Paul McKenzie