BOOL player_impl::unsubclasswindow(HWND hwnd) { if (!IsWindow(m_hwnd) || !IsWindow(hwnd) || m_hwnd != hwnd || !m_old_win_proc) { return FALSE; } // 设置为原来的窗口过程. ::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)m_old_win_proc); window_pool.remove_window(this); m_hwnd = NULL; return TRUE; }
BOOL player_impl::destory_window() { if (!IsWindow(m_hwnd)) return FALSE; BOOL ret = DestroyWindow(m_hwnd); if (m_brbackground) { DeleteObject(m_brbackground); m_brbackground = NULL; } window_pool.remove_window(this); return ret; }
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; }