.NET

Reply
Active Contributor
Jan1
Posts: 43
Registered: ‎05-14-2004
Message 1 of 6 (600 Views)

SendStringToExecute and modeless dialog

600 Views, 5 Replies
03-15-2006 05:27 AM
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
*Tony Tanzillo
Message 2 of 6 (600 Views)

Re: SendStringToExecute and modeless dialog

03-15-2006 11:49 AM 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
Active Contributor
Jan1
Posts: 43
Registered: ‎05-14-2004
Message 3 of 6 (600 Views)

Re: SendStringToExecute and modeless dialog

03-16-2006 03:19 AM in reply to: Jan1
Thanks, it works with the acedPostCommand command. But how can I supress the command echo?
*Tony Tanzillo
Message 4 of 6 (600 Views)

Re: SendStringToExecute and modeless dialog

03-16-2006 07:23 AM 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?
Active Contributor
Jan1
Posts: 43
Registered: ‎05-14-2004
Message 5 of 6 (600 Views)

Re: SendStringToExecute and modeless dialog

03-16-2006 11:45 PM in reply to: Jan1
Works fine, thanks.
Member
corra76
Posts: 5
Registered: ‎05-25-2010
Message 6 of 6 (481 Views)

Re: Palette and modeless dialog command

03-25-2011 08:43 AM 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

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!