Message 1 of 8
Generic Routine to post arbitrary commands to the AutoCAD prompt
Not applicable
03-05-2008
03:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Im trying to port the following VB6 code to VB.NET but keep hitting the wall. Has anyone managed to port this function to VB.NET? All i manage is to send random chineese unicode characters when trying to send commands. I need a generic function that works with both AutoCAD and AutoCAD LT, which disqualifies me from using any AutoCAD ActiveX APIs... Any ideas or pointers on how to port this would be highly appreciated.
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long
Declare Function GetForegroundWindow Lib "user32" () As Long
Public Const WM_COPYDATA = &H4A
Type COPYDATASTRUCT
dwData As Long
cbData As Long
lpData As String
End Type
Public Sub SendToCommandPrompt(strMessage As String)
Dim DataStruct As COPYDATASTRUCT
DataStruct.dwData = 1
DataStruct.lpData = strMessage
DataStruct.cbData = Len(strMessage) + 2
AppActivate ThisDrawing.Application.Caption
SendMessage GetForegroundWindow, WM_COPYDATA, 0, DataStruct
End Sub
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long
Declare Function GetForegroundWindow Lib "user32" () As Long
Public Const WM_COPYDATA = &H4A
Type COPYDATASTRUCT
dwData As Long
cbData As Long
lpData As String
End Type
Public Sub SendToCommandPrompt(strMessage As String)
Dim DataStruct As COPYDATASTRUCT
DataStruct.dwData = 1
DataStruct.lpData = strMessage
DataStruct.cbData = Len(strMessage) + 2
AppActivate ThisDrawing.Application.Caption
SendMessage GetForegroundWindow, WM_COPYDATA, 0, DataStruct
End Sub