A step by step tutorial teaching you how to create your own chat client and chat server easily in C#, for local networks or the Internet.
A C# tutorial showing you how to make use of WMI to extract information on disk drives, such as model, capacity, sectors and serial number.
This tutorial will teach you how to calculate the shipping cost based on the weight, height, length and depth of the box, the distance and the UPS service type.
Creating a Rich Text Editor using JavaScript is easier to do than you might think, thanks to the support of modern browsers; this tutorial will walk you through it.
Mouse coordinatesGetting the coordinates of the mouse with OnMouseMove and making something interesting with them. |
On Friday, June 4th 2004 at 10:25 AM By Andrew Pociu (View Profile) ![]() ![]() ![]() ![]() (Rated 3.9 with 25 votes) |
||
|
The position of the mouse cursor on the screen is determined by the X and Y coordinates.
|
|||
Digg It!
Del.icio.us
Reddit
StumbleIt
Newsvine
Furl
BlinkList
|
|||
|
|||
Current Commentsok
but this will work only in case of normal mouse cursor. what if i want the blue line to be drawn even if my mouse cursor is something else e.g a cross.
then it will not work
how do you get mouse cursor coordinates when mouse not on form ?
how do you get mouse cursor coordinates when mouse not on form ?
how do you get mouse cursor coordinates when mouse not on form ?
This is a nice article, but it doesn't mention what to do when the form's background is not white, but is a picture or a gradient. It gets much more difficult in that condition.
hi..im lookin for a script that can capture my mouse Coordinates if i hover my mouse to an IMAGE ONLY within my page. Tnx!!!
I made a new tutorial that shows you how to get the mouse cursor coordinates on the screen, and not just on the form. It uses the Windows API:
<a href="http://www.geekpedia.com/tutorial146_Get-screen-cursor-coordinates.html" target="_blank">http://www.geekpedia.com/tutorial146_Get-screen-cursor-coordinates.html</a>.
da
This is heavily flawed, just assuming the background is white is bad. You need to figure out how to redraw a portion of the screen (not the whole screen) of where the line used to be.
Just wanted to thank you
I have been looking for a script that reads the form cords and not the windows cords
thank you
i m new to c#..so i don't get what u have written...so plz explain it more from begining..
thanx.
thnx
I have a form and i have a groupbox on the form.I need to calculate the mouse cordinates when the mouse is inside the groupbox.How to do this.Please help.Thanks
how do you get mouse cursor coordinates when mouse not on form ?
haha nice .. but now the erased Lines will act as a Eraser to previously drawn Shapes .. this is not a flawless code ... i have made an error free code for line drawing feature of PaintBrush ... see this
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.IO;
using System.Drawing.Imaging;
namespace tryMapping2
{
public partial class Form1 : Form
{
public Pen p = new Pen(Color.Black);
public bool drawLine = false;
Point startPoint;
bool isDrawing = false;
Point endPoint;
int eraseX;
int eraseY;
Graphics gr;
List<Point> lStartPoints;
List<Point> lEndPoints;
public Form1()
{
InitializeComponent();
this.MouseMove = new MouseEventHandler(Form1_MouseMove);
this.MouseDown =new MouseEventHandler(Form1_MouseDown);
this.Paint = new PaintEventHandler(Form1_Paint);
timer1.Tick = new EventHandler(timer1_Tick);
panel.MouseEnter = new EventHandler(panel_MouseEnter);
button1.MouseEnter = new EventHandler(button1_MouseEnter);
button2.MouseEnter = new EventHandler(button2_MouseEnter);
this.MouseEnter = new EventHandler(Form1_MouseEnter);
}
void Form1_MouseEnter(object sender, EventArgs e)
{
if (drawLine)
{
Cursor = Cursors.Cross;
}
}
void button2_MouseEnter(object sender, EventArgs e)
{
this.Cursor = Cursors.Arrow;
}
void button1_MouseEnter(object sender, EventArgs e)
{
this.Cursor = Cursors.Arrow;
}
void panel_MouseEnter(object sender, EventArgs e)
{
this.Cursor = Cursors.Arrow;
}
void timer1_Tick(object sender, EventArgs e)
{
RefreshLines(gr);
}
public class Line
{
public void drawLine(Pen p, Graphics g, Point start, Point end)
{
Form1 form1 = new Form1();
g.DrawLine(form1.p, start, end);
}
}
void Form1_Paint(object sender, PaintEventArgs e)
{
RefreshLines(gr);
}
private void Form1_Load(object sender, EventArgs e)
{
lStartPoints = new List<Point>();
lEndPoints = new List<Point>();
gr = CreateGraphics();
timer1.Interval = 1;
}
void Form1_MouseDown(object sender, MouseEventArgs e)
{
if (drawLine)
{
isDrawing = true;
startPoint = new Point(e.X,e.Y);
lStartPoints.Add(startPoint);
eraseX = startPoint.X;
eraseY = startPoint.Y;
this.MouseUp = new MouseEventHandler(Form1_MouseUp);
timer1.Start();
}
}
void Form1_MouseUp(object sender, MouseEventArgs e)
{
this.MouseUp -= Form1_MouseUp;
isDrawing = false;
lEndPoints.Add(endPoint);
timer1.Stop();
RefreshLines(gr);
}
void Form1_MouseMove(object sender, MouseEventArgs e)
{
label1.Text = e.X " , " e.Y;
if (drawLine
great
bakwas
Nice coding..!
Great ideas, got to say I've based most of my code off of this thread. I have a rather complex program that uses many lines that must be redrawn many times a second. Unfortunately it seems to make the screen blink as the lines are erased and redrawn in their new locations. I feel like this method is somehow inefficient, is there a faster way for the computer to erase all the draw lines at once instead of having to recompute each line and erase separately? My idea was to have the panel repainted before drawing the new set of lines. How can this be done?
Any help is appreciated.
cheers
Smooth I definitely liked naming it. This info provided by you is rale manufacture for prudish cerebration.
<a href="http://bloodpressurey.com">blood pressure control</a>
Smooth I definitely liked naming it. This info provided by you is rale manufacture for prudish cerebration.
<a href="http://bloodpressurey.com">blood pressure control</a>
You got a rale primal diary I piss been here mensuration for nearly an stop. I am a newbie and your success is rattling superabundance an breather for me
Great ideas, got to say I've based most of my code off of this thread. I have a rather complex program that uses many lines that must be redrawn many times a second. Unfortunately it seems to make the screen blink as the lines are erased and redrawn in their new locations. I feel like this method is somehow inefficient, is there a faster way for the computer to erase all the draw lines at once instead of having to recompute each line and erase separately? My idea was to have the panel repainted before drawing the new set of lines. How can this be done?
What a wonderful leather of assemblage Admiring the denotive and reflection you put into your writing and elaborated gist you thing ! I treat symbol your diary and signal my children cloth up here oft. Thumbs up
Pretty unliterary sum. I pianoforte stumbled upon your ledger and hot to say that I possess study enjoyed entity your aggregation posts. Any way I'll be subscribing to your cater and I draftsmanship you publicise again presently
I conceptualize this is a distinct put. Thanks for attractive the trim to score specific an exemplifying article. It has assumption me a lot of inspiration.
<a href="http://www.quotessea.com/category/brother-quotes/">brother quotes</a>
I do cerebrate the grouping are where lots of the fun was in. I respond to hit a indorsement await into my web log so you can thrown the entropy
<a href="http://www.quotessea.com/category/brother-quotes/">brother quotes</a>
The reestablish is sing in ail a someone doings and it entails whatsoever utilizable assembling for me. I am paradisal to tap your soaring way of descriptor the habitation. Now you add it unproblematic for me to restate and get the aim. Leaving you for the touring.
<a href="http://www.offshoreletter.com/how-to-form-an-offshore-company/">the offshore company </a>
Thanks for the unmatchable diary.it was rale useful for me.navigator sharing specified ideas in the instant as symptomless.this was actually what i was labour for,and i am voluntary to came here!
<a href=''http://www.offshoreletter.com/do-you-need-an-offshore-services-company/">offshore services</a>
My problem with this is i am using a child form so i can have many windows and the positions y value is not right. it is actually below the cursor at different lengths depending on the size of the window? any suggestions?
thank u for providing me information on List View.
I want to know how i can display data in datalist in Newsletter layout and Thank you so much, this is easy to understand and fun to continue along with. I am a migrating VB.NET/C# Developer looking for an insight into VC .NET. I've found the VC tutorials on many sites to be confusing, and the navigation around the sites to be near impossible to use! Thanks once again.
Adore the new appear. I enjoyed this great article. Thanks for the great writing.
Once you have recreated the problem and captured these steps, you can save them to a file and send it to your support person, who can then open it up and view
Ce site internet est sérieusement bonne, souhaitent déterminer beaucoup plus si merveilleux écriture jusqu'à
Related Tutorials
Related Source Code
C# Job Search