User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 391,606 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,612 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: 273 | Replies: 3
Reply
Join Date: Mar 2006
Posts: 24
Reputation: bagi is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
bagi bagi is offline Offline
Newbie Poster

GUI - very simple, but still couldnt solve, help pls

  #1  
May 13th, 2008
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Posts: 11
Reputation: puneetkay is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
puneetkay's Avatar
puneetkay puneetkay is offline Offline
Newbie Poster

Re: GUI - very simple, but still couldnt solve, help pls

  #2  
May 14th, 2008
Hie bagi,

Im also new in VC#(GUI) but still i have knowledge of C#(Console Applications).

Can you please tell me which tool are you using ? as im unable to find the tool for draw ellipse.

Waiting for your reply!
PK
Reply With Quote  
Join Date: Mar 2006
Posts: 24
Reputation: bagi is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
bagi bagi is offline Offline
Newbie Poster

Re: GUI - very simple, but still couldnt solve, help pls

  #3  
May 14th, 2008
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
Reply With Quote  
Join Date: Nov 2007
Posts: 11
Reputation: puneetkay is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
puneetkay's Avatar
puneetkay puneetkay is offline Offline
Newbie Poster

Re: GUI - very simple, but still couldnt solve, help pls

  #4  
May 14th, 2008
Originally Posted by bagi View Post
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
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C# Marketplace
Thread Tools Display Modes

Other Threads in the C# Forum

All times are GMT -4. The time now is 12:03 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC