这个问题编译运行确实正常,但是跟踪调试一下,消息循环的处理不对,在WM_PAINT消息中,执行BeginPaint(HWND, LPPAINTSTRUCT)语句之后,就会产生WM_ERASEBKGND消息,之后就不再执行Paint了!!!而且消息好像也没有了,CE5.0的帮助说明如下:
Calling SetWindowLong with the GWL_WNDPROC index creates a subclass of the window class used to create the window. An application can subclass a system class, but should not subclass a window class created by another process. The SetWindowLong function creates the window subclass by changing the window procedure associated with a particular window class, causing the system to call the new window procedure instead of the previous one. An application must pass any messages not processed by the new window procedure to the previous window procedure by calling CallWindowProc. This allows the application to create a chain of window procedures.