hi chris,
i have used wndproc to get the left mousedown event like this
(copy this code in the form1.vb as it is)
**************
code starts
********************
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Public Class Form1
Inherits System.Windows.Forms.Form
' Constant value was found in the "windows.h" header file.
Private Const WM_LBUTTONDOWN As Integer = &H201
Private Const WM_NCLBUTTONDOWN As Integer = &HA1
<STAThread()> _
Shared Sub Main()
Application.Run(New Form1)
End Sub 'Main
Public Sub New()
MyBase.New()
InitializeComponent()
End Sub
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand,
Name:="FullTrust")> _
Protected Overrides Sub WndProc(ByRef m As Message)
' Listen for operating system messages
Select Case (m.Msg)
Case WM_LBUTTONDOWN
MsgBox(Control.MousePosition.ToString())
Case Else
MyBase.WndProc(m)
End Select
MyBase.WndProc(m)
End Sub
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Button2 As System.Windows.Forms.Button
Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.Button2 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(72, 88)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(72, 32)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Button1"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(56, 160)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(184, 20)
Me.TextBox1.TabIndex = 1
Me.TextBox1.Text = "TextBox1"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(40, 32)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(192, 16)
Me.Label1.TabIndex = 2
Me.Label1.Text = "Label1"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(88, 216)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(88, 24)
Me.Button2.TabIndex = 3
Me.Button2.Text = "Button2"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.ResumeLayout(False)
End Sub
Private Sub Button1_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown
MsgBox("button1_down" & " " & x.ToString & " " & y.ToString)
End Sub
Private Sub Button1_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown
MsgBox("button1_up" & " " & x.ToString & " " & y.ToString)
End Sub
End Class
******************
code ends
***************
the problem with this is that
1) it also working for left mousedown in non-client area which i dont
want and
2) after left mousedown on any control(eg. for button1)
Button1_mousedown() should also get called which is not happening
pl. have a look at it
thanks
sagar