| | |
circles erased ??
Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Thread Solved
![]() |
Hello, first you need to know that this is my first Win Application made in C#!!
I`m trying to draw some circles based on mouse left click coordinates but the circles disappear when I minimize the window, Solutions found on the internet didn`t helped me too much
. Here is my code:
u
I`m trying to draw some circles based on mouse left click coordinates but the circles disappear when I minimize the window, Solutions found on the internet didn`t helped me too much
. Here is my code:u
C# Syntax (Toggle Plain Text)
sing System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace GraphCApplication1 { /// <summary> /// Summary description for Form1. /// </summary> public class Form1 : System.Windows.Forms.Form { int i=0, x, y; String s = ""; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } protected override void OnPaint(PaintEventArgs e) { base.OnPaint (e); } #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> /// public void mouseDownForm(object sender, System.Windows.Forms.MouseEventArgs e) { Font f; SolidBrush br; Pen pn; Rectangle rct; switch(e.Button) { case MouseButtons.Left: x = e.X; y = e.Y; i++; s = i.ToString(); //Graphics g = Graphics.FromHwnd(this.Handle); Graphics g = CreateGraphics(); //Draw(g); //g.FillRectangle(new SolidBrush(this.BackColor), this.ClientRectangle); f = new Font("Arial", 14); br = new SolidBrush(Color.Red); pn = new Pen(Color.GreenYellow); rct = new Rectangle(e.X, e.Y, 50, 50); g.DrawEllipse(pn, rct); g.DrawString(s, f, br, rct); //MessageBox.Show(this, "click stanga"); break; case MouseButtons.Right: /*if (RightClick != null) { RightClick(sender, e); }*/ MessageBox.Show(this, "click dreapta"); break; } } /*public void Draw(Graphics g) { Rectangle r = new Rectangle(x, y, 20, 20); g.DrawEllipse(new Pen(Color.Coral), r); g.DrawString(s, new Font("Arial", 10), new SolidBrush(Color.Coral), r); }*/ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.Size = new System.Drawing.Size(300,300); this.Text = "Form1"; this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.mouseDownForm); } #endregion /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.Run(new Form1()); } } }
•
•
Join Date: Nov 2007
Posts: 30
Reputation:
Solved Threads: 6
What I would do is create a data structure to keep track of the places you have clicked and any corresponding info you need, then when the form is minimized/maximized/given focus/whatever else, redraw all the circles.
What i think is happening, is the form 'forgets' whats been drawn when you minimize it, not sure about this as I'm no expert, but storing what you need and re-drawing when required should fix it.
What i think is happening, is the form 'forgets' whats been drawn when you minimize it, not sure about this as I'm no expert, but storing what you need and re-drawing when required should fix it.
Actually, I think you need to put the code
in the minimized event handler or similar.
C# Syntax (Toggle Plain Text)
this.Invalidate()
•
•
Join Date: Nov 2007
Posts: 30
Reputation:
Solved Threads: 6
•
•
•
•
Actually, I think you need to put the code
in the minimized event handler or similar.C# Syntax (Toggle Plain Text)
this.Invalidate()

My solution would work, its just needlessly complicated.
![]() |
Similar Threads
- Installing RedHat 9.0 on Vmware 4.0 via XP (Windows Software)
- Any recommendations on good Flash books? (Graphics and Multimedia)
- Can't burn an erased disk (Windows Software)
- Document Root paths and circles (Search Engine Optimization)
- Circles .... Locus... (C++)
- Two red circles with X (Viruses, Spyware and other Nasties)
- Administrator accounts erased, can I create one w/out access to system preferences? (OS X)
Other Threads in the C# Forum
- Previous Thread: c# login trouble
- Next Thread: Books
| Thread Tools | Search this Thread |
.net access algorithm array asp.net bitmap box broadcast c# check checkbox client combobox control conversion csharp database datagrid datagridview dataset datetime dbconnection decryption degrees design developer draganddrop drawing encryption enum eventhandlers excel file firefox focus form format forms function gdi+ grantorrevokepermissionthroughc#.net hospitalmanagementsystem image input install interface java libraries list loop marshalbyrefobject math mouseclick movingimage mysql netcfsvcutil.exe numeric operator path photoshop php picturebox pixelinversion platform polynomial post programming properties radians read regex remote remoting richtextbox server sleep socket sql statistics string stringformatting study system.servicemodel table tcpclientchannel text textbox thread time timer update usb usercontrol validation visualstudio webbrowser winforms wpf wpfc# xml






