Hi guys, my aim is to capture the screen of a windows form using c++/cli. Below is the code to capture the window, however, it is in C#. What changes do I have to make to the code for it to work in c++?
Graphics myGraphics = this.CreateGraphics();
Size s = this.Size;
memoryImage = new Bitmap(s.Width, s.Height, myGraphics);
Graphics memoryGraphics = Graphics.FromImage(memoryImage);
memoryGraphics.CopyFromScreen(this.Location.X, this.Location.Y, 0, 0, s);
What I have tried:
I've tried using the code below in c++, however, I get errors for the parts in bold.
For the first bold part, I get an error that says
expected a ; after Size, for the graphics error, it says
type name is not allowed .
Graphics^ myGraphics = this->CreateGraphics();
Size s = this->Size;
memoryImage = gcnew Bitmap(s->Width, s->Height, myGraphics);
Graphics^ memoryGraphics = Graphics->FromImage(memoryImage);
memoryGraphics->CopyFromScreen(this->Location.X, this->Location.Y, 0, 0, s);