Function to making screenshoot (wxScreenDC)

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
woser
Earned a small fee
Earned a small fee
Posts: 18
Joined: Thu Nov 18, 2010 8:32 am

Function to making screenshoot (wxScreenDC)

Post by woser » Thu Nov 18, 2010 8:36 am

Hi I wrote function to make a screenshot , it is working but only when the second monitor is in the right side of the properties of screen (windows) , in the over case it shows only black shape. Where the problem is ?

void MakeScreenShot()
{
wxScreenDC dcScreen;

int height = GetSystemMetrics(SM_CYVIRTUALSCREEN ) ;
int width = GetSystemMetrics(SM_CXVIRTUALSCREEN) ;

wxBitmap screenshot(width, height,-1);

wxMemoryDC memDC;

memDC.SelectObject(screenshot);
memDC.Blit( 0, 0,
width, //Kopiuj szerokosc
height, //Kopiuj wysykosc
&dcScreen, //Skad kopiujemy
0, //Oryginalny X
0);

memDC.SelectObject(wxNullBitmap);

//NO i zapisujemy nasza bitmapke
screenshot.SaveFile("my_screenshot.jpg",wxBITMAP_TYPE_JPEG);

}

User avatar
doublemax
Moderator
Moderator
Posts: 15065
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax » Thu Nov 18, 2010 9:24 am

When a monitor is left or above the main screen, it has negative coordinates.

You can get a list of all monitors and their positions using:
http://docs.wxwidgets.org/stable/wx_wxd ... #wxdisplay

But i'm not sure if wxScreenDC supports negative coordinates.
Use the source, Luke!

woser
Earned a small fee
Earned a small fee
Posts: 18
Joined: Thu Nov 18, 2010 8:32 am

Post by woser » Thu Nov 18, 2010 1:24 pm

I was looking for information on the Internet, but to no avail, maybe someone has a simple proven way how to make a screenshot of multiple monitors.

User avatar
doublemax
Moderator
Moderator
Posts: 15065
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax » Thu Nov 18, 2010 2:43 pm

I did a little bit of research: Currently this is not possible with wxWidgets methods. wxScreenDC always creates a DC for the primary monitor and you can't get one for other monitors.
Use the source, Luke!

Post Reply