#include "wx/wx.h"
class Application : public wxApp
{
public :
Application () {}
};
wxImage FaireuneCapturedecran()
{
wxScreenDC dcEcran; // Déclaration d'une variable de type wxScreenDc
int height = GetSystemMetrics(SM_CYSCREEN); // On récupère la résolution de l'écran
int width = GetSystemMetrics(SM_CXSCREEN);
wxBitmap Capture(width, height); // On initialise un object wxBitmap vide
wxMemoryDC memDC; // Déclaration d'une variable de type wxMemoryDC
memDC.SelectObject(Capture); // On selectionne une variable wxBitmap pour stocker notre capture
memDC.Blit( 0, 0, width, height, &dcEcran, 0, 0); // On capture l'écran
memDC.SelectObject(wxNullBitmap); // On désélèctionne la variable
return Capture.ConvertToImage(); // Conversion du wxBitmap en wxImage
}
int main(int argc, char ** argv)
{
Application * app = new Application();
wxApp::SetInstance(app);
wxEntryStart(argc, argv);
wxImage cp = FaireuneCapturedecran();
cp.SaveFile("Capture.bmp");
app->OnRun();
app->OnExit();
wxEntryCleanup();
return 0;
}