或者,您也可以覆盖上创建的窗口过程而不是注册一个新的窗口类:
WNDPROC g_ComboBoxProc;
LRESULT CALLBACK SearchBoxProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
// Special handling here.
return CallWindowProc(g_ComboBoxProc, hwnd, uMsg, wParam, lParam);
}
HWND CreateSearchBox(LPCTSTR lpWindowName, DWORD dwStyle, int x, int y,
int w, int h, HWND hWndParent, HMENU hMenu,
HINSTANCE hInstance, LPVOID lpParam) {
HWND hwnd = CreateWindow(TEXT("COMBOBOX"), lpWindowName, dwStyle,
x, y, w, h, hWndParent, hMenu, hInstance);
if (hwnd) {
g_ComboBoxProc = (WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC,
(WNDPROC) SearchBoxProc);
}
return hwnd;
}
虽然SetWindowSubclass或许应该被替代。