releaseCapture API and send message API. 
Author Message
 releaseCapture API and send message API.

Hello

In VB6 I created a form that could be moved by clicking anywhere on the from
and dragging it.  it used the releaseCapture API and send message API. I am
unable to replicate this in vb.net.

can anyone help me.
I think it has to do with the handle returned from the form in .net. I
Converted it to me.handle.ToInt32. and sent it to send message.

here is a sample in VB6

Option Explicit

    '
****************************************************************************
**********
    '* API'S
    '
****************************************************************************
**********

'***************************************************************************
***********
    Private Declare Function ReleaseCapture Lib "user32" () As Long
    ' Purpose         : This function will A window that has captured the
stylus receives all
    '                   stylus input, regardless of the position of the
stylus.
    ' Pre-conditions  : None
    ' Arguments       : None
    ' Returns         : Long - Nonzero indicates success. Zero indicates
failure.
    ' Post-conditions : None

'***************************************************************************
***********

'***************************************************************************
***********
    Private 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
    ' Purpose         : This function will function sends the specified
message to a window or windows
    ' Pre-conditions  : None
    ' Arguments       : hWnd - Handle to the window whose window procedure
will receive the message.
    '                   wMsg - Specifies the message to be sent.
    '                   wParam - Specifies additional message-specific
information.
    '                   lParam - Specifies additional message-specific
information.
    ' Returns         : Long - Nonzero indicates success. Zero indicates
failure.
    ' Post-conditions : None

'***************************************************************************
***********

    '
****************************************************************************
**********
    '* CONSTANTS
    '
****************************************************************************
**********

    'used to drag a form around that has no title bar
    Private Const WM_NCLBUTTONDOWN = &HA1

    'Used with indicate that the drag is In a title bar.
    Private Const HTCAPTION = 2

'
****************************************************************************
**********
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single,
Y As Single)
' Purpose         : Used to drag and drop the form since there is no header
' Pre-conditions  : None
' Arguments       : Button  -
'                   Shift  -
'                   X  -
'                   Y  -
' Returns         : None
' Post-conditions : None
' Written By      : PRITCJ (IMS Health)
'
****************************************************************************
**********

    'Don't drag the sceen if it is the right button or the wheel.
    If Button = vbLeftButton Then
        ReleaseCapture
        SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0
    End If
End Sub



Mon, 11 Oct 2004 21:21:11 GMT  
 releaseCapture API and send message API.


Quote:
> In VB6 I created a form that could be moved by clicking anywhere on the from
> and dragging it.  it used the releaseCapture API and send message API. I am
> unable to replicate this in vb.net.

> can anyone help me.
> I think it has to do with the handle returned from the form in .net. I
> Converted it to me.handle.ToInt32. and sent it to send message.

Handle is an IntPtr and your SendMessage API should use an IntPtr as the
first argument.

See this thread too:

http://groups.google.com/groups?selm=711e9158.0202060929.5268842a%
40posting.google.com

If you still have problems, please post your definition of the API
declares.

--
Patrick Steele
Microsoft .NET MVP



Tue, 12 Oct 2004 03:20:39 GMT  
 releaseCapture API and send message API.
Hi there...

Made the changes but it still does not work.... below is a simple sample
project

Option Explicit

Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As IntPtr, ByVal wMsg As Long, ByVal wParam As Long, ByVal
lParam As Long) As Long

    'used to drag a form around that has no title bar
    Private Const WM_NCLBUTTONDOWN = &HA1

    'Used with indicate that the drag is In a title bar.
    Private Const HTCAPTION = 2

      Private Sub frmMain_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs)             Handles MyBase.MouseDown
        'Don't drag the sceen if it is the right button or the wheel.

        If e.Button = MouseButtons.Left Then

            ReleaseCapture()

            SendMessage(Me.Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0)

        End If

    End Sub



Quote:


> > In VB6 I created a form that could be moved by clicking anywhere on the
from
> > and dragging it.  it used the releaseCapture API and send message API. I
am
> > unable to replicate this in vb.net.

> > can anyone help me.
> > I think it has to do with the handle returned from the form in .net. I
> > Converted it to me.handle.ToInt32. and sent it to send message.

> Handle is an IntPtr and your SendMessage API should use an IntPtr as the
> first argument.

> See this thread too:

> http://groups.google.com/groups?selm=711e9158.0202060929.5268842a%
> 40posting.google.com

> If you still have problems, please post your definition of the API
> declares.

> --
> Patrick Steele
> Microsoft .NET MVP



Tue, 12 Oct 2004 21:22:56 GMT  
 releaseCapture API and send message API.
Hi there...

 Made the changes but it still does not work.... below is a simple sample
 project

 Option Explicit

 Private Declare Function ReleaseCapture Lib "user32" () As Long
 Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
 (ByVal hwnd As IntPtr, ByVal wMsg As Long, ByVal wParam As Long, ByVal
 lParam As Long) As Long

     'used to drag a form around that has no title bar
     Private Const WM_NCLBUTTONDOWN = &HA1

     'Used with indicate that the drag is In a title bar.
     Private Const HTCAPTION = 2

       Private Sub frmMain_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs)             Handles MyBase.MouseDown

         'Don't drag the sceen if it is the right button or the wheel.

         If e.Button = MouseButtons.Left Then

             ReleaseCapture()

             SendMessage(Me.Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0)

         End If

     End Sub

Quote:




> > > In VB6 I created a form that could be moved by clicking anywhere on
the
> from
> > > and dragging it.  it used the releaseCapture API and send message API.
I
> am
> > > unable to replicate this in vb.net.

> > > can anyone help me.
> > > I think it has to do with the handle returned from the form in .net. I
> > > Converted it to me.handle.ToInt32. and sent it to send message.

> > Handle is an IntPtr and your SendMessage API should use an IntPtr as the
> > first argument.

> > See this thread too:

> > http://groups.google.com/groups?selm=711e9158.0202060929.5268842a%
> > 40posting.google.com

> > If you still have problems, please post your definition of the API
> > declares.

> > --
> > Patrick Steele
> > Microsoft .NET MVP



Tue, 12 Oct 2004 21:26:47 GMT  
 releaseCapture API and send message API.
 Hi there...

  Made the changes but it still does not work.... below is a simple sample
  project

  Option Explicit

  Private Declare Function ReleaseCapture Lib "user32" () As Long
  Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
  (ByVal hwnd As IntPtr, ByVal wMsg As Long, ByVal wParam As Long, ByVal
  lParam As Long) As Long

      'used to drag a form around that has no title bar
      Private Const WM_NCLBUTTONDOWN = &HA1

      'Used with indicate that the drag is In a title bar.
      Private Const HTCAPTION = 2

        Private Sub frmMain_MouseDown(ByVal sender As Object, ByVal e As
 System.Windows.Forms.MouseEventArgs)             Handles MyBase.MouseDown

          'Don't drag the sceen if it is the right button or the wheel.

          If e.Button = MouseButtons.Left Then

              ReleaseCapture()

              SendMessage(Me.Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0)

          End If

      End Sub




JWCPRITCHARD

 > > > In VB6 I created a form that could be moved by clicking anywhere on
 the
 > from
 > > > and dragging it.  it used the releaseCapture API and send message
API.
 I
 > am
 > > > unable to replicate this in vb.net.
 > > >
 > > > can anyone help me.
 > > > I think it has to do with the handle returned from the form in .net.
I
 > > > Converted it to me.handle.ToInt32. and sent it to send message.
 > >
 > > Handle is an IntPtr and your SendMessage API should use an IntPtr as
the
 > > first argument.
 > >
 > > See this thread too:
 > >
 > > http://groups.google.com/groups?selm=711e9158.0202060929.5268842a%
 > > 40posting.google.com
 > >
 > > If you still have problems, please post your definition of the API
 > > declares.
 > > --
 > > Patrick Steele
 > > Microsoft .NET MVP
 >



Tue, 12 Oct 2004 21:30:13 GMT  
 releaseCapture API and send message API.


Quote:
> Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
> (ByVal hwnd As IntPtr, ByVal wMsg As Long, ByVal wParam As Long, ByVal
> lParam As Long) As Long

In VB.NET, use the "Integer" datatype to represent a 4-byte value, not a
Long (VB6 defined a 4-byte value as a Long).  Change your SendMessage
API declare to use Integer instead of Long and you should be all set.

--
Patrick Steele
Microsoft .NET MVP



Sat, 16 Oct 2004 00:45:15 GMT  
 releaseCapture API and send message API.
works like a charm



Quote:


> > Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
> > (ByVal hwnd As IntPtr, ByVal wMsg As Long, ByVal wParam As Long, ByVal
> > lParam As Long) As Long

> In VB.NET, use the "Integer" datatype to represent a 4-byte value, not a
> Long (VB6 defined a 4-byte value as a Long).  Change your SendMessage
> API declare to use Integer instead of Long and you should be all set.

> --
> Patrick Steele
> Microsoft .NET MVP



Sat, 16 Oct 2004 01:24:04 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. need help with releaseCapture API and send message API

2. the releaseCapture API and send message

3. Send a message (comparable to net send) using NetBIOS API

4. Send a message (comparable to net send) using NetBIOS API

5. SetCapture and ReleaseCapture API

6. API SEND MESSAGE ---> to another application

7. API for sending and receiving SMS messages via GSM modem

8. Send Message API?

9. API for sending and receiving SMS messages via GSM modem

10. send message api

11. How to use API to send message to another app from vb

12. API call send messages between Two window appications

 

 
Powered by phpBB® Forum Software