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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:49:54+00:00 2026-06-03T03:49:54+00:00

Im actually trying to paint an elipse around my cursor when i moove it,

  • 0

Im actually trying to paint an elipse around my cursor when i moove it, I dont want it to leave a trail like it does actually.

Can someone help with this, I believe it has something to do with the invalidaterec option

Any example son using invalidate rec?

Here is my code, besides the trail it has to work the same way it does now.

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.Runtime.InteropServices;



namespace MouseTest
{
    public partial class Form1 : Form
    {
        [DllImport("user32.dll", EntryPoint = "GetDC")]
        private static extern IntPtr GetDC(IntPtr hWnd);

        [DllImport("user32.dll", EntryPoint = "ReleaseDC")]
        private static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);

        [System.Runtime.InteropServices.DllImport("Shell32.dll")]
        private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1,         IntPtr item2);

        System.Timers.Timer t1 = new System.Timers.Timer(100);


        public Form1()
        {
        t1.Elapsed += new System.Timers.ElapsedEventHandler(t1_Elapsed);
        t1.Start();
        // System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
        //Mouse.OverrideCursor = System.Windows.Input.Cursors.Hand;
        InitializeComponent();


    }

    void t1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
    {
        t1.Stop();

        //SolidBrush b = new SolidBrush(Color.Red);
        IntPtr desktopDC = GetDC(IntPtr.Zero);
        Graphics g = Graphics.FromHdc(desktopDC);
        g.FillEllipse(new SolidBrush(Color.BlueViolet), Cursor.Position.X, Cursor.Position.Y, 25, 25);
        g.Dispose();
        ReleaseDC(IntPtr.Zero, desktopDC);

       t1.Start();


    }



}

}

  • 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-03T03:49:55+00:00Added an answer on June 3, 2026 at 3:49 am

    Yes, keeping the previous coordinate and calling InvalidateRect on the previous enclosing rectangle before drawing the new new ellipse would probably work. I don’t have any code lying around that calls InvalidateRect, but if this is exactly your goal:” to paint an elipse around my cursor when i moove it, I dont want it to leave a trail like it does actually.” there are other, more straight forward ways.

    One way is to draw the ellipse on a transparent form and then move that form around based on the cursor’s movement:

    Here, first is the form definition:

    namespace MouseForm
    {
        partial class Form1
        {
            /// <summary>
            /// Required designer variable.
            /// </summary>
            private System.ComponentModel.IContainer components = null;
    
            /// <summary>
            /// Clean up any resources being used.
            /// </summary>
            /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
            protected override void Dispose(bool disposing)
            {
                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }
    
            #region Windows Form Designer generated code
    
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
                this.components = new System.ComponentModel.Container();
                this.shapeContainer1 = new Microsoft.VisualBasic.PowerPacks.ShapeContainer();
                this.ovalShape1 = new Microsoft.VisualBasic.PowerPacks.OvalShape();
                this.timer1 = new System.Windows.Forms.Timer(this.components);
                this.SuspendLayout();
                // 
                // shapeContainer1
                // 
                this.shapeContainer1.Location = new System.Drawing.Point(0, 0);
                this.shapeContainer1.Margin = new System.Windows.Forms.Padding(0);
                this.shapeContainer1.Name = "shapeContainer1";
                this.shapeContainer1.Shapes.AddRange(new Microsoft.VisualBasic.PowerPacks.Shape[] {
                this.ovalShape1});
                this.shapeContainer1.Size = new System.Drawing.Size(74, 74);
                this.shapeContainer1.TabIndex = 0;
                this.shapeContainer1.TabStop = false;
                // 
                // ovalShape1
                // 
                this.ovalShape1.BorderColor = System.Drawing.Color.Red;
                this.ovalShape1.BorderWidth = 3;
                this.ovalShape1.FillColor = System.Drawing.SystemColors.Control;
                this.ovalShape1.FillStyle = Microsoft.VisualBasic.PowerPacks.FillStyle.Solid;
                this.ovalShape1.Location = new System.Drawing.Point(2, 2);
                this.ovalShape1.Name = "ovalShape1";
                this.ovalShape1.Size = new System.Drawing.Size(70, 70);
                // 
                // timer1
                // 
                this.timer1.Enabled = true;
                this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
                // 
                // Form1
                // 
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(74, 74);
                this.ControlBox = false;
                this.Controls.Add(this.shapeContainer1);
                this.Enabled = false;
                this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
                this.Name = "Form1";
                this.ShowIcon = false;
                this.ShowInTaskbar = false;
                this.Text = "Form1";
                this.TopMost = true;
                this.TransparencyKey = System.Drawing.SystemColors.Control;
                this.ResumeLayout(false);
    
            }
    
            #endregion
    
            private Microsoft.VisualBasic.PowerPacks.ShapeContainer shapeContainer1;
            private Microsoft.VisualBasic.PowerPacks.OvalShape ovalShape1;
            private System.Windows.Forms.Timer timer1;
        }
    }
    

    And here is the code:

    using System;
    using System.Windows.Forms;
    
    namespace MouseForm
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void timer1_Tick(object sender, EventArgs e)
            {
                this.Left = Cursor.Position.X - this.Width / 2;
                this.Top = Cursor.Position.Y - this.Height / 2;
            }
        }
    }
    

    I’ll leave it as an exercise to the reader to implement a way to close the transparent form 🙂

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

Sidebar

Related Questions

I'm trying to understand how I can paint simple graphics in x86 protected mode
I'm trying to drawText on a Canvas using Paint and I can't seem to
I am trying to create something like (very poorly created in paint) in the
What I'm actually trying to do is put a WebKitView into a ScreenSaver (which
I am actually trying to change the color index for the first word with
I'm actually trying to fix this issue where my projects are always out of
is there similar syntax to php's $$variable in python? what I am actually trying
I am new to android..Actually iam trying to increase the RAM Memory of android
Actually I'm trying to implement an ontouchlistener into my android (1.5) application. therefore i
actually I thought I was trying something really simple. ControllerClassNameHandlerMapping sounded great to produce

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.