Esempio n. 1
0
void CMyButtonEx::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	CRect rcClient;
	GetClientRect(&rcClient);

	CMemoryDC memoryDC(&dc, rcClient);
	DrawParentWndBg(GetSafeHwnd(), memoryDC->GetSafeHdc());

	switch (m_nBtnType) {
		case BT_PUSHBUTTON:
			DrawPushButton(&memoryDC, rcClient);
			break;
		case BT_RADIOBUTTON:
		case BT_CHECKBUTTON:
			DrawCheckButton(&memoryDC, rcClient);
			break;
		case BT_ICONBUTTON:
			DrawIconButton(&memoryDC, rcClient);
			break;
		case BT_MENUBUTTON:
			DrawMenuButton(&memoryDC, rcClient);
			break;
		case BT_SPLITBUTTON:
			DrawSplitButton(&memoryDC, rcClient);
			break;
		ASSERT(FALSE);
	}	
}
Esempio n. 2
0
bool wxWindowsPrintPreview::RenderPageFragment(float scaleX, float scaleY,
                                               int *nextFinalLine,
                                               wxPrinterDC& printer,
                                               wxMemoryDC& finalDC,
                                               const wxRect& rect,
                                               int pageNum)
{
    // compute 'rect' equivalent in the small final bitmap:
    const wxRect smallRect(wxPoint(0, *nextFinalLine),
                           wxPoint(int(rect.GetRight() * scaleX),
                                   int(rect.GetBottom() * scaleY)));
    wxLogTrace("printing",
               "rendering fragment of page %i: [%i,%i,%i,%i] scaled down to [%i,%i,%i,%i]",
               pageNum,
               rect.x, rect.y, rect.GetRight(), rect.GetBottom(),
               smallRect.x, smallRect.y, smallRect.GetRight(), smallRect.GetBottom()
               );

    // create DC and bitmap compatible with printer DC:
    wxBitmap large(rect.width, rect.height, printer);
    if ( !large.IsOk() )
        return false;

    // render part of the page into it:
    {
        PageFragmentDC memoryDC(&printer, large,
                                rect.GetPosition(),
                                wxSize(m_pageWidth, m_pageHeight));
        if ( !memoryDC.IsOk() )
            return false;

        memoryDC.Clear();

        if ( !RenderPageIntoDC(memoryDC, pageNum) )
            return false;
    } // release bitmap from memoryDC

    // now scale the rendered part down and blit it into final output:

    wxImage img;
    {
        wxDIB dib(large);
        if ( !dib.IsOk() )
            return false;
        large = wxNullBitmap; // free memory a.s.a.p.
        img = dib.ConvertToImage();
    } // free the DIB now that it's no longer needed, too

    if ( !img.IsOk() )
        return false;

    img.Rescale(smallRect.width, smallRect.height, wxIMAGE_QUALITY_HIGH);
    if ( !img.IsOk() )
        return false;

    wxBitmap bmp(img);
    if ( !bmp.IsOk() )
        return false;

    img = wxNullImage;
    finalDC.DrawBitmap(bmp, smallRect.x, smallRect.y);
    if ( bmp.IsOk() )
    {
        *nextFinalLine += smallRect.height;
        return true;
    }

    return false;
}
Esempio n. 3
0
void InjectorProc(void *injectorModule, unsigned int dataSize, const void *data)
{
	util::dcout << "In inject proc." << std::endl;

#if 0
	util::dcout << "Waiting for debugger ..." << std::endl;

	if(IsDebuggerPresent() == FALSE)
	{
		while(IsDebuggerPresent() == FALSE)
		{
			Sleep(100);
		}

		DebugBreak();
	}

	util::dcout << "Debugger attached." << std::endl;
#endif

	HWND targetWindow = GetTargetWindow();
	if(targetWindow == NULL)
	{
		util::dcout << "Cannot find window !" << std::endl;

		return;
	}

	CheckWindow(targetWindow);

	OpenGLDrawData oglData;
	oglData.window = targetWindow;
	if(!InitOpenGLContext(oglData))
	{
		return;
	}
	InitOpenGL(oglData);

	MemoryDC memoryDC(oglData.width, oglData.height);
	oglData.memoryDC = &memoryDC;
	Init(oglData);

	wglMakeCurrent(NULL, NULL);
	g_oglData = &oglData;

	//MakeWindowFullyTransparent(targetWindow);
	WNDPROC originalWndProc = (WNDPROC)GetWindowLongPtr(targetWindow, GWLP_WNDPROC);
	g_originalWndProc = originalWndProc;
	SetWindowLongPtr(targetWindow, GWLP_WNDPROC, (LONG_PTR)HookWndProc);
	InvalidateRect(targetWindow, NULL, TRUE);

	//DrawLoop(oglData);
	//DrawFrame(oglData);
	Sleep(30000);

	wglMakeCurrent(oglData.oglDC, oglData.oglContext);
	DeInit(oglData);
	FreeOpenGLContext(oglData);

	SetWindowLongPtr(targetWindow, GWLP_WNDPROC, (LONG_PTR)originalWndProc);
	//MakeWindowUndo(targetWindow);
	InvalidateRect(targetWindow, NULL, TRUE);

	util::dcout << "Exiting inject proc." << std::endl;
}