.NET

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

Palette keeps focus

155 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 (155 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 (155 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 (155 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 (155 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
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!