我想知道为什么一个类中的窗口过程仅在我返回非静态窗口过程时才起作用。那么,为什么我必须返回操作当前窗口的窗口过程 - 为什么函数调用不够?
我用过这里的例子: http://www.codeproject.com/Articles/17894/Simple-Mapping-of-WndProc-to-your-Specific-Class-W
LRESULT CALLBACK Win::WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
// Recover the pointer to our class, don't forget to type cast it back
CWin* winptr = (CWin*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
// Check if the pointer is NULL and call the Default WndProc
if (winptr == NULL) {
return DefWindowProc(hwnd, message, wParam, lParam);
} else {
// Call the Message Handler for my class (MsgProc in my case)
return winptr->MsgProc(hwnd, message, wParam, lParam); // <--
}
正在调用的成员函数如下所示:
switch (msg) {
case WM_NCPAINT:
break;
...
}
实际上当前窗口应该只是白色。没有任何标题栏等 这仅在我返回函数
时有效return winptr->MsgProc(hwnd, message, wParam, lParam); // working
winptr->MsgProc(hwnd, message, wParam, lParam); // has no effect
那么,为什么我必须返回该函数以便我可以操作当前窗口?