.NET

Reply
Active Member
sbergeron
Posts: 8
Registered: ‎01-12-2006
Message 1 of 5 (152 Views)

Palette keeps focus

152 Views, 4 Replies
01-12-2006 06:14 AM
I have made a palette using a usercontrol with a button on it. This button sends a command to the command line using DocumentManager.MdiActiveDocument.SendStringToExecute.

Up to there it all works fine but the command never executes until the mouse cursor is moved out of the palette and over the main drawing window.

Is there a way to give the focus temporarily to the drawing area? The AutoCAD Tools Palette seems to be doing that.
Valued Contributor
fmarcelino
Posts: 61
Registered: ‎10-25-2005
Message 2 of 5 (152 Views)

Re: Palette keeps focus

01-26-2006 08:05 AM in reply to: sbergeron
Hi Sebastien,

the same thing is happening to me. I need help to.
If I found a way I will let you know.

Regards,
Filipe Marcelino
Valued Contributor
fmarcelino
Posts: 61
Registered: ‎10-25-2005
Message 3 of 5 (152 Views)

Re: Palette keeps focus

02-02-2006 10:20 AM in reply to: sbergeron
Hi,

I figured it out. Declare this function in your code:

Private Declare Function SetFocus Lib "user32" (ByVal hwnd As System.IntPtr) As System.IntPtr

then, after you call "SendStringToExecute" caal this function, like this:

Application.DocumentManager.MdiActiveDocument.SendStringToExecute("test", True, False, False)
SetFocus(Application.DocumentManager.MdiActiveDocument.Window.Handle)

I hope this helps,


Regards,
Filipe Marcelino
Active Member
sbergeron
Posts: 8
Registered: ‎01-12-2006
Message 4 of 5 (152 Views)

Re: Palette keeps focus

02-08-2006 07:04 AM in reply to: sbergeron
I have tried the function SetActiveWindow before, also from user32 library. Your method with SetFocus seems to perform better, but we still have to move the cursor off the palette for the command to execute.
Valued Contributor
fmarcelino
Posts: 61
Registered: ‎10-25-2005
Message 5 of 5 (152 Views)

Re: Palette keeps focus

02-08-2006 07:39 AM in reply to: sbergeron
Hi remember one thing. When you call the method SendStringToExecute afetr your command name you have to insert a space like this:

Application.DocumentManager.MdiActiveDocument.SendStringToExecute("test ", True, False, False)

Let me know if it works.

Regards,
Filipe Marcelino
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.