或者,您也可以覆蓋上創建的窗口過程而不是註冊一個新的窗口類:
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或許應該被替代。