SendStringToExecute and modeless dialog

SendStringToExecute and modeless dialog

Anonymous
Not applicable
1,493 Views
5 Replies
Message 1 of 6

SendStringToExecute and modeless dialog

Anonymous
Not applicable
Hello,

I'm trying to call the command SendStringToExecute from a modeless dialog (platte), but the command only gets executed when I move the mouse cursor out of the dialog. While I do not move the cursor out of my dialog the command seems to wait.

Here is a short extract:

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Application.DocumentManager.MdiActiveDocument.SendStringToExecute("_line 0,0 100,0 ", True, False, True)
End Sub

Regards, Andreas
0 Likes
1,494 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Try using this instead of SendStringToExecute:

[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "?acedPostCommand@@YAHPBD@Z")]
extern static public int acedPostCommand(string cmd);

In addition, if your palette has the KeepFocus property
set to True, you should set it to false before the call.

If the arrow cursor does not change to a crosshair when
you move it over the drawing view window, then you can
also P/Invoke the PostMessage() API after calling the
above function, and post a WM_SETFOCUS message to
the Document object's window.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

wrote in message news:5111406@discussion.autodesk.com...
Hello,

I'm trying to call the command SendStringToExecute from a modeless dialog (platte), but the command only gets executed when I move the mouse cursor out of the dialog. While I do not move the cursor out of my dialog the command seems to wait.

Here is a short extract:

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Application.DocumentManager.MdiActiveDocument.SendStringToExecute("_line 0,0 100,0 ", True, False, True)
End Sub

Regards, Andreas
0 Likes
Message 3 of 6

Anonymous
Not applicable
Thanks, it works with the acedPostCommand command. But how can I supress the command echo?
0 Likes
Message 4 of 6

Anonymous
Not applicable
Pass your commnd input to SendStringToExecute()
exactly as you did before, then call acedPostCommand()
with a null string as the argument.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

wrote in message news:5112521@discussion.autodesk.com...
Thanks, it works with the acedPostCommand command. But how can I supress the command echo?
0 Likes
Message 5 of 6

Anonymous
Not applicable
Works fine, thanks.
0 Likes
Message 6 of 6

Anonymous
Not applicable

Hi everybody,

 

I'm writing some code (Visual Studio 2010 with Autocad 2011 on Windows XP SP3) to throw a command from a Autocad palette to a dwg.

It works with Send​StringToExecute (I move the mouse from palette to the dwg window and the arrow cursor changes to a crosshair rightly) but the command its not syncron.

 

So, I changed my code to use acedPostCommand (that is syncron) but it doesn't work rightly because only gets executed when I move the mouse cursor out of the dialog pattern and I click on the dwg (I don't want click..).

I used also PostMessage API with WM_SETFOCUS but it works like before.

I don't understand were I got wrong.

Here is some code...

---------------------------------------------------------------------------------------------------

Private Declare Auto Function acedPostCommand Lib "acad.exe" Alias "?acedPostCommand@@YAHPB_W@Z" (ByVal strExpr As String) As Integer

 

<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _

Private Shared Function PostMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Boolean

End Function

 

Public Function insertBlock(ByVal strDwgPathFileName As String) As ObjectId

 

Dim doc As Autodesk.AutoCAD.ApplicationServices.Document

doc = Application.DocumentManager.MdiActiveDocument

 

'Pattern focus...

StrumentaUTA.StrumentUTA.m_ps.KeepFocus = False

 

'Throw BJ command...

acedPostCommand(Chr(27) & Chr(27) & "BJ " & Chr(34) & strDwgPathFileName & Chr(34) & Chr(13))

 

Const WM_SETFOCUS As Long = &H7

Dim hWndCAD As IntPtr = Autodesk.AutoCAD.ApplicationServices.Application.MainWindow.Handle

Dim boolEr As Boolean = PostMessage(hWndCAD, WM_SETFOCUS, 0, 0)

 

End Function

-------------------------------------------------------------------------

 

Does anybody can help me understand what'wrong with it?

 

Thank you

 

Corra

0 Likes