示例#1
0
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;
}
示例#2
0
LRESULT CALLBACK player_impl::static_win_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
	player_impl* this_ptr = window_pool.lookup_window(hwnd);
	if (!this_ptr)
	{
		::logger("Impossible running to here!\n");
		assert(0); // 不可能执行到此!!!
		return DefWindowProc(hwnd, msg, wparam, lparam);
	}

	return this_ptr->win_wnd_proc(hwnd, msg, wparam, lparam);
}
示例#3
0
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);
}
示例#4
0
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;
}
示例#5
0
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;
}