0
votes

I'm creating an application for capturing the screen or a part of it, and for that I need to select the part of the screen I want to capture.

The idea is to create a fullscreen semi-transparent window and draw thing on it so the user can see what he is doing. I have a working implementation where the selected area is dislayed as a wxPanel, but I want to rewrite it to paint everything to the main wxPanel manually.

frame = new wxFrame(NULL, -1, "", wxPoint(0,0), wxSize(0,0), wxSTAY_ON_TOP|wxFRAME_NO_TASKBAR|wxFRAME_SHAPED);

panel = new wxPanel(frame, -1);

SetTopWindow( frame );

panel->Bind(wxEVT_KEY_DOWN, &wxMiniApp::OnKeyDown, this);
panel->Bind(wxEVT_KEY_UP, &wxMiniApp::OnKeyUp, this);
panel->Bind(wxEVT_LEFT_DOWN, &wxMiniApp::OnMouseStart, this);
panel->Bind(wxEVT_LEFT_UP, &wxMiniApp::OnMouseEnd, this);
panel->Bind(wxEVT_MOTION, &wxMiniApp::OnMouseMove, this);

panel->Bind(wxEVT_PAINT, &wxMiniApp::OnPaintPanel, this);

panel->SetFocus();

panel->SetBackgroundColour(wxColor(0,0,0,100));
panel->SetBackgroundStyle(wxBG_STYLE_PAINT);

frame->SetBackgroundColour(wxColor(0,0,0,0));

frame->Show();

frame->ShowFullScreen(true);

I use panel to capture the mouse/keyboard events and I want to do the painting there too, but I don't know how to do this.

I want to have semi-transparent black background and the selected area should be transparent white or even fully transparent (without the black background).

The result of every attempt was that either it draw a solid color background or I got the famous WinXP lag effect.

Can you give me a basic OnPaintPanel(wxPaintEvent &event) implementation using x, y, with, height of the selected area (can be in wxPython too, if you're more comfortable with it) ?

1

1 Answers

1
votes

You need to use SetTransparent(), wxDC doesn't support using alpha transparency anyhow (wxGraphicsContext does but it wouldn't help here).