.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Palette keeps focus

4 REPLIES 4
Reply
Message 1 of 5
sbergeron
275 Views, 4 Replies

Palette keeps focus

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.
4 REPLIES 4
Message 2 of 5
fmarcelino
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
Message 3 of 5
fmarcelino
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
Message 4 of 5
sbergeron
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.
Message 5 of 5
fmarcelino
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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost