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 4093978
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:41:11+00:00 2026-05-20T19:41:11+00:00

I have a picture box which I draw some stuff on it using a

  • 0

I have a picture box which I draw some stuff on it using a bitmap (loading the bitmap as picturebox image after each change of drawing). Now I have a “Add a note” button. this button is somewhere in the mainForm. I want it so when user clicks on this button, the mouse pointer to jump into picturebox control and does not move out of it unless the user has clicked inside the control or pressed Escape key. Is this possible?

I am using this code at the moment:

    private void buttonAddNote_Click(object sender, EventArgs e)
    {
        Cursor = Cursors.Cross;
    }

Or a better approach could be on this time when user clicked add a note button, mouse clicks only work within picturebox component (IE user can not click somewhere else in program)

  • 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-20T19:41:11+00:00Added an answer on May 20, 2026 at 7:41 pm

    Modality like that in a user interface is a pretty bad idea. But Winforms does make it possible. You can use the Cursor.Clip property to restrict motion. It can’t prevent the user from still accessing, say, the Start menu with a keyboard shortcut, you need to use Capture property to detect that you lost.

    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
            pictureBox1.MouseCaptureChanged += new EventHandler(pictureBox1_MouseCaptureChanged);
            pictureBox1.MouseDown += new MouseEventHandler(pictureBox1_MouseDown);
            button1.Click += new EventHandler(button1_Click);
        }
    
        private void button1_Click(object sender, EventArgs e) {
            var rc = pictureBox1.RectangleToScreen(new Rectangle(Point.Empty, pictureBox1.ClientSize));
            Cursor.Position = new Point(rc.Left + rc.Width / 2, rc.Top + rc.Height / 2);
            Cursor.Clip = rc;
            pictureBox1.Capture = true;
            pictureBox1.Cursor = Cursors.Cross;
        }
    
        void pictureBox1_MouseDown(object sender, MouseEventArgs e) {
            pictureBox1.Capture = false;
        }
    
        void pictureBox1_MouseCaptureChanged(object sender, EventArgs e) {
            if (!pictureBox1.Capture) {
                pictureBox1.Cursor = Cursors.Default;
                Cursor.Clip = new Rectangle(0, 0, 0, 0);
            }
        }
    
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
            if (keyData == Keys.Escape) pictureBox1.Capture = false;
            return base.ProcessCmdKey(ref msg, keyData);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the picture box in which the image may be zoomed with different
I have a PictureBox (WinMobile 6 WinForm) on which I draw some images. There
I have a control (picturebox), in which I want to draw an 2D image
I have a picture box which reads in an image from a folder to
Hi I am using visual studio 8, vb.net. I have a picture box on
I have a transparent rectangle on a picture box,if i click next,the next image
I have a picture box in my application which displays pictures. Now if user
HI all, I have a picture box in my C# WinForms application which is
In vb.net i have one panel in which multiple picture box controls are added.
I want to scale captured image and show it in the picture box which

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.