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

SendStringToExecute and modeless dialog

5 REPLIES 5
Reply
Message 1 of 6
Jan1
934 Views, 5 Replies

SendStringToExecute and modeless dialog

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
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Jan1

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
Message 3 of 6
Jan1
in reply to: Jan1

Thanks, it works with the acedPostCommand command. But how can I supress the command echo?
Message 4 of 6
Anonymous
in reply to: Jan1

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?
Message 5 of 6
Jan1
in reply to: Jan1

Works fine, thanks.
Message 6 of 6
corra76
in reply to: Jan1

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

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