Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

RubberBand

1 REPLY 1
Reply
Message 1 of 2
revitaddins
220 Views, 1 Reply

RubberBand

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

errorScreenshot 2021-04-02 152359.png

 

 

 

1 REPLY 1
Message 2 of 2
mhannonQ65N2
in reply to: revitaddins

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 hWndwParam, 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.

Post to forums  

Rail Community


Autodesk Design & Make Report