Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9236769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:22:38+00:00 2026-06-18T07:22:38+00:00

I’m trying to develop a windows forms application that captures snapshots of scree, displays

  • 0

I’m trying to develop a windows forms application that captures snapshots of scree, displays them dynamically as they are captured and I would also like to provide the functionality to delete the captured images too. Right now, I’ve completed till capturing and displaying them as thumbnails. When a particular thumbnail is clicked, I would like to display an enlarged version of the image. I’m having trouble in linking the images captured and displaying the re-sized version.
Here is my code of what I’ve done so far.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging;
using HotKeys;

namespace Snapper
{
    public partial class SnapperForm : Form
    {
        static int imgCounter = 0;//keeps track of img for naming

        //create an instance of GlobalHotKey
        private GlobalHotKey ghk1; 
        private GlobalHotKey ghk2;

        public SnapperForm()
        {
            InitializeComponent();

            //pass the required key combination and form to the constructor
            ghk1 = new GlobalHotKey(Constants.CTRL + Constants.SHIFT, Keys.S, this);
            ghk2 = new GlobalHotKey(Constants.CTRL + Constants.SHIFT, Keys.W, this);
        }

        private Keys GetKey(IntPtr LParam)
        {
            return (Keys)((LParam.ToInt32()) >> 16);
        }
        //Perform the action required when HotKey is pressed
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == Constants.WM_HOTKEY_MSG_ID)
            {
                switch (GetKey(m.LParam))
                {
                    case Keys.S:
                        //take a snapshot of entire screen when CTRL + SHIFT + S is pressed
                        CaptureScreen();
                        break;
                    case Keys.W:
                        TestHotKeyCSW();
                        break;
                }                
            }
            base.WndProc(ref m);
        }


        private void TestHotKeyCSW()
        {
            MessageBox.Show("Hot key CTRL + SHIFT + W recived");
        }

        private void CaptureScreen()
        { 
            /*This method captures a snapshot of screen and 
             * adds it to the ImageFlowLayoutPanel
             */             

            Rectangle bounds = Screen.GetBounds(Point.Empty);
            Bitmap bmp = new Bitmap(bounds.Width,bounds.Height);
            Graphics g = Graphics.FromImage(bmp);
            g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size); 
            imgCounter += 1;
            bmp.Save("snap" + imgCounter.ToString() + ".jpg", ImageFormat.Jpeg);

            //working with ImageList
            CapturedImagesList.Images.Add(bmp);
            PictureBox tempPictureBox = new PictureBox();

            //generates a thumbnail image of specified size

            tempPictureBox.Image = bmp.GetThumbnailImage(100, 100,
                                   new Image.GetThumbnailImageAbort(ThumbnailCallback),
                                   IntPtr.Zero);
            tempPictureBox.Size = new System.Drawing.Size(100, 100);
            tempPictureBox.Click += new EventHandler(this.tempPictureBox_Click);
            ImageFlowLayoutPanel.Controls.Add(tempPictureBox);                       
        }        

        //This click event will be used to display the enlarged images
        private void tempPictureBox_Click(object sender, EventArgs e)
        {            
            PreviewPictureBox.Image = ((PictureBox)sender).Image;

        }
        public bool ThumbnailCallback()
        {
            return true;
        }
        private void Main_Load(object sender, EventArgs e)
        {
            if (!ghk1.Register() || !ghk2.Register())
            {
                MessageBox.Show("Failed to register", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void SnapperForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!ghk1.Unregister() || !ghk2.Unregister())
            {
                MessageBox.Show("Failed to UnRegister", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}

I thought to store captured images in an imagelist and sync between the dynamically generated thumbnails (picture boxes) and display the enlarged version of image clicked in the preview picture box. I’m able to display the image when it is clicked from the flowlayoutpanel to previewpicturebox, but only of the size of thumbnail again. I want the image to be enlarged. Can anyone guide me in achieving my requirement. If this design is not possible, can anyone guide me in using appropriate controls for this application?
Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T07:22:39+00:00Added an answer on June 18, 2026 at 7:22 am

    The way you do it your PreviewPictureBox will only show thumbnail images because of PreviewPictureBox.Image = ((PictureBox)sender).Image; in the tempPictureBox_Click method.

    The sender parameter is the tempPictureBox which you created in the CaptureScreen() method and its Image property is returning the thumbnail which you created by calling bmp.GetThumbnailImage(...).

    In order to show the large image you have to store the bmp object itself, not just the thumbnail version. One way to do this is to store it in the tempPictureBox.Tag property. These Tag properties can be found in most Windows Forms controls and are used to store arbitrary data associated with that control.

    So, to summarize it:

    add tempPictureBox.Tag = bmp; in the CaptureScreen() method,

    change PreviewPictureBox.Image = ((PictureBox)sender).Image; to PreviewPictureBox.Image = (Bitmap)((PictureBox)sender).Tag;.

    It might still be necessary to adjust the size of the PreviewPictureBox, but at least it won’t show the thumbnail picture that way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.