# MouseCoordinates show coordinates only outside MapControl

**URL:** <https://community.thinkgeo.com/t/mousecoordinates-show-coordinates-only-outside-mapcontrol/1385>\
**Category:** WinForms\
**Created:** [August 10, 2010, 7:46am UTC](https://community.thinkgeo.com/t/mousecoordinates-show-coordinates-only-outside-mapcontrol/1385 "2010-08-10T07:46:17Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wilmer](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/w/ee7513/32.png) [@Wilmer](https://community.thinkgeo.com/u/Wilmer)\
**Post date:** [August 10, 2010, 7:46am UTC](https://community.thinkgeo.com/t/mousecoordinates-show-coordinates-only-outside-mapcontrol/1385/1 "2010-08-10T07:46:17Z")

</div>

Hi&nbsp;everybody.

I&nbsp;put&nbsp;the&nbsp;piece&nbsp;of&nbsp;code&nbsp;that&nbsp;shows&nbsp;the&nbsp;mouse&nbsp;pointer&nbsp;coordinates&nbsp;(screen&nbsp;coordinates&nbsp;and&nbsp;world&nbsp;coordinates),&nbsp;and&nbsp;it&nbsp;only&nbsp;updates&nbsp;label's&nbsp;text&nbsp;when&nbsp;the&nbsp;pointer&nbsp;its&nbsp;outside&nbsp;the&nbsp;MapControl&nbsp;but&nbsp;still&nbsp;inside&nbsp;the&nbsp;form&nbsp;here's&nbsp;the&nbsp;code&nbsp;i've&nbsp;used:

&nbsp;

private&nbsp;void&nbsp;winformsMap1\_MouseMove(object&nbsp;sender,&nbsp;MouseEventArgs&nbsp;e)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//Displays&nbsp;the&nbsp;X&nbsp;and&nbsp;Y&nbsp;in&nbsp;screen&nbsp;coordinates.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;statusStrip1.Items["toolStripStatusLabelScreen"].Text&nbsp;=&nbsp;"X:"&nbsp;+&nbsp;e.X&nbsp;+&nbsp;"&nbsp;Y:"&nbsp;+&nbsp;e.Y;  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//Gets&nbsp;the&nbsp;PointShape&nbsp;in&nbsp;world&nbsp;coordinates&nbsp;from&nbsp;screen&nbsp;coordinates.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PointShape&nbsp;pointShape&nbsp;=&nbsp;ExtentHelper.ToWorldCoordinate(winformsMap1.CurrentExtent,&nbsp;new&nbsp;ScreenPointF(e.X,&nbsp;e.Y),&nbsp;winformsMap1.Width,&nbsp;winformsMap1.Height);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//Displays&nbsp;world&nbsp;coordinates.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;statusStrip1.Items["toolStripStatusLabelWorld"].Text&nbsp;=&nbsp;"(world)&nbsp;X:"&nbsp;+&nbsp;Math.Round(pointShape.X,&nbsp;4)&nbsp;+&nbsp;"&nbsp;Y:"&nbsp;+&nbsp;Math.Round(pointShape.Y,&nbsp;4);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}

Any&nbsp;idea&nbsp;?&nbsp;i'm&nbsp;missing&nbsp;something?,&nbsp;thanks.

---

<div class="post-metadata">

**Author:** ![David4](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/d/8e7dd6/32.png) [@David4](https://community.thinkgeo.com/u/David4)\
**Post date:** [August 10, 2010, 9:04am UTC](https://community.thinkgeo.com/t/mousecoordinates-show-coordinates-only-outside-mapcontrol/1385/2 "2010-08-10T09:04:12Z")

</div>

&nbsp;

---

<div class="post-metadata">

**Author:** ![Val](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/v/e56c9b/32.png) [@Val](https://community.thinkgeo.com/u/Val)\
**Post date:** [August 10, 2010, 12:06pm UTC](https://community.thinkgeo.com/t/mousecoordinates-show-coordinates-only-outside-mapcontrol/1385/3 "2010-08-10T12:06:43Z")

</div>

Displaying&nbsp;world&nbsp;and&nbsp;screen&nbsp;coordinates&nbsp;at&nbsp;mouse&nbsp;move&nbsp;is&nbsp;a&nbsp;very&nbsp;standard&nbsp;operation&nbsp;and&nbsp;we&nbsp;do&nbsp;that&nbsp;in&nbsp;all&nbsp;our&nbsp;Code&nbsp;Community&nbsp;projects&nbsp;for&nbsp;example.&nbsp;Actually,&nbsp;you&nbsp;can&nbsp;look&nbsp;at&nbsp;the&nbsp;latest&nbsp;Desktop&nbsp;project&nbsp;_Ruler&nbsp;Overlay&nbsp;_and&nbsp;you&nbsp;will&nbsp;see&nbsp;how&nbsp;to&nbsp;do&nbsp;that&nbsp;in&nbsp;the&nbsp;MapMouseMove&nbsp;event.&nbsp;[code.thinkgeo.com/projects/show/ruleroverlay](http://code.thinkgeo.com/projects/show/ruleroverlay)

Also,&nbsp;on&nbsp;the&nbsp;theme&nbsp;of&nbsp;displaying&nbsp;coordinates,&nbsp;we&nbsp;have&nbsp;also&nbsp;the&nbsp;project&nbsp;_Decimal&nbsp;Degrees&nbsp;Formatting&nbsp;_if&nbsp;you&nbsp;are&nbsp;interested.&nbsp;[code.thinkgeo.com/projects/show/decimaldegrees](http://code.thinkgeo.com/projects/show/decimaldegrees)

---

<div class="post-metadata">

**Author:** ![Wilmer](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/w/ee7513/32.png) [@Wilmer](https://community.thinkgeo.com/u/Wilmer)\
**Post date:** [August 10, 2010, 2:41pm UTC](https://community.thinkgeo.com/t/mousecoordinates-show-coordinates-only-outside-mapcontrol/1385/4 "2010-08-10T14:41:49Z")

</div>

Thanks&nbsp;David&nbsp;and&nbsp;Val.&nbsp;  
&nbsp;&nbsp;  
&nbsp;David&nbsp;I&nbsp;can’t&nbsp;read&nbsp;yout&nbsp;post&nbsp;here&nbsp;in&nbsp;the&nbsp;forum,&nbsp;but&nbsp;by&nbsp;email&nbsp;i&nbsp;saw&nbsp;your&nbsp;VB&nbsp;code&nbsp;and&nbsp;it’s&nbsp;essentially&nbsp;the&nbsp;same&nbsp;instructions&nbsp;but&nbsp;in&nbsp;other&nbsp;language(VB).&nbsp;  
&nbsp;&nbsp;  
&nbsp;Val&nbsp;the&nbsp;“ruler&nbsp;overlay”&nbsp;code&nbsp;for&nbsp;mouseMove&nbsp;it’s&nbsp;exactly&nbsp;the&nbsp;same&nbsp;used&nbsp;in&nbsp;other&nbsp;community&nbsp;projects&nbsp;as&nbsp;you&nbsp;say,&nbsp;and&nbsp;it’s&nbsp;the&nbsp;same&nbsp;that&nbsp;i&nbsp;use&nbsp;in&nbsp;my&nbsp;app,&nbsp;i&nbsp;don’t&nbsp;know&nbsp;why&nbsp;it&nbsp;don’t&nbsp;behave&nbsp;as&nbsp;expected,&nbsp;in&nbsp;fact&nbsp;it&nbsp;works&nbsp;in&nbsp;a&nbsp;inverse&nbsp;way,&nbsp;load&nbsp;the&nbsp;mouse&nbsp;pointer&nbsp;coordinates&nbsp;in&nbsp;the&nbsp;labels.Text&nbsp;only&nbsp;if&nbsp;the&nbsp;pointer&nbsp;is&nbsp;in&nbsp;the&nbsp;form&nbsp;but&nbsp;outside&nbsp;the&nbsp;mapControl,&nbsp;i’ve&nbsp;tried&nbsp;uninstalling&nbsp;the&nbsp;map&nbsp;suite&nbsp;and&nbsp;reinstall&nbsp;but&nbsp;it&nbsp;didn’t&nbsp;make&nbsp;any&nbsp;difference.&nbsp;And&nbsp;why&nbsp;did&nbsp;you&nbsp;suggested&nbsp;“decimaldegrees”&nbsp;project?&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;again.

---

<div class="post-metadata">

**Author:** ![Val](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/v/e56c9b/32.png) [@Val](https://community.thinkgeo.com/u/Val)\
**Post date:** [August 11, 2010, 10:55am UTC](https://community.thinkgeo.com/t/mousecoordinates-show-coordinates-only-outside-mapcontrol/1385/5 "2010-08-11T10:55:11Z")

</div>

Your&nbsp;problem&nbsp;is&nbsp;very&nbsp;strange.&nbsp;I&nbsp;think&nbsp;that&nbsp;we&nbsp;would&nbsp;need&nbsp;a&nbsp;self&nbsp;contained&nbsp;sample&nbsp;app&nbsp;that&nbsp;narrows&nbsp;down&nbsp;the&nbsp;problem&nbsp;from&nbsp;you&nbsp;to&nbsp;determine&nbsp;what&nbsp;is&nbsp;going&nbsp;on.&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;I&nbsp;was&nbsp;suggesting&nbsp;the&nbsp;project&nbsp;"Formatting&nbsp;Decimal&nbsp;Degrees"&nbsp;just&nbsp;to&nbsp;show&nbsp;how&nbsp;to&nbsp;format&nbsp;decimal&nbsp;degrees&nbsp;to&nbsp;Degrees,&nbsp;Minutes&nbsp;and&nbsp;Seconds&nbsp;if&nbsp;you&nbsp;were&nbsp;interested.&nbsp;It&nbsp;was&nbsp;just&nbsp;some&nbsp;additional&nbsp;information&nbsp;related&nbsp;to&nbsp;displaying&nbsp;world&nbsp;coordinates&nbsp;if&nbsp;your&nbsp;data&nbsp;is&nbsp;in&nbsp;decimal&nbsp;degrees.

---

<div class="post-metadata">

**Author:** ![Wilmer](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/w/ee7513/32.png) [@Wilmer](https://community.thinkgeo.com/u/Wilmer)\
**Post date:** [August 11, 2010, 11:32am UTC](https://community.thinkgeo.com/t/mousecoordinates-show-coordinates-only-outside-mapcontrol/1385/6 "2010-08-11T11:32:15Z")

</div>

Hello&nbsp;Val.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Yes&nbsp;is&nbsp;a&nbsp;very&nbsp;strange&nbsp;problem,&nbsp;'cause&nbsp;the&nbsp;code&nbsp;in&nbsp;my&nbsp;app&nbsp;is&nbsp;the&nbsp;same&nbsp;used&nbsp;in&nbsp;the&nbsp;Code&nbsp;Community&nbsp;proyects,&nbsp;as&nbsp;i&nbsp;said&nbsp;and&nbsp;pasted&nbsp;before.&nbsp;  
&nbsp;Val,&nbsp;can&nbsp;you&nbsp;please&nbsp;explain&nbsp;what&nbsp;do&nbsp;you&nbsp;mean&nbsp;by:`we would need a self contained sample app `?&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;attention

---

<div class="post-metadata">

**Author:** ![Val](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/v/e56c9b/32.png) [@Val](https://community.thinkgeo.com/u/Val)\
**Post date:** [August 11, 2010, 12:08pm UTC](https://community.thinkgeo.com/t/mousecoordinates-show-coordinates-only-outside-mapcontrol/1385/7 "2010-08-11T12:08:52Z")

</div>

Since&nbsp;we&nbsp;cannot&nbsp;recreate&nbsp;the&nbsp;problem&nbsp;on&nbsp;our&nbsp;side,&nbsp;we&nbsp;would&nbsp;need&nbsp;a&nbsp;sample&nbsp;app&nbsp;from&nbsp;you&nbsp;that&nbsp;you&nbsp;can&nbsp;attach.&nbsp;In&nbsp;that&nbsp;sample&nbsp;app&nbsp;we&nbsp;would&nbsp;see&nbsp;the&nbsp;problem&nbsp;occuring&nbsp;before&nbsp;our&nbsp;eyes&nbsp;and&nbsp;that&nbsp;way&nbsp;it&nbsp;will&nbsp;help&nbsp;us&nbsp;determining&nbsp;where&nbsp;the&nbsp;problem&nbsp;is&nbsp;and&nbsp;how&nbsp;to&nbsp;fix&nbsp;it.&nbsp;There&nbsp;might&nbsp;be&nbsp;something&nbsp;&nbsp;specific&nbsp;to&nbsp;your&nbsp;case&nbsp;where&nbsp;you&nbsp;have&nbsp;some&nbsp;setup&nbsp;in&nbsp;certain&nbsp;way&nbsp;causing&nbsp;this&nbsp;undesirable&nbsp;behavior&nbsp;that&nbsp;only&nbsp;a&nbsp;sample&nbsp;app&nbsp;from&nbsp;you&nbsp;would&nbsp;help&nbsp;fixing.&nbsp;I&nbsp;hope&nbsp;this&nbsp;is&nbsp;clear.&nbsp;Thank&nbsp;you.

---

<div class="post-metadata">

**Author:** ![Wilmer](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/w/ee7513/32.png) [@Wilmer](https://community.thinkgeo.com/u/Wilmer)\
**Post date:** [August 11, 2010, 2:25pm UTC](https://community.thinkgeo.com/t/mousecoordinates-show-coordinates-only-outside-mapcontrol/1385/8 "2010-08-11T14:25:12Z")

</div>

Hi&nbsp;Val.  
  
Thank&nbsp;you&nbsp;for&nbsp;your&nbsp;help,&nbsp;here&nbsp;goes&nbsp;the&nbsp;code&nbsp;attached.&nbsp;Hope&nbsp;you&nbsp;could&nbsp;find&nbsp;whats&nbsp;happening.

[Form1.cs](https://community.thinkgeo.com/uploads/default/original/2X/6/6c5f802a0a233fac339f93bf8979d7d86280c290.cs) (10.7 KB)

---

<div class="post-metadata">

**Author:** ![Val](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/v/e56c9b/32.png) [@Val](https://community.thinkgeo.com/u/Val)\
**Post date:** [August 11, 2010, 10:06pm UTC](https://community.thinkgeo.com/t/mousecoordinates-show-coordinates-only-outside-mapcontrol/1385/9 "2010-08-11T22:06:47Z")

</div>

Thank&nbsp;you&nbsp;for&nbsp;your&nbsp;attached&nbsp;file.&nbsp;Tomorrow&nbsp;morning,&nbsp;I&nbsp;will&nbsp;look&nbsp;at&nbsp;that&nbsp;and&nbsp;let&nbsp;you&nbsp;know&nbsp;what&nbsp;I&nbsp;find.

---

<div class="post-metadata">

**Author:** ![Wilmer](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/w/ee7513/32.png) [@Wilmer](https://community.thinkgeo.com/u/Wilmer)\
**Post date:** [August 12, 2010, 8:11am UTC](https://community.thinkgeo.com/t/mousecoordinates-show-coordinates-only-outside-mapcontrol/1385/10 "2010-08-12T08:11:56Z")

</div>

Hi&nbsp;Val.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Finally&nbsp;found&nbsp;what’s&nbsp;was&nbsp;wrong,&nbsp;the&nbsp;winformsMap1\_MouseMove&nbsp;event&nbsp;handler&nbsp;was&nbsp;assigned&nbsp;to&nbsp;the&nbsp;forms’&nbsp;MouseMove&nbsp;event&nbsp;instead&nbsp;mapControl’s&nbsp;MouseMove&nbsp;event&nbsp;(My&nbsp;fellow&nbsp;worker,&nbsp;Iván&nbsp;discovered&nbsp;it).&nbsp;My&nbsp;bad,&nbsp;sorry&nbsp;for&nbsp;take&nbsp;some&nbsp;of&nbsp;your&nbsp;time&nbsp;looking&nbsp;for&nbsp;an&nbsp;error&nbsp;in&nbsp;the&nbsp;code&nbsp;when&nbsp;the&nbsp;code&nbsp;its&nbsp;o.k.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Once&nbsp;again&nbsp;thanks&nbsp;for&nbsp;your&nbsp;support.

---

<div class="post-metadata">

**Author:** ![Val](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/v/e56c9b/32.png) [@Val](https://community.thinkgeo.com/u/Val)\
**Post date:** [August 12, 2010, 9:18am UTC](https://community.thinkgeo.com/t/mousecoordinates-show-coordinates-only-outside-mapcontrol/1385/11 "2010-08-12T09:18:43Z")

</div>

Wilmer,&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;You&nbsp;don’t&nbsp;have&nbsp;to&nbsp;apologize.&nbsp;That’s&nbsp;our&nbsp;job&nbsp;to&nbsp;help.&nbsp;I&nbsp;am&nbsp;glad&nbsp;your&nbsp;team&nbsp;discovered&nbsp;it.&nbsp;Do&nbsp;not&nbsp;hesitate&nbsp;to&nbsp;post&nbsp;any&nbsp;other&nbsp;questions&nbsp;you&nbsp;might&nbsp;have&nbsp;while&nbsp;developping&nbsp;with&nbsp;Map&nbsp;Suite&nbsp;Desktop&nbsp;Edition.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Val.
