Ejemplo n.º 1
0
CMemDC::CMemDC(CDC& dc, CWnd* pWnd) :
	m_dc(dc), m_bMemDC(FALSE), m_hBufferedPaint(NULL), m_pOldBmp(NULL)
{
	ASSERT_VALID(pWnd);

	pWnd->GetClientRect(m_rect);

	m_rect.right += pWnd->GetScrollPos(SB_HORZ);
	m_rect.bottom += pWnd->GetScrollPos(SB_VERT);

	HDC hdcPaint = NULL;

	if (!GetGlobalData()->m_bBufferedPaintInited)
	{
		BufferedPaintInit();
		GetGlobalData()->m_bBufferedPaintInited = TRUE;
	}

	m_hBufferedPaint = BeginBufferedPaint(dc.GetSafeHdc(), m_rect, BPBF_TOPDOWNDIB, NULL, &hdcPaint);

	if (m_hBufferedPaint != NULL && hdcPaint != NULL)
	{
		m_bMemDC = TRUE;
		m_dcMem.Attach(hdcPaint);
	}
	}
Ejemplo n.º 2
0
AeroControlBase::AeroControlBase()
    : gdiplusToken(0)
{
    GdiplusStartupInput gdiplusStartupInput;
    m_regEnableDWMFrame = CRegDWORD(L"Software\\TortoiseSVN\\EnableDWMFrame", TRUE);

    if (GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL)==Ok)
    {
    }
    BufferedPaintInit();
}
//   PURPOSE: Saves instance handle and creates main window
//
//   COMMENTS:
//
//        In this function, we save the instance handle in a global variable and
//        create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
    BOOL fPassed = FALSE;
    g_hInst = hInstance; // Store instance handle in our global variable
    
    HWND hWnd = CreateWindow(g_szWindowClass, g_szTitle, WS_OVERLAPPEDWINDOW,
                             CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
    if (hWnd)
    {
        fPassed = TRUE;
        BufferedPaintInit();
        
        ShowWindow(hWnd, nCmdShow);
        UpdateWindow(hWnd);
    }
    
    return fPassed;
}
Ejemplo n.º 4
0
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd )
{
	theInstance = hInstance;

	RunTests();
	//OneOff();

	ULONG_PTR gdiplusToken;
	Gdiplus::GdiplusStartupInput gdiplusStartupInput;
	Gdiplus::GdiplusStartup( &gdiplusToken, &gdiplusStartupInput, NULL );

	CoInitializeEx( NULL, COINIT_APARTMENTTHREADED );
	BufferedPaintInit();

	if ( !InitApp() || !RegisterTextEdit( hInstance ) )
		return 0;

	HWND hwnd = CreateWindow( APPCLASS,
	                          TEXT( "Let's edit some shit, yeah?" ),
	                          WS_OVERLAPPEDWINDOW,
	                          CW_USEDEFAULT, CW_USEDEFAULT,
	                          CW_USEDEFAULT, CW_USEDEFAULT,
	                          NULL,
	                          NULL,
	                          theInstance,
	                          0 );

	ShowWindow( hwnd, nShowCmd );

	MSG msg;
	while ( GetMessage( &msg, NULL, 0, 0 ) )
	{
		TranslateMessage( &msg );
		DispatchMessage ( &msg );
	}

	BufferedPaintUnInit();
	CoUninitialize();
	Gdiplus::GdiplusShutdown( gdiplusToken );

	return 0;
}
Ejemplo n.º 5
0
CMemDC::CMemDC(CDC& dc, const CRect& rect) :
	m_dc(dc), m_bMemDC(FALSE), m_hBufferedPaint(NULL), m_pOldBmp(NULL), m_rect(rect)
{
	ASSERT(!m_rect.IsRectEmpty());

	HDC hdcPaint = NULL;

	if (!GetGlobalData()->m_bBufferedPaintInited)
	{
		BufferedPaintInit();
		GetGlobalData()->m_bBufferedPaintInited = TRUE;
	}

	m_hBufferedPaint = BeginBufferedPaint(dc.GetSafeHdc(), m_rect, BPBF_TOPDOWNDIB, NULL, &hdcPaint);

	if (m_hBufferedPaint != NULL && hdcPaint != NULL)
	{
		m_bMemDC = TRUE;
		m_dcMem.Attach(hdcPaint);
	}
}
Ejemplo n.º 6
0
//  Entry to the app
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR /*lpCmdLine*/, int /*nCmdShow*/)
{
    g_hInstance = hInstance;

    //  Mark that this process is DPI aware.
    SetProcessDPIAware();

    // Init COM and double-buffered painting
    HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
    if (SUCCEEDED(hr))
    {
        hr = BufferedPaintInit();
        g_bDblBuffered = SUCCEEDED(hr);

        // Init volume monitor
        g_pVolumeMonitor = new (std::nothrow) CVolumeMonitor();
        if (g_pVolumeMonitor)
        {
            hr = g_pVolumeMonitor->Initialize();
            if (SUCCEEDED(hr))
            {
                // Get initial volume level so that we can figure out a good window size
                g_pVolumeMonitor->GetLevelInfo(&g_currentVolume);

                WNDCLASSEX wcex = { sizeof(wcex) };
                wcex.style          = CS_HREDRAW | CS_VREDRAW;
                wcex.lpfnWndProc    = WndProc;
                wcex.hInstance      = g_hInstance;
                wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
                wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
                wcex.lpszClassName  = g_szWindowClass;

                RegisterClassEx(&wcex);

                // Create the (only) window
                DWORD const dwStyle = WS_POPUP;     // no border or title bar
                DWORD const dwStyleEx = WS_EX_LAYERED | WS_EX_TOPMOST | WS_EX_NOACTIVATE;   // transparent, topmost, with no taskbar item
                g_hwndOSD = CreateWindowEx(dwStyleEx, g_szWindowClass, NULL, dwStyle, 0, 0, 0, 0, NULL, NULL, g_hInstance, NULL);
                if (g_hwndOSD)
                {
                    // Hide the window
                    ShowWindow(g_hwndOSD, SW_HIDE);

                    // Main message loop
                    MSG msg;
                    while (GetMessage(&msg, NULL, 0, 0))
                    {
                        TranslateMessage(&msg);
                        DispatchMessage(&msg);
                    }
                }

                if (g_bDblBuffered)
                    BufferedPaintUnInit();

                g_pVolumeMonitor->Dispose();
                g_pVolumeMonitor->Release();
            }
        }
        CoUninitialize();
    }

    return 0;
}