منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : (تم الحل) تحريك الادوات
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
الصفحات : 1 2
السلام عليكم ورحمة الله وبركاته

هل هناك طريقة لتحريك الادوات

بحيث الضغط على اداة Label ووضعها على اداة Textbox وتجذبها اداة الـ TextBox كلمغنطيس

مع امكانية تحريكها مرة ثانية من فوق الاداة
كل شي ممكن مع فيجوال بيسك
انت اعرف مكان اي اداة وقم بالتحكم بها من خلال مؤقت او bgw
[h=1]مثال التنقل بين صناديق المجموعات ضمن اداة بانل (وكل عام وانتم بخير - اخوكم سعود)[/h]
الف شكر اخي العزيز سعود

لكني لم اقصد هذا بل قصدت عند الضغط على نفس الاداة وتحريكها فوق اداة اخرى

وضعت مثال لذلك
لكن المثال عملته بطريقة اخرى لعدم تمكني من عمل ما اريد
اريد عند تحريك اداة Button فوق اداة TextBox بمجرد دخول اداة Button فوق اداة Textbox يتم وضع
اداة الـ Button فوق اداة Textbox حسب الـ Location لاداة TextBox

شاهد المثال وستعرف قصدي
المثال اضغط على اداة الـ Button سيتغير لونه ثم اضغط على احد مربعات النصوص وشاهد سينتقل الـ Button فوقه مباشرة
لكني اريده بالضغط والافلات فوق التكست بوكس
السلام عليكم،
تم التعديل على الكود ليعمل كما تريد
الكود بعد التعديل:
كود :
Public Class Form1
    Public Const WM_NCLBUTTONDOWN = &HA1
    Public Const HTCAPTION = 2

    Private Sub Button1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown
        If e.Button = Windows.Forms.MouseButtons.Left Then
            Button1.Capture = False
            Dim msg As Message = _
                Message.Create(Button1.Handle, WM_NCLBUTTONDOWN, _
                    New IntPtr(HTCAPTION), IntPtr.Zero)
            Me.DefWndProc(msg)
        End If
        Me.Button1.BackColor = Color.Violet
    End Sub

    Private Sub Button2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button2.MouseDown
        If e.Button = Windows.Forms.MouseButtons.Left Then
            Button2.Capture = False
            Dim msg As Message = _
                Message.Create(Button2.Handle, WM_NCLBUTTONDOWN, _
                    New IntPtr(HTCAPTION), IntPtr.Zero)
            Me.DefWndProc(msg)
        End If

        Me.Button2.BackColor = Color.Violet

    End Sub

    Private Sub Button3_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button3.MouseDown
        If e.Button = Windows.Forms.MouseButtons.Left Then
            Button3.Capture = False
            Dim msg As Message = _
                Message.Create(Button3.Handle, WM_NCLBUTTONDOWN, _
                    New IntPtr(HTCAPTION), IntPtr.Zero)
            Me.DefWndProc(msg)
        End If

        Me.Button3.BackColor = Color.Violet

    End Sub

    Private Sub Button4_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button4.MouseDown
        If e.Button = Windows.Forms.MouseButtons.Left Then
            Button4.Capture = False
            Dim msg As Message = _
                Message.Create(Button4.Handle, WM_NCLBUTTONDOWN, _
                    New IntPtr(HTCAPTION), IntPtr.Zero)
            Me.DefWndProc(msg)
        End If

        Me.Button4.BackColor = Color.Violet

    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

        Me.Button1.Location = New System.Drawing.Point(149, 66)
        Me.Button2.Location = New System.Drawing.Point(12, 66)
        Me.Button3.Location = New System.Drawing.Point(12, 24)
        Me.Button4.Location = New System.Drawing.Point(149, 24)

        Me.Button1.BackColor = Color.Empty
        Me.Button2.BackColor = Color.Empty
        Me.Button3.BackColor = Color.Empty
        Me.Button4.BackColor = Color.Empty

    End Sub

    Private Sub TextBox2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox2.MouseDown
        If Me.Button1.BackColor = Color.Violet Then
            Me.Button1.Location = New System.Drawing.Point(12, 132)
            If Me.Button1.Location = New System.Drawing.Point(12, 132) Then
                Me.Button1.BackColor = Color.Empty
                MsgBox("صح")
                TextBox2.Location = New Point(Button1.Left, Button1.Top - Button1.Height)
            End If
        End If
        If Me.Button2.BackColor = Color.Violet Then
            Me.Button2.Location = New System.Drawing.Point(12, 132)
            If Me.Button2.Location = New System.Drawing.Point(12, 132) Then
                Me.Button2.BackColor = Color.Empty
                MsgBox("خطأ")
                TextBox2.Location = New Point(Button2.Left, Button2.Top - Button2.Height)
            End If
        End If
        If Me.Button3.BackColor = Color.Violet Then
            Me.Button3.Location = New System.Drawing.Point(12, 132)
            If Me.Button3.Location = New System.Drawing.Point(12, 132) Then
                Me.Button3.BackColor = Color.Empty
                MsgBox("خطأ")
                TextBox2.Location = New Point(Button3.Left, Button3.Top - Button3.Height)
            End If
        End If
        If Me.Button4.BackColor = Color.Violet Then
            Me.Button4.Location = New System.Drawing.Point(12, 132)
            If Me.Button4.Location = New System.Drawing.Point(12, 132) Then
                Me.Button4.BackColor = Color.Empty
                MsgBox("خطأ")
                TextBox2.Location = New Point(Button4.Left, Button4.Top - Button4.Height)
            End If
        End If
    End Sub

    Private Sub TextBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseDown
        If Me.Button1.BackColor = Color.Violet Then
            Me.Button1.Location = New System.Drawing.Point(149, 132)
            If Me.Button1.Location = New System.Drawing.Point(149, 132) Then
                Me.Button1.BackColor = Color.Empty
                MsgBox("خطأ")
                TextBox1.Location = New Point(Button1.Left, Button1.Top - Button1.Height)
            End If
        End If
        If Me.Button2.BackColor = Color.Violet Then
            Me.Button2.Location = New System.Drawing.Point(149, 132)
            If Me.Button2.Location = New System.Drawing.Point(149, 132) Then
                Me.Button2.BackColor = Color.Empty
                MsgBox("صح")
                TextBox1.Location = New Point(Button2.Left, Button2.Top - Button2.Height)
            End If
        End If
        If Me.Button3.BackColor = Color.Violet Then
            Me.Button3.Location = New System.Drawing.Point(149, 132)
            If Me.Button3.Location = New System.Drawing.Point(149, 132) Then
                Me.Button3.BackColor = Color.Empty
                MsgBox("خطأ")
                TextBox1.Location = New Point(Button3.Left, Button3.Top - Button3.Height)
            End If
        End If
        If Me.Button4.BackColor = Color.Violet Then
            Me.Button4.Location = New System.Drawing.Point(149, 132)
            If Me.Button4.Location = New System.Drawing.Point(149, 132) Then
                Me.Button4.BackColor = Color.Empty
                MsgBox("خطأ")
                TextBox1.Location = New Point(Button4.Left, Button4.Top - Button4.Height)
            End If
        End If
    End Sub
End Class
نحمده ونصلي على رسوله الكريم
اشكر الجميع على التعاون

لكن ليس هذا ما قصدت تحريك الاداه هذا جميل جداً لكن اريد بعد تحريك الاداة من خلال
السحب ومرورها فوق التكست بمجرد دخولها فوق التكست والافلات يتم لصق الاداة فوق التكست

وطبعاً ابعاد الاداة والتكست متساوية وضحت الفكرة
في مشروع الأخ DreamsDotNet إستبدل الأمر الموجود في Button1_MouseUp بالأمر التالي :
كود :
Private Sub Button1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseUp
        Button1.Cursor = Cursors.Default
        Dim P As Point = (Button1.Location + e.Location)
        If P.X >= TextBox1.Left AndAlso P.X <= TextBox1.Left + TextBox1.Width Then
            If P.Y >= TextBox1.Top AndAlso P.Y <= TextBox1.Top + TextBox1.Height Then
                TextBox1.Controls.Add(Button1)
                Button1.Dock = DockStyle.Fill
            End If
        End If
    End Sub
سلمت يداك هذا هو المطلوب
الف شكر
السلام عليكم ورحمة الله وبركاته

في طلب آخر متعلق بالموضوع بعد وضع الـ Button على TextBox

اريد اخرجه لا استطيع سحبه من فوق الـ TextBox

مع اني استخدمت في Button2 آخر

PHP كود :
Me.Button1.Location = New System.Drawing.Point(139310

ولم ينفع
aftfm كتب :السلام عليكم ورحمة الله وبركاته

في طلب آخر متعلق بالموضوع بعد وضع الـ Button على TextBox

اريد اخرجه لا استطيع سحبه من فوق الـ TextBox

مع اني استخدمت في Button2 آخر

PHP كود :
Me.Button1.Location = New System.Drawing.Point(139310

ولم ينفع

أضف في البداية الأمر التالي :
كود :
Button1.Dock = DockStyle.None
Me.Controls.Add(Button1)
  Me.Button1.Location = New System.Drawing.Point(139, 310)
الصفحات : 1 2