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

  • Home
  • SEARCH
  • 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 3485862
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:57:32+00:00 2026-05-18T10:57:32+00:00

I have a Winforms application that the user uses to take a region based

  • 0

I have a Winforms application that the user uses to take a region based screenshot. I want to have a small preview pane, but i’m not sure how to do it. So far i tried recreating a bitmap on mouse move and its just way too laggy to be usable. So i thought if i used a pre-defined image (screenshot of the whole screen) and moved it inside the picturebox based off the mouse location so that you get a zoomed in look at the screen (to select the precise pixels you want to take the screenshot with easier). I’m not sure how i can implement this, i am also pretty new to drawing so i will show you what i have now.

private void falseDesktop_MouseMove(object sender, MouseEventArgs e)
    {
        zoomBox.Image = showZoomBox(e.Location);
        zoomBox.Invalidate();
    }

private Image showZoomBox(Point curLocation)
        {
            int x = 0;
            int y = 0;
            if (curLocation.X - 12 <= 0)
            {
                x = curLocation.X - 12;
            }
            else
            {
                x = curLocation.X;
            }

            if (curLocation.Y - 11 <= 0)
            {
                y = curLocation.Y - 11;
            }
            else
            {
                y = curLocation.Y;
            }

            Point start = new Point(curLocation.X - 12, curLocation.Y - 11);
            Size size = new Size(24, 22);
            Rectangle rect = new Rectangle(start, size);
            Image selection = cropImage(falseDesktop.Image, rect);
            return selection;
        }

private static Image cropImage(Image img, Rectangle cropArea)
    {
        if (cropArea.Width != 0 && cropArea.Height != 0)
        {
            Bitmap bmpImage = new Bitmap(img);
            Bitmap bmpCrop = bmpImage.Clone(cropArea, bmpImage.PixelFormat);
            bmpImage.Dispose();
            return (Image)(bmpCrop);
        }
        return null;
    }

EDIT:

Here is a mock up like requested:

The black part of this image is a panel, of course the text being a label and the area where you see the image (stack overflow) would be the picturebox (called zoomBox) the lines on top of the zoomBox would be a guide and where the 2 lines intersect would be the mouse position. Hope this is a better assist to help you understand my issue.

alt text

Another thing that might help explain my issue is The form actually fills the entire screen with a “false desktop”. its a picturebox that covers the entire screen with a screenshot of the desktop when “printscreen” was pressed. So I want this little “preview pane” to basically be a zoomed in location of where the mouse is.

  • 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-05-18T10:57:33+00:00Added an answer on May 18, 2026 at 10:57 am

    This is a little bit laggy, but worth a try:

    It’s a WInForms app in a single file showing how a “live” zoom might work. It doesn’t paint the cross hairs etc. that’s up to you.

    Key Parts:

    • _scale
    • PictureBoxSizeMode.StretchImage

    using System;
    using System.Drawing;
    using System.Windows.Forms;
    using System.Drawing.Imaging;
    
    static class Program {
    [STAThread]
    static void Main() {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());
    }
    }
    
    public class Form1 : Form {
    private Bitmap _myImage = new Bitmap(@"C:\Users\Public\Pictures\Sample   Pictures\LightHouse.jpg");
    private int _scale = 10; // keep this < 15
    
    private PictureBox pboxMain;
    private PictureBox pboxZoom;
    private System.ComponentModel.IContainer components;
    
    public Form1() {
        InitializeComponent();
    }
    
    private void Form1_Load(object sender, EventArgs e) {
        pboxMain.Image = _myImage;
    }
    
    private void pboxMain_MouseMove(object sender, MouseEventArgs e) {
        try {
            Rectangle rc = new Rectangle(
                new Point(e.X - _scale, e.Y - _scale),
                new Size(_scale * 2, _scale * 2));
            pboxZoom.Image = _myImage.Clone(rc, PixelFormat.DontCare);
        }
        catch (OutOfMemoryException  ex) {/* ignore... */}
    }
    
    protected override void Dispose(bool disposing) {
        if (disposing && (components != null)) {
            components.Dispose();
        }
        base.Dispose(disposing);
    }
    
    private void InitializeComponent() {
        this.pboxMain = new PictureBox();
        this.pboxZoom = new PictureBox();
        ((System.ComponentModel.ISupportInitialize)(this.pboxMain)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.pboxZoom)).BeginInit();
        this.SuspendLayout();
    
        this.pboxMain.Dock = DockStyle.Fill;
        this.pboxMain.Location = new System.Drawing.Point(0, 0);
        this.pboxMain.Name = "pboxMain";
        this.pboxMain.Size = new System.Drawing.Size(767, 435);
        this.pboxMain.TabIndex = 0;
        this.pboxMain.TabStop = false;
        this.pboxMain.MouseMove += new MouseEventHandler(this.pboxMain_MouseMove);
    
        this.pboxZoom.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))),
      ((int)(((byte)(255)))), ((int)(((byte)(192)))));
        this.pboxZoom.BorderStyle = BorderStyle.FixedSingle;
        this.pboxZoom.Location = new System.Drawing.Point(12, 12);
        this.pboxZoom.Name = "pboxZoom";
        this.pboxZoom.Size = new System.Drawing.Size(106, 83);
        this.pboxZoom.SizeMode = PictureBoxSizeMode.StretchImage;
        this.pboxZoom.TabIndex = 1;
        this.pboxZoom.TabStop = false;
    
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(767, 435);
        this.Controls.Add(this.pboxZoom);
        this.Controls.Add(this.pboxMain);
        this.Name = "Form1";
        this.Text = "Form1";
        this.Load += new System.EventHandler(this.Form1_Load);
        ((System.ComponentModel.ISupportInitialize)(this.pboxMain)).EndInit();
        ((System.ComponentModel.ISupportInitialize)(this.pboxZoom)).EndInit();
        this.ResumeLayout(false);
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a WinForms application that uses SQL server to store its data. To
I have a desktop (winforms) application that uses a Firebird database as a data
I'm working on a WinForms application that uses System.Windows.Forms.PrintPreviewDialog to display a Print Preview
I'm trying to modify a C# WinForms application that uses multiple forms. At startup,
I have an ASP.NET web application I built for a client that uses default
I have a winform application that uses some referenced web services to get data.
I'm investigating an asp.net web application that extensively uses User Controls on each page.
I have a stand-alone WinForms application, let's call it Program A. Program A let's
I'm trying to invoke a dialog on the UI dispatcher : class DialogService :
Brief description of requirements (Lots of good answers here, thanks to all, I'll update

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.