Beispiel #1
0
HRESULT FMPlayerDShow::SetVideoRect(const RECT &rcPos)
{
	HRESULT hr = S_FALSE; 

	WTL::CRect wr = rcPos; 

	m_VideoRect = rcPos; 
	if (m_VideoWnd)
	{

		WTL::CSize arxy = GetVideoSize(); 
		WTL::CRect vr = WTL::CRect(0,0,0,0);
		WTL::CSize ws = wr.Size(); 

		int w = ws.cx;
		int h = ws.cy;

		double m_ZoomX = 1; 
		double m_ZoomY = 1; 
		double m_PosX = 0.5; 
		double m_PosY = 0.5; 

		BOOL bFromInside = TRUE;  

		if(bFromInside)
		{
			h = ws.cy;
			w = MulDiv(h, arxy.cx, arxy.cy);

			if(bFromInside && w > ws.cx)
			{
				w = ws.cx;
				h = MulDiv(w, arxy.cy, arxy.cx);
			}
		}

		WTL::CSize size((int)(m_ZoomX*w), (int)(m_ZoomY*h));

		WTL::CPoint pos(
			(int)(m_PosX*(wr.Width()*3 - m_ZoomX*w) - wr.Width()), 
			(int)(m_PosY*(wr.Height()*3 - m_ZoomY*h) - wr.Height()));


		vr = WTL::CRect(pos, size);

		wr |= WTL::CRect(0,0,0,0);
		vr |= WTL::CRect(0,0,0,0);

		{

			hr = m_pBV->SetDefaultSourcePosition();
			hr = m_pBV->SetDestinationPosition(vr.left, vr.top, vr.Width(), vr.Height());
			hr = m_VideoWnd->SetWindowPosition(wr.left, wr.top, wr.Width(), wr.Height());


		}
	}

	return hr; 
}
Beispiel #2
0
LRESULT QFrame::OnHtmlNotify( UINT uMsg, WPARAM wParam, LPARAM lParam )
{
    switch(((NMHDR*)lParam)->code) 
    {
    case HLN_DOCUMENT_COMPLETE:
        {
            if ( !_HasFlag(GetStyle(),WS_CHILD) )
            {
                WTL::CRect r;
                GetWindowRect(&r);

                // 非子窗口,调整窗体为合适大小
                int nWidth = max(HTMLayoutGetMinWidth(m_hWnd), (UINT)r.Width()); 
                WTL::CRect rcNew;
                rcNew.SetRect(r.left, r.top, 
                    nWidth + r.left, 
                    r.top + max((UINT)r.Height(), HTMLayoutGetMinHeight(m_hWnd,nWidth)));
                AdjustWindowRectEx( &rcNew, GetStyle(), FALSE, GetExStyle());

                // 调整大小,位置不变
                SetWindowPos(NULL, 0, 0, rcNew.Width(), rcNew.Height(), SWP_NOZORDER | SWP_NOMOVE);

                size_min_ = rcNew.Size();
                // 设置title
                ctl_title_ = GetCtrl("#wc-title");
                if (ctl_title_.is_valid())
                {
                    SetWindowText(ctl_title_.GetText());
                }
            }
            break;
        }
    }
    return QView::OnHtmlNotify(uMsg, wParam, lParam);
}
HBRUSH AtlGetBackgroundBrush(HWND hWnd, HWND hwndParent)
{
	ATL::CWindow wnd = hWnd;
	ATL::CWindow wndParent = hwndParent;
	WTL::CClientDC dcParent = wndParent;
	WTL::CRect rcParent;
	wndParent.GetWindowRect(&rcParent);
	WTL::CDC dcCompat1;
	dcCompat1.CreateCompatibleDC(dcParent);
	WTL::CBitmap bmpCompat1;
	bmpCompat1.CreateCompatibleBitmap(dcParent, rcParent.Width(), rcParent.Height());
	HBITMAP hOldBmp1 = dcCompat1.SelectBitmap(bmpCompat1);
	wndParent.SendMessage(WM_ERASEBKGND, (WPARAM) (HDC) dcCompat1, 0);
	wndParent.SendMessage(WM_PRINTCLIENT, (WPARAM) (HDC) dcCompat1, (LPARAM)(PRF_ERASEBKGND | PRF_CLIENT | PRF_NONCLIENT));
	WTL::CRect rcWin;
	wnd.GetWindowRect(&rcWin);
	WTL::CDC dcCompat2;
	dcCompat2.CreateCompatibleDC();
	WTL::CBitmap bmpCompat2;
	bmpCompat2.CreateCompatibleBitmap(dcCompat1, rcWin.Width(), rcWin.Height());
	HBITMAP hOldBmp2 = dcCompat2.SelectBitmap(bmpCompat2);
	WTL::CRect rcSnap = rcWin;
	::MapWindowPoints(NULL, wndParent, (LPPOINT) (LPRECT) &rcSnap, 2);
	dcCompat2.BitBlt(0, 0, rcWin.Width(), rcWin.Height(), dcCompat1, rcSnap.left, rcSnap.top, SRCCOPY);
	HBRUSH hBrush = ::CreatePatternBrush(bmpCompat2);
	dcCompat1.SelectBitmap(hOldBmp1);
	dcCompat2.SelectBitmap(hOldBmp2);
	return hBrush;
}
LRESULT SwitcherSettingsDialog::OnInitDialog(UINT, WPARAM, LPARAM, BOOL&) {
	schema_list_.SubclassWindow(GetDlgItem(IDC_SCHEMA_LIST));
	schema_list_.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);
	schema_list_.AddColumn(L"方案名稱", 0);
	WTL::CRect rc;
	schema_list_.GetClientRect(&rc);
	schema_list_.SetColumnWidth(0, rc.Width() - 20);

	description_.Attach(GetDlgItem(IDC_SCHEMA_DESCRIPTION));
	
	hotkeys_.Attach(GetDlgItem(IDC_HOTKEYS));
	hotkeys_.EnableWindow(FALSE);

	get_schemata_.Attach(GetDlgItem(IDC_GET_SCHEMATA));
	get_schemata_.EnableWindow(TRUE);
	
	Populate();
	
	CenterWindow();
	BringWindowToTop();
	return TRUE;
}
Beispiel #5
0
BOOL QView::MakeTransparent(BOOL bTransparent/* = TRUE*/)
{
    CBackHelper(this/*, CBackHelper::BACK_TRANS_RENDERPARENT*/);

    return TRUE;

    using namespace htmlayout;
    using namespace htmlayout::dom;

    // 非子窗口不可以使用透明效果
    if ( ((GetStyle() & WS_CHILD) == 0) || (NULL == he_wrapper_) )
    {
        ATLASSERT(FALSE);
        return FALSE;
    }

    ECtrl eThis = GetBody();
    // html背景URI
    CStdString sBackImgURI;
    sBackImgURI.Format(L"%s_back_%p.png",quibase::GetModulePath(),GetSafeHwnd());
    if ( !bTransparent )
    {
        // 将背景图像删除掉
        char ch = 0;
        return HTMLayoutDataReadyAsync(GetSafeHwnd(), 
            L"file://" + sBackImgURI, (LPBYTE)&ch, 1, HLRT_DATA_IMAGE);
    }
//     else
//     {
//         // 写入透明标记
//         eThis.set_attribute("transparent",L"true");
//     }

    // 首先获取QView相对于Parent的位置
    //!! <widget type="windowed" /> 不能使用padding属性
    // 需要QView完全的覆盖到widget上面
    ATLASSERT(element(he_wrapper_).get_style_attribute("padding") == NULL);
    WTL::CRect rcCont = element(he_wrapper_).get_location(ROOT_RELATIVE | PADDING_BOX);
    WTL::CRect rcClient = element(element(he_wrapper_).root()).get_location();

    // 找到上层的实体窗口句柄
    BOOL bRet = FALSE;
    image *pImgParent = image::create(rcCont.Width(), rcCont.Height());
    image *pImgThis = NULL;
    do 
    {
        // 先将父窗口整个区域的图像拷贝下来
        if (NULL == (image::create(rcClient.Width(),rcClient.Height())))
            break;
        if ( !HTMLayoutRender(GetParent().m_hWnd,pImgParent->handle(),rcCont) )
            break;
        // 将本窗口与父亲窗口重叠区域的背景保存到图像中
        if (NULL == (pImgThis = image::create(rcCont.Width(), rcCont.Height())))
            break;
        graphics(pImgThis).blit_image(pImgParent,0,0, rcCont.left, rcCont.top,
            rcCont.right, rcCont.bottom);

        // 成功 
        bRet = TRUE;
    } while (false);

    // 将重叠区域图像数据写到内存缓冲区中
    if ( bRet )
    {
        struct write_to_thisback : public htmlayout::writer
        {   
            QBuffer buf;
            virtual bool write( aux::bytes data )
            {
                return buf.Write(data.start,data.length);
            }
        } wtt;
        // 参数0,指示写入格式为png格式
        pImgThis->save(wtt, 0);
        // 使用透明效果
        // 现在改写背景style和背景的图像地址,原来的自定义的背景数据将丢失
        eThis.SetBkgndImage(sBackImgURI);
        eThis.SetBkgndRepeat(L"no-repeat");
        eThis.SetBkgndPosition(0,0,0,0);
        // 将数据更新到指定的URI中
        bRet = HTMLayoutDataReadyAsync(GetSafeHwnd(),L"file://" + sBackImgURI,
            wtt.buf.GetBuffer(0),wtt.buf.GetBufferLen(),HLRT_DATA_IMAGE);

        wtt.buf.FileWrite(L"F:/a.png");
        eThis.SetBkgndImage(L"F:/a.png");
    }

    // 释放资源
    if (NULL != pImgThis)
    {
        delete pImgThis;
    }
    if (NULL != pImgParent)
    {
        delete pImgParent;
    }

    return bRet;
}