Results 1 to 4 of 4

Thread: SendMessage Lib "User32" Alias "SendMessageA" in VB.net? [resolved]

  1. #1

    Thread Starter
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172

    Question SendMessage Lib "User32" Alias "SendMessageA" in VB.net? [resolved]

    This api call should move the form around. even if it is borderless (what mine is).. any suggestions on how to do this with the below code OR with other code?

    I am wondering how i can use similar code or this code in vb.net
    i doesnt seem to work at all.

    VB Code:
    1. Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    2. Private Declare Sub ReleaseCapture Lib "User32" ()
    3. Const WM_NCLBUTTONDOWN = &HA1
    4. Const HTCAPTION = 2
    5.  
    6.  
    7. Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    8. Dim lngReturnValue As Long
    9.    If Button = 1 Then
    10.       Call ReleaseCapture
    11.       lngReturnValue = SendMessage(Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
    12.   End If
    13. End Sub

    this is the code i used in vb6.. but in lParam As Any gives : Any is not supported bug..
    Last edited by Ultimasnake; Sep 19th, 2003 at 07:49 AM.
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

  2. #2
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148
    There's a class for moving a captionless form in VB.net on this site...

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Or use this code :
    VB Code:
    1. Private Declare Function ReleaseCapture Lib "user32" () As Long
    2.     Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
    3.  
    4.     Private Const WM_NCLBUTTONDOWN As Integer = &HA1
    5.     Private Const HTCAPTION As Integer = 2
    6.  
    7.     Public Sub New()
    8.         Me.Text = "Drag anywhere to move"
    9.         AddHandler Me.MouseDown, AddressOf frmMain_MouseDown
    10.     End Sub
    11.  
    12.     Private Sub frmMain_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
    13.         'Don't drag the sceen if it is the right button or the wheel.
    14.         If e.Button = MouseButtons.Left Then
    15.             ReleaseCapture()
    16.             SendMessage(Me.Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0)
    17.         End If
    18.  
    19.     End Sub

  4. #4

    Thread Starter
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172
    Thanks guys...

    i am using the one from pirate

    its like my code but fixed :P
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width