<?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: Getting focus to switch to editor from palette in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/getting-focus-to-switch-to-editor-from-palette/m-p/2567585#M68877</link>
    <description>Works Great!  Thanks guys, you are the best</description>
    <pubDate>Tue, 06 Oct 2009 18:11:39 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2009-10-06T18:11:39Z</dc:date>
    <item>
      <title>Getting focus to switch to editor from palette</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-focus-to-switch-to-editor-from-palette/m-p/2567582#M68874</link>
      <description>I have created a custom user control that i use in a palette.  The control has a button on it that when clicked asks the user to select an insertion point for a new block.  The code works and inserts the block. The problem is when i go to select the insertion point I have to click once on the drawing area so it gets focus, then i can click again to pick my insertion point.  Is there anyway in code to set focus from the palette to the drawing editor? &lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance for your help &lt;BR /&gt;
Mark</description>
      <pubDate>Mon, 05 Oct 2009 19:56:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-focus-to-switch-to-editor-from-palette/m-p/2567582#M68874</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-10-05T19:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: Getting focus to switch to editor from palette</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-focus-to-switch-to-editor-from-palette/m-p/2567583#M68875</link>
      <description>Many people (including myself) have had similar problems with both palettes and modeless dialogs.&lt;BR /&gt;
&lt;BR /&gt;
I think most who have solved their problem would indicate that your getpoint should not run inside the event handler of the palette, but rather be in a sub that is called from the event handler.  My problem was a little different, and after attempting a lot of different approaches, a solution that ended up working was proposed to me by Kean Walmsley.  That solution is to PInvoke a SetFocus method like this:&lt;BR /&gt;
{code}&lt;BR /&gt;
[System.Runtime.InteropServices.DllImport("user32.dll")] _&lt;BR /&gt;
  Public Function SetFocus(ByVal hwnd As IntPtr) As IntPtr&lt;BR /&gt;
  End Function&lt;BR /&gt;
{code}&lt;BR /&gt;
(NOTE: either with or without the [code] tags, this editor was removing the DllImport statement because of the 'greater than/less than' symbols.  The top line should have the brackets [ ] replaced with 'less than, greater than')&lt;BR /&gt;
&lt;BR /&gt;
Then call it right before the select point like this:&lt;BR /&gt;
{code}&lt;BR /&gt;
SetFocus(Document.UnmanagedObject)&lt;BR /&gt;
{code}&lt;BR /&gt;
where Document is obviously a reference to whatever document you are trying to activate.&lt;BR /&gt;
&lt;BR /&gt;
This worked for my particular problem with a modeless dialog keeping the focus when it shouldn't have.</description>
      <pubDate>Mon, 05 Oct 2009 21:09:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-focus-to-switch-to-editor-from-palette/m-p/2567583#M68875</guid>
      <dc:creator>chiefbraincloud</dc:creator>
      <dc:date>2009-10-05T21:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: Getting focus to switch to editor from palette</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-focus-to-switch-to-editor-from-palette/m-p/2567584#M68876</link>
      <description>If you're targeting AutoCAD 2009 at minimum, you can use&lt;BR /&gt;
this, just before you call any GetXxxxx() method of the Editor:&lt;BR /&gt;
&lt;BR /&gt;
    Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView();&lt;BR /&gt;
&lt;BR /&gt;
On AutoCAD 2009 this requires a reference to AcMgdInternal.dll,&lt;BR /&gt;
but not on 2010.&lt;BR /&gt;
&lt;BR /&gt;
If you're using a ToolStrip on your palette, this may not work.&lt;BR /&gt;
&lt;BR /&gt;
In that case, download this for some additional help:&lt;BR /&gt;
&lt;BR /&gt;
   http://www.caddzone.com/PaletteUtils.cs&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD&lt;BR /&gt;
Supporting AutoCAD 2000 through 2010&lt;BR /&gt;
&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");&lt;BR /&gt;
&lt;BR /&gt;
&lt;OLDVWS&gt; wrote in message news:6266108@discussion.autodesk.com...&lt;BR /&gt;
I have created a custom user control that i use in a palette.  The control &lt;BR /&gt;
has a button on it that when clicked asks the user to select an insertion &lt;BR /&gt;
point for a new block.  The code works and inserts the block. The problem is &lt;BR /&gt;
when i go to select the insertion point I have to click once on the drawing &lt;BR /&gt;
area so it gets focus, then i can click again to pick my insertion point. &lt;BR /&gt;
Is there anyway in code to set focus from the palette to the drawing editor?&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance for your help&lt;BR /&gt;
Mark&lt;/OLDVWS&gt;</description>
      <pubDate>Mon, 05 Oct 2009 21:31:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-focus-to-switch-to-editor-from-palette/m-p/2567584#M68876</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-10-05T21:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: Getting focus to switch to editor from palette</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-focus-to-switch-to-editor-from-palette/m-p/2567585#M68877</link>
      <description>Works Great!  Thanks guys, you are the best</description>
      <pubDate>Tue, 06 Oct 2009 18:11:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-focus-to-switch-to-editor-from-palette/m-p/2567585#M68877</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-10-06T18:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: Getting focus to switch to editor from palette</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-focus-to-switch-to-editor-from-palette/m-p/6550866#M68878</link>
      <description>&lt;P&gt;2017..&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using the mouse enter and leave events works for me in 2017. MouseEnter to set the focus on the toolstrips of a palette&amp;nbsp;(fixed two clicks on the first button click) and the MouseLeave to set focus the normal way, without the button pulling the focus back..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Snippet&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;   Private&amp;nbsp;&lt;SPAN&gt;Sub&lt;/SPAN&gt;&amp;nbsp;ToolStrip1_MouseEnter&lt;SPAN&gt;(&lt;/SPAN&gt;sender&amp;nbsp;&lt;SPAN&gt;As&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;Object&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&amp;nbsp;e&amp;nbsp;&lt;SPAN&gt;As&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;EventArgs&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;Handles&lt;/SPAN&gt;&amp;nbsp;ToolStrip1&lt;SPAN&gt;.&lt;/SPAN&gt;MouseEnter &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;      ToolStrip1&lt;SPAN&gt;.&lt;/SPAN&gt;Focus&lt;SPAN&gt;()&lt;/SPAN&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;SPAN&gt;   End&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;Sub&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;   Private&lt;/SPAN&gt;&amp;nbsp;Clamps_Clicked&amp;nbsp;&lt;SPAN&gt;As&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;Boolean&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;=&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;False&lt;/SPAN&gt;
&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;Private&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;Sub&lt;/SPAN&gt;&amp;nbsp;Clamps_Click&lt;SPAN&gt;(&lt;/SPAN&gt;sender&amp;nbsp;&lt;SPAN&gt;As&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;Object&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&amp;nbsp;e&amp;nbsp;&lt;SPAN&gt;As&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;EventArgs&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;Handles&lt;/SPAN&gt;&amp;nbsp;Clamps&lt;SPAN&gt;.&lt;/SPAN&gt;Click
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Clamps_Clicked&amp;nbsp;&lt;SPAN&gt;=&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;True&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;End&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;Sub&lt;/SPAN&gt;
&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;Private&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;Sub&lt;/SPAN&gt;&amp;nbsp;Clamps_MouseEnter&lt;SPAN&gt;(&lt;/SPAN&gt;sender&amp;nbsp;&lt;SPAN&gt;As&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;Object&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&amp;nbsp;e&amp;nbsp;&lt;SPAN&gt;As&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;EventArgs&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;Handles&lt;/SPAN&gt;&amp;nbsp;Clamps&lt;SPAN&gt;.&lt;/SPAN&gt;MouseEnter
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Clamps_Clicked&amp;nbsp;&lt;SPAN&gt;=&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;False&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;End&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;Sub&lt;BR /&gt;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;Private&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;Sub&lt;/SPAN&gt;&amp;nbsp;Clamps_MouseLeave&lt;SPAN&gt;(&lt;/SPAN&gt;sender&amp;nbsp;&lt;SPAN&gt;As&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;Object&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&amp;nbsp;e&amp;nbsp;&lt;SPAN&gt;As&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;EventArgs&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;Handles&lt;/SPAN&gt;&amp;nbsp;Clamps&lt;SPAN&gt;.&lt;/SPAN&gt;MouseLeave
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;If&lt;/SPAN&gt;&amp;nbsp;Clamps_Clicked&amp;nbsp;&lt;SPAN&gt;Then&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;'PaletteFocus.ActivateEditor() 'txt Tony&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;Active&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;Document&lt;SPAN&gt;.&lt;/SPAN&gt;Window&lt;SPAN&gt;.&lt;/SPAN&gt;Focus&lt;SPAN&gt;()&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;myApp&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Commands&lt;/SPAN&gt;&lt;SPAN&gt;.SelectStuff&lt;/SPAN&gt;&lt;SPAN&gt;()&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;End&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;If&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;End&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;Sub&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2016 20:18:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-focus-to-switch-to-editor-from-palette/m-p/6550866#M68878</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-09-08T20:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: Getting focus to switch to editor from palette</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-focus-to-switch-to-editor-from-palette/m-p/6551180#M68879</link>
      <description>Use SendStringToExecute to start the command. Helps against the bounce of the toolstrip button and the user can repeat the command after enter of space..&lt;BR /&gt;&lt;BR /&gt;Active.Document.Window.Focus()&lt;BR /&gt;Active.Document.SendStringToExecute("MyCommand ", True, False, False)&lt;BR /&gt;</description>
      <pubDate>Thu, 08 Sep 2016 22:44:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-focus-to-switch-to-editor-from-palette/m-p/6551180#M68879</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-09-08T22:44:31Z</dc:date>
    </item>
  </channel>
</rss>

