That's odd it didn't work for you, however, I'm glad to hear you were able to make some tweaks and get it working.
>I couldn't get it to work with the Public [Shared[lt]DllImportAttribute] declaration. I imported System.Runtime.InteropServices. It kept saying declaration expected on the less-than symbol after shared :( I don't know what I missed... Anyway what you gave me led me to find the following that did work for me. These are the only two lines that changed.
>
> Declare Auto Function ReleaseCapture Lib "user32.dll" () As Boolean
> Declare Auto Function SendMessage Lib "user32.dll" (hWnd As IntPtr, Msg As Integer, wParam As Integer, lParam As Integer) As Integer
>
>
>Thanks again,
>Joe.
>
>>Hi Joe,
>>
>>You don't need to change too much of your original code. Here are the revisions:
>>
>>
>>' Import
>>Imports System.Runtime.InteropServices
>>
>>' Under Programming space
>>Const WM_NCLBUTTONDOWN As Integer = &HA1
>>Public Const HTCAPTION As Integer = &H2
>>
>>Public Shared<DllImportAttribute("user32.dll")> _
>>Function SendMessage(hWnd As IntPtr, Msg As Integer, wParam As Integer, lParam As Integer) As Integer
>>
>>Public Shared<DllImportAttribute("user32.dll")> _
>>Function ReleaseCapture() As Boolean
>>
>>' On Mouse Down (object where you want to drag)
>>ReleaseCapture()
>>SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0)
>>
>>
>>
>>>Previously I used the following code to move the form. I don't know how to do this in .NET? Anyone know how?
>>>
>>>
>>>' Declarations
>>> Public Declare Function ReleaseCapture Lib "user32" () As Long
>>> Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
>>> (ByVal hWnd As Long, ByVal wMsg As Long, _
>>> ByVal wParam As Long, ByVal lParam As Long) As Long
>>>
>>>' In the form or object that can be used to move the form
>>> Private Sub object_MouseDown()
>>> ReleaseCapture()
>>> SendMessage(Me.hwnd, &HA1, 2, 0&)
>>> End Sub
>>>
-----------------------------------------
Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.comwww.prenia.comWeblog: blogs.prenia.com/cathi