Community
Hi all, not very Revit API specific but I'll give it a try anyway. I'm following a discussion here https://forums.autodesk.com/t5/revit-api-forum/example-rubberband/m-p/9004118#M41057 but apparently I'm getting error when I copy the code, any idea how to fix it? PS I don't have experience with VB, Ill use the code as it is. Cheers!
Imports System.Runtime.InteropServices
Public Module WindowsMessaging
<DllImport("user32.dll", EntryPoint:="SendMessage")="">
Function SendMessage(ByVal hWnd As Integer, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer</dllimport("user32.dll",>
End Function
<DllImport("user32.dll", EntryPoint:="PostMessage")="">
Function PostMessage(ByVal hWnd As Integer, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer</dllimport("user32.dll",>
End Function
Public Const WM_KEYDOWN As Integer = &H100
Function SendWindowsMessage(ByVal hWnd As Integer, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Dim result As Integer = 0
If hWnd > 0 Then result = SendMessage(hWnd, Msg, wParam, lParam)
Return result
End Function
Function PostWindowsMessage(ByVal hWnd As Integer, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Dim result As Integer = 0
If hWnd > 0 Then result = PostMessage(hWnd, Msg, wParam, lParam)
Return result
End Function
End Module
error
It's a simple syntax error. Apparently some editor confused Visual Basic attributes with xml. Here's the fixed code.
Imports System.Runtime.InteropServices
Public Module WindowsMessaging
<DllImport("user32.dll", EntryPoint:="SendMessage")>
Function SendMessage(ByVal hWnd As Integer, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
End Function
<DllImport("user32.dll", EntryPoint:="PostMessage")>
Function PostMessage(ByVal hWnd As Integer, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
End Function
Public Const WM_KEYDOWN As Integer = &H100
Function SendWindowsMessage(ByVal hWnd As Integer, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Dim result As Integer = 0
If hWnd > 0 Then result = SendMessage(hWnd, Msg, wParam, lParam)
Return result
End Function
Function PostWindowsMessage(ByVal hWnd As Integer, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Dim result As Integer = 0
If hWnd > 0 Then result = PostMessage(hWnd, Msg, wParam, lParam)
Return result
End Function
End Module
However, I am skeptical of declaring hWnd, wParam, and lParam as Integers when running in 64 bits. I'd probably declare them as IntPtrs.
Can't find what you're looking for? Ask the community or share your knowledge.