•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 363,396 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,978 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser:
Views: 232 | Replies: 3
![]() |
•
•
Join Date: Mar 2006
Posts: 24
Reputation:
Rep Power: 3
Solved Threads: 0
Hi all,
Once I started learning C#, really much enjoying it. I faced some problem using GUI. I m trying to draw ellipse as many as possible with mouse moving events, but theres problem....
My code here:
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
myRect.Width = 0;
myRect.Height = 0;
myRect.X = e.X;
myRect.Y = e.Y;
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
Graphics g = this.CreateGraphics();
Pen p = new Pen(Color.Red, 2);
if (e.Button == MouseButtons.Left)
{
g.Clear(this.BackColor);
myRect.Width = e.X - myRect.X;
myRect.Height = e.Y - myRect.Y;
g.DrawEllipse(p, myRect);
}
}
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
Graphics g = this.CreateGraphics();
Pen p = new Pen(Color.Green,4);
g.DrawEllipse(p, myRect);
// g.Dispose();
}
If you run this code, it works fine. BUT I cant draw ellipse continually, then only last one remains and previous one is deleted. BUT if I remove
g.Clear(this.BackColor); this line from mouseMove event, then I can draw ellipse as many as possible. But process shows shadow of the drawing which I want to remove. If you run both ways you might understand what Im trying to do.......
Pls help, urgent pls
thanks in advance
bagi
Once I started learning C#, really much enjoying it. I faced some problem using GUI. I m trying to draw ellipse as many as possible with mouse moving events, but theres problem....
My code here:
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
myRect.Width = 0;
myRect.Height = 0;
myRect.X = e.X;
myRect.Y = e.Y;
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
Graphics g = this.CreateGraphics();
Pen p = new Pen(Color.Red, 2);
if (e.Button == MouseButtons.Left)
{
g.Clear(this.BackColor);
myRect.Width = e.X - myRect.X;
myRect.Height = e.Y - myRect.Y;
g.DrawEllipse(p, myRect);
}
}
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
Graphics g = this.CreateGraphics();
Pen p = new Pen(Color.Green,4);
g.DrawEllipse(p, myRect);
// g.Dispose();
}
If you run this code, it works fine. BUT I cant draw ellipse continually, then only last one remains and previous one is deleted. BUT if I remove
g.Clear(this.BackColor); this line from mouseMove event, then I can draw ellipse as many as possible. But process shows shadow of the drawing which I want to remove. If you run both ways you might understand what Im trying to do.......
Pls help, urgent pls
thanks in advance
bagi
•
•
•
•
Tool? You mean talking about C#? You dont need to work on console if you use C#. You can work with interface which makes everything easy for you. I use Visual Studio . NET 2008, the lastest version. hope this help
bagi
Hie again,
Yes, im also using Visual Studio .NET 2008.
What i want to know is.. What is "myRect" ??
Waiting for your reply!
PK
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb C# Marketplace
Other Threads in the C# Forum
- Previous Thread: Help with GUI. Updating between 2 forms.
- Next Thread: OLeDb Connection fail


Linear Mode