I'm using visual studio 2010 and i'm writing a code to capture a screen on a button click. i've written the code as
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
try
{
SaveFileDialog^ save = gcnew SaveFileDialog();
save->Title = "Save Screenshot";
save->Filter = "JPEG | *.jpg | Bitmap | *.bmp | Portable Network Graphics|*.png|Graphical Interchange File Format|*.gif";
save->ShowDialog();
pictureBox1->Image->Save(save->FileName);
}
catch(Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void Form1_KeyDown(System::Object^ sender, System::Windows::Forms::KeyEventArgs^ e) {
if(e->KeyCode == System::Windows::Forms::Keys::Enter)
{
Rectangle^ bounds;
System::Drawing::Bitmap^ screenshot;
Graphics^ graph;
bounds = Screen::PrimaryScreen->Bounds;
screenshot = gcnew System::Drawing::Bitmap(bounds->Width,bounds->Height, System::Drawing::Imaging::PixelFormat::Format32bppArgb);
graph = Graphics::FromImage(screenshot);
graph = CopyFromScreen (bounds->X, bounds->Y, 0, 0, bounds-> Size, CopyPixelOperation::SourceCopy);
pictureBox1->Image = screenshot;
}
}
But with this i'm getting an error as CopyFromScreen:Identifier not found. i tried to search abt this and everywhere it shows syntax is correct.