Witam
Czy zrobiłem w tym kodzie jakiś błąd? Po wywołaniu funkcji program się zatrzymuje.
void screen(HWND Handle, const char *SaveTo)
{
RECT r;
GetWindowRect(Handle,&r);\
TCanvas &WindowCanvas = *new TCanvas();
Graphics::TBitmap *Bmp = new Graphics::TBitmap;
TJPEGImage *Jpg = new TJPEGImage();
WindowCanvas.Handle = GetDC(Handle);
Bmp->Width =r.right-r.left;
Bmp->Height =r.bottom-r.top;
Bmp->Canvas->CopyRect(Rect(0, 0, Bmp->Width, Bmp->Height), &WindowCanvas,
Rect(0, 0, Bmp->Width, Bmp->Height));
Jpg->Assign(Bmp);
Jpg->SaveToFile(SaveTo);
}