// Paints the entire non-client area.  
//  Creates an in-memory DC to draw on to reduce flicker
void cef_dark_window::DoPaintNonClientArea(HDC hdc)
{
    EnforceMenuBackground();

    HDC hdcOrig = hdc;
    RECT rectWindow;
    GetWindowRect(&rectWindow);

    int Width = ::RectWidth(rectWindow);
    int Height = ::RectHeight(rectWindow);

    HDC dcMem = ::CreateCompatibleDC(hdc);
    HBITMAP bm = ::CreateCompatibleBitmap(hdc, Width, Height);
    HGDIOBJ bmOld = ::SelectObject(dcMem, bm);

    hdc = dcMem;

    InitDeviceContext(hdc);
    InitDeviceContext(hdcOrig);
    DoDrawFrame(hdc);
    DoDrawSystemMenuIcon(hdc);
    DoDrawTitlebarText(hdc);
    DoDrawSystemIcons(hdc);
    DoDrawMenuBar(hdc);

    ::BitBlt(hdcOrig, 0, 0, Width, Height, dcMem, 0, 0, SRCCOPY);

    ::SelectObject(dcMem, bmOld);
    ::DeleteObject(bm);
    ::DeleteDC(dcMem);
}
static void WindowMinMaxInfo(TMinMaxInfo far * MinMaxInfo)
{
    int X, Y;
    TEXTMETRIC Metrics;

    InitDeviceContext();
    GetTextMetrics(DC, &Metrics);
    CharSize.x = Metrics.tmMaxCharWidth;
    CharSize.y = Metrics.tmHeight + Metrics.tmExternalLeading;
    CharAscent = Metrics.tmAscent;
    X = Min(_ScreenSize.x * CharSize.x + GetSystemMetrics(SM_CXVSCROLL),
    GetSystemMetrics(SM_CXSCREEN)) + GetSystemMetrics(SM_CXFRAME) * 2;
    Y = Min(_ScreenSize.y * CharSize.y + GetSystemMetrics(SM_CYHSCROLL) +
    GetSystemMetrics(SM_CYCAPTION), GetSystemMetrics(SM_CYSCREEN)) +
    GetSystemMetrics(SM_CYFRAME) * 2;
    (*MinMaxInfo)[1].x = X;
    (*MinMaxInfo)[1].y = Y;
    (*MinMaxInfo)[3].x = CharSize.x * 16 + GetSystemMetrics(SM_CXVSCROLL) +
    GetSystemMetrics(SM_CXFRAME) * 2;
    (*MinMaxInfo)[3].y = CharSize.y * 4 + GetSystemMetrics(SM_CYHSCROLL) +
    GetSystemMetrics(SM_CYFRAME) * 2 + GetSystemMetrics(SM_CYCAPTION);
    (*MinMaxInfo)[4].x = X;
    (*MinMaxInfo)[4].y = Y;
    DoneDeviceContext();
}
static void ShowText(int L, int R)
{
    if (L < R)
        {
        InitDeviceContext();
        TextOut(DC, (L - _Origin.x) * CharSize.x,
                    (_Cursor.y - _Origin.y) * CharSize.y,
                    ScreenPtr(L, _Cursor.y), R - L);
        DoneDeviceContext();
        }
}
示例#4
0
HRESULT D3D11Object::Initialize( HWND &hWnd, ID3D11UnorderedAccessView** ppResultUAV )
{
	printf("Initializing DXObject...\n");

	HRESULT hr = S_OK;

	RECT rc;
	GetClientRect( hWnd, &rc );
	UINT width = rc.right - rc.left;
	UINT height = rc.bottom - rc.top;

	InitDeviceContext(static_cast<int>(HEIGHT), static_cast<int>(WIDTH), hWnd );
	m_pSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), reinterpret_cast<void**>(&m_pBackBufferTexture) );
	CreateBufferTexUAV( m_pBackBufferTexture, ppResultUAV );
	m_pDevice->CreateRenderTargetView( m_pBackBufferTexture, NULL, &m_pRenderTargetView );
	CreateViewport(width, height);
	CreateSamplerStates();

	return hr;
}
static void WindowPaint(VOID)
{
    int X1, X2, Y1, Y2;

    Painting = TRUE;
    InitDeviceContext();
    X1 = Max(0, PS.rcPaint.left / CharSize.x + _Origin.x);
    X2 = Min(_ScreenSize.x,
             (PS.rcPaint.right + CharSize.x - 1) / CharSize.x + _Origin.x);
    Y1 = Max(0, PS.rcPaint.top / CharSize.y + _Origin.y);
    Y2 = Min(_ScreenSize.y,
             (PS.rcPaint.bottom + CharSize.y - 1) / CharSize.y + _Origin.y);
    while (Y1 < Y2)
        {
        TextOut(DC, (X1 - _Origin.x) * CharSize.x, (Y1 - _Origin.y) * CharSize.y,
                    ScreenPtr(X1, Y1), X2 - X1);
        ++Y1;
        }
    DoneDeviceContext();
    Painting = FALSE;
}