ralan Posted February 26, 2004 Posted February 26, 2004 In VB6 when I wanted to Capture a part of a form, I would do the following: Release Capture lRtn = SendMessage(Me.hwnd, _ WM_NCLBUTTONDOWN,HTCAPTION,0&) This would set the control under the mouse to be Captured like the Caption bar normally is. Thus I could drag a form around by any control I wanted. Does any one know how to do this in VB.NET? I'd rather not call the Win32 API if I can avoid it. Thanks, ralan Quote
Moderators Robby Posted February 26, 2004 Moderators Posted February 26, 2004 The answer's here http://www.xtremedotnettalk.com/showthread.php?threadid=79795&highlight=borderless Quote Visit...Bassic Software
Leaders dynamic_sysop Posted February 26, 2004 Leaders Posted February 26, 2004 i know you say you don't want to use the api way , but i knocked this up for you anyway ( as it's still ok / sometimes necassary to use Api calls in .net / C# ) '/// in your Form... Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown If e.Button = MouseButtons.Left Then _Win32.ReleaseCapture() _Win32.SendMessage(Me.Handle.ToInt32, _Win32.WM_NCLBUTTONDOWN, _Win32.HTCAPTION, 0) End If End Sub '/// seperate Class ... Public Class _Win32 Public Declare Function ReleaseCapture Lib "user32.dll" () As Integer Public Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByRef lParam As Integer) As Integer Public Const WM_NCLBUTTONDOWN As Integer = &HA1 Public Const HTCAPTION As Integer = 2 End Class Quote
ralan Posted February 26, 2004 Author Posted February 26, 2004 Nice! Thanks for the replies. I'm glad to learn more than one way to solve a problem. Adds for flexibility down the road. Again, thanks! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.