<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Locating/Centering a form in an Add-In in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/locating-centering-a-form-in-an-add-in/m-p/539950#M14619</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey Leo,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thanks, that did it!!! From there i was able to get what I needed to center the form!!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kevin Orcutt&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 Feb 2013 12:43:47 GMT</pubDate>
    <dc:creator>KevinOrcutt</dc:creator>
    <dc:date>2013-02-20T12:43:47Z</dc:date>
    <item>
      <title>Locating/Centering a form in an Add-In</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/locating-centering-a-form-in-an-add-in/m-p/539945#M14614</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I'm sure this one's been covered, but for the life of me, i can't find a solution in either the forum or the docs :confused: ...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm building an Add-In in Visual BASIC for a Desktop environment (Arcmap 10.1).&amp;nbsp; I have a simple tool that the user selects a feature, and then I want a simple form to come up to show some attributes and other things...&amp;nbsp; This is not a dockable window or anything like that, just a simple form...&amp;nbsp; I am trying to bring up a custom form after the user "Uses/clicks" my Add-In tool... I can presenty get the form to come up, that's NO problem...&amp;nbsp; It's the location of that form that's causing me grief :mad:. I am trying to center the form on the ArcMap application window...&amp;nbsp; NO GO! I can't figure out a way of getting the form to come up over/centered on the ArcMap application.&amp;nbsp; This is particularly important when the user has multiple monitors and has ArcMap on the second or beyond monitor...&amp;nbsp;&amp;nbsp; Is there a way of getting the desktop (Windows Desktop) location of the running ArcMap application and using that to locate said form???&amp;nbsp; I'm pretty sure this should be an easy one to solve,, just pulling my hair out trying to figure out! &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&amp;nbsp; I'm figuring I should start with My.ArcMap.( something goes here :))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in Advance,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Slightly Frustrated,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kevin Orcutt&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Feb 2013 19:44:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/locating-centering-a-form-in-an-add-in/m-p/539945#M14614</guid>
      <dc:creator>KevinOrcutt</dc:creator>
      <dc:date>2013-02-19T19:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: Locating/Centering a form in an Add-In</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/locating-centering-a-form-in-an-add-in/m-p/539946#M14615</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;it involves getting the application height, and subtracting your form height, then divide that result by 2.&amp;nbsp; this is your form's top.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;same for width.&amp;nbsp; get the application width, subtract your form width, then divide that result by 2.&amp;nbsp; this is your form's left.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Feb 2013 19:53:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/locating-centering-a-form-in-an-add-in/m-p/539946#M14615</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2013-02-19T19:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: Locating/Centering a form in an Add-In</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/locating-centering-a-form-in-an-add-in/m-p/539947#M14616</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Leo,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;getting there, but not quite, sorry.&amp;nbsp; I figured that I would have to do something along those lines, but getting the application height and width among other things are escaping my grasp...&amp;nbsp; The KEY thing that I'm trying to get is the application's location on the desktop.&amp;nbsp; That way I can place the form over it when it comes up.&amp;nbsp; As mentioned, this is particular to when ArcMap is on the second monitor or beyond.&amp;nbsp; I want the form to appear over ArcMap, not back on the first monitor.&amp;nbsp; So the location is Key...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any other ideas???&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kevin O.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Feb 2013 20:33:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/locating-centering-a-form-in-an-add-in/m-p/539947#M14616</guid>
      <dc:creator>KevinOrcutt</dc:creator>
      <dc:date>2013-02-19T20:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: Locating/Centering a form in an Add-In</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/locating-centering-a-form-in-an-add-in/m-p/539948#M14617</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm not a VB person, but the concept will position your form over ArcMap, wherever ArcMap is.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What happens when you type My.ArcMap.&amp;nbsp; ?&amp;nbsp; What do you get?&amp;nbsp; Height?&amp;nbsp; Read the API.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Feb 2013 20:43:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/locating-centering-a-form-in-an-add-in/m-p/539948#M14617</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2013-02-19T20:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: Locating/Centering a form in an Add-In</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/locating-centering-a-form-in-an-add-in/m-p/539949#M14618</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What about casting from the application to IWindowPostion?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="http://help.arcgis.com/en/sdk/10.0/vba_desktop/componenthelp/001t/001t000000z3000000.htm" rel="nofollow" target="_blank"&gt;http://help.arcgis.com/en/sdk/10.0/vba_desktop/componenthelp/001t/001t000000z3000000.htm&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Feb 2013 21:00:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/locating-centering-a-form-in-an-add-in/m-p/539949#M14618</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2013-02-19T21:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: Locating/Centering a form in an Add-In</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/locating-centering-a-form-in-an-add-in/m-p/539950#M14619</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey Leo,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thanks, that did it!!! From there i was able to get what I needed to center the form!!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kevin Orcutt&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Feb 2013 12:43:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/locating-centering-a-form-in-an-add-in/m-p/539950#M14619</guid>
      <dc:creator>KevinOrcutt</dc:creator>
      <dc:date>2013-02-20T12:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: Locating/Centering a form in an Add-In</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/locating-centering-a-form-in-an-add-in/m-p/539951#M14620</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you set the form's owner when you show it then all you should need to do is set the form's StartupPosition property to CenterParent.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;// set the form's owner&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;yourForm.Show(System.Windows.Forms.Control.FromHandle((IntPtr)m_application.hWnd));&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Feb 2013 13:05:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/locating-centering-a-form-in-an-add-in/m-p/539951#M14620</guid>
      <dc:creator>NeilClemmons</dc:creator>
      <dc:date>2013-02-20T13:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: Locating/Centering a form in an Add-In</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/locating-centering-a-form-in-an-add-in/m-p/539952#M14621</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Neil,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Theoretically that should happen, but my applications have the StartPosition property set to CenterParent for the forms. I set the form's owner using your code and yet the forms appear randomly on the page. I have to use the following sub to center my forms before I show them.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Public Sub CenterForm(ByVal form As System.Windows.Forms.Form, ByVal m_application As ESRI.ArcGIS.Framework.IApplication)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pWinPos As ESRI.ArcGIS.Framework.IWindowPosition
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim CenterX As Short
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim CenterY As Short

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pWinPos = m_application
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CenterX = (pWinPos.Width / 2) + pWinPos.Left
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CenterY = (pWinPos.Height / 2) + pWinPos.Top

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; form.Location = New System.Drawing.Point(CenterX - form.Width / 2, CenterY - form.Height / 2)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; form.StartPosition = Windows.Forms.FormStartPosition.Manual

&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:25:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/locating-centering-a-form-in-an-add-in/m-p/539952#M14621</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2021-12-11T23:25:06Z</dc:date>
    </item>
  </channel>
</rss>

