I built simple application to take full screenshot each 100ms of computer's screen and set the screenshots on the PictureBox :
- private void StartWork()
- {
- try
- {
- // width :1916 and height :1074 is the best measure to take full screenshot of whole laptotp's screen
- using (Image bitmap = new Bitmap(1916, 1074))
- {
- using (Graphics g = Graphics.FromImage(bitmap))
- {
- g.CopyFromScreen(Point.Empty, Point.Empty, new Size(1916, 1074));
- }
- pictureBox1.BackgroundImage = (Image)bitmap.Clone();
- pictureBox1.BackgroundImageLayout = ImageLayout.Stretch;
- //Sending Function to Send every token screenshot to all connected TcpClients
- // Sending(bitmap);
- pictureBox1.Invalidate();
- pictureBox1.Refresh();
- }
- }
- catch (Exception ee)
- {
- // MessageBox.Show(ee.Message);
- }
- }
calling StartWork() in every 100ms in Tick event :
- private void timer1_Tick(object sender, EventArgs e)
- {
- StartWork();
- }
Data = {System.Collections.ListDictionaryInternal}
HResult = -2147024809
Message = "Parameter is not valid."
Source = "System.Drawing"
StackTrace = " at System.Drawing.Graphics.GetHdc()\r\n at System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)\r\n at System.Drawing.Graphics.CopyF...
TargetSite = {IntPtr GetHdc()}
I was searched in simillar problems in CSharp Corner and Stackoverflow and try to change a lot of things but really i becommed tired.
please developers how solve this problem .
Thanks in Advance .


Sachin SinghRank #66 · 26.2K reputationPosted Oct 14, 2020, 11:33 PM EDT
Junaid MuslaRank #8,429 · 222 reputationPosted Oct 14, 2020, 11:30 PM EDT
Abdulmajeed AlshariRank #7,641 · 237 reputationPosted Oct 15, 2020, 1:51 AM EDT
Abdulmajeed AlshariRank #7,641 · 237 reputationPosted Oct 15, 2020, 2:20 PM EDT