LRESULT CALLBACK win_cbt_filter_hook(int code, WPARAM wParam, LPARAM lParam) { if (code != HCBT_CREATEWND) { return CallNextHookEx(win_tls->hook, code, wParam, lParam); } else { HWND hwnd = (HWND)wParam; player_impl *win = win_tls->win; window_pool.add_window(hwnd, win); } return CallNextHookEx(win_tls->hook, code, wParam, lParam); }
BOOL player_impl::subclasswindow(HWND hwnd, BOOL in_process) { if (!IsWindow(hwnd)) return FALSE; if (IsWindow(m_hwnd)) return FALSE; // 创建非纯黑色的画刷, 用于ddraw播放时刷背景色. m_brbackground = CreateSolidBrush(RGB(0, 0, 1)); window_pool.add_window(hwnd, this); m_old_win_proc = (WNDPROC)::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)&player_impl::static_win_wnd_proc); if (!m_old_win_proc) { window_pool.remove_window(this); if (in_process) return FALSE; } m_hwnd = hwnd; return TRUE; }