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 SendStringToExecute (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.