تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
تحريك الادوات بالفأرة على النموذج وقت التشغيل
#1
كاتب الموضوع : Ahmed_online



السلام عليكم ورحمة الله وبركاته


=======================




هذه اكواد تمكنك من تحريك الادوات بالفأرة على النموذج وقت التشغيل كأنك تحركها فى وقت التصميم



أولا : للأمانة هذه الاكواد ليست من تصميمي وانما هى منقولة من احد المواقع

ثانيا : قم بانشاء مشروع جديد من النوع Windows Application وضع عليه Button

ثالثا : قم بأضافة Class وسمها ClsCapture

ثالثا : الصق داخل هذه الفئة الاكواد التالية



كود :
[color=#000000][COLOR=#0000bb][/color][COLOR=#ff8000]#Region "Global Vars"

    [/COLOR][color=#0000bb]Dim WithEvents dad [/color][color=#007700]As [/color][COLOR=#0000bb]Form
    Dim WithEvents dd [/COLOR][color=#007700]As [/color][COLOR=#0000bb]Control
    Dim WithEvents Btn_exit [/COLOR][color=#007700]As New [/color][COLOR=#0000bb]Button
    Dim WithEvents Btn_Min [/COLOR][color=#007700]As New [/color][COLOR=#0000bb]Button
    Dim bCaptureMe [/COLOR][color=#007700]As [/color][COLOR=#0000bb]Boolean
    Dim pLocation [/COLOR][color=#007700]As New [/color][COLOR=#0000bb]Point

[/COLOR][COLOR=#ff8000]#End Region

    [/COLOR][color=#007700]Private [/color][color=#0000bb]Sub Form1_MouseDown[/color][color=#007700]([/color][color=#0000bb]ByVal sender [/color][color=#007700]As [/color][color=#0000bb]Object[/color][color=#007700], [/color][color=#0000bb]ByVal e [/color][color=#007700]As [/color][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]Windows[/color][color=#007700].[/color][color=#0000bb]Forms[/color][color=#007700].[/color][color=#0000bb]MouseEventArgs[/color][color=#007700]) [/color][COLOR=#dd0000]'Handles dad.MouseDown, dd.MouseDown
        Try
            bCaptureMe = True
            pLocation = e.Location
            sender.BringToFront()
        Catch
        End Try
    End Sub

    Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) '[/COLOR][color=#0000bb]Handles dad[/color][color=#007700].[/color][color=#0000bb]MouseMove[/color][color=#007700], [/color][color=#0000bb]dd[/color][color=#007700].[/color][COLOR=#0000bb]MouseMove
        [/COLOR][COLOR=#007700]Try
            If [/COLOR][COLOR=#0000bb]bCaptureMe Then
                [/COLOR][color=#007700]If [/color][color=#0000bb]dd Is Nothing AndAlso dad[/color][color=#007700].[/color][color=#0000bb]Cursor [/color][color=#007700]<> [/color][color=#0000bb]Cursors[/color][color=#007700].[/color][COLOR=#0000bb]SizeNESW _
                AndAlso dad[/COLOR][color=#007700].[/color][color=#0000bb]Cursor [/color][color=#007700]<> [/color][color=#0000bb]Cursors[/color][color=#007700].[/color][COLOR=#0000bb]SizeNWSE _
                AndAlso dad[/COLOR][color=#007700].[/color][color=#0000bb]Cursor [/color][color=#007700]<> [/color][color=#0000bb]Cursors[/color][color=#007700].[/color][COLOR=#0000bb]SizeNS _
                AndAlso dad[/COLOR][color=#007700].[/color][color=#0000bb]Cursor [/color][color=#007700]<> [/color][color=#0000bb]Cursors[/color][color=#007700].[/color][COLOR=#0000bb]SizeWE Then
                    dad[/COLOR][color=#007700].[/color][color=#0000bb]Location [/color][color=#007700]= New [/color][color=#0000bb]Point[/color][color=#007700]([/color][color=#0000bb]dad[/color][color=#007700].[/color][color=#0000bb]Location[/color][color=#007700].[/color][color=#0000bb]X [/color][color=#007700]- [/color][color=#0000bb]pLocation[/color][color=#007700].[/color][color=#0000bb]X [/color][color=#007700]+ [/color][color=#0000bb]e[/color][color=#007700].[/color][color=#0000bb]X[/color][color=#007700], [/color][color=#0000bb]dad[/color][color=#007700].[/color][color=#0000bb]Location[/color][color=#007700].[/color][color=#0000bb]Y [/color][color=#007700]- [/color][color=#0000bb]pLocation[/color][color=#007700].[/color][color=#0000bb]Y [/color][color=#007700]+ [/color][color=#0000bb]e[/color][color=#007700].[/color][color=#0000bb]Y[/color][COLOR=#007700])

                ElseIf [/COLOR][color=#0000bb]dd[/color][color=#007700].[/color][color=#0000bb]Cursor [/color][color=#007700]<> [/color][color=#0000bb]Cursors[/color][color=#007700].[/color][COLOR=#0000bb]SizeNESW _
                AndAlso dd[/COLOR][color=#007700].[/color][color=#0000bb]Cursor [/color][color=#007700]<> [/color][color=#0000bb]Cursors[/color][color=#007700].[/color][COLOR=#0000bb]SizeNWSE _
                AndAlso dd[/COLOR][color=#007700].[/color][color=#0000bb]Cursor [/color][color=#007700]<> [/color][color=#0000bb]Cursors[/color][color=#007700].[/color][COLOR=#0000bb]SizeNS _
                AndAlso dd[/COLOR][color=#007700].[/color][color=#0000bb]Cursor [/color][color=#007700]<> [/color][color=#0000bb]Cursors[/color][color=#007700].[/color][COLOR=#0000bb]SizeWE Then
                    dd[/COLOR][color=#007700].[/color][color=#0000bb]Location [/color][color=#007700]= New [/color][color=#0000bb]Point[/color][color=#007700]([/color][color=#0000bb]dd[/color][color=#007700].[/color][color=#0000bb]Location[/color][color=#007700].[/color][color=#0000bb]X [/color][color=#007700]- [/color][color=#0000bb]pLocation[/color][color=#007700].[/color][color=#0000bb]X [/color][color=#007700]+ [/color][color=#0000bb]e[/color][color=#007700].[/color][color=#0000bb]X[/color][color=#007700], [/color][color=#0000bb]dd[/color][color=#007700].[/color][color=#0000bb]Location[/color][color=#007700].[/color][color=#0000bb]Y [/color][color=#007700]- [/color][color=#0000bb]pLocation[/color][color=#007700].[/color][color=#0000bb]Y [/color][color=#007700]+ [/color][color=#0000bb]e[/color][color=#007700].[/color][color=#0000bb]Y[/color][COLOR=#007700])
                [/COLOR][color=#0000bb]End [/color][COLOR=#007700]If

            [/COLOR][color=#0000bb]End [/color][COLOR=#007700]If
        Catch
        [/COLOR][color=#0000bb]End [/color][COLOR=#007700]Try
    [/COLOR][COLOR=#0000bb]End Sub

    [/COLOR][color=#007700]Private [/color][color=#0000bb]Sub Form1_MouseUp[/color][color=#007700]([/color][color=#0000bb]ByVal sender [/color][color=#007700]As [/color][color=#0000bb]Object[/color][color=#007700], [/color][color=#0000bb]ByVal e [/color][color=#007700]As [/color][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]Windows[/color][color=#007700].[/color][color=#0000bb]Forms[/color][color=#007700].[/color][color=#0000bb]MouseEventArgs[/color][color=#007700]) [/color][color=#0000bb]Handles dad[/color][color=#007700].[/color][color=#0000bb]MouseUp[/color][color=#007700], [/color][color=#0000bb]dd[/color][color=#007700].[/color][COLOR=#0000bb]MouseUp
        [/COLOR][COLOR=#007700]Try
            [/COLOR][color=#0000bb]bCaptureMe [/color][color=#007700]= [/color][COLOR=#0000bb]False
        [/COLOR][COLOR=#007700]Catch
        [/COLOR][color=#0000bb]End [/color][COLOR=#007700]Try
    [/COLOR][COLOR=#0000bb]End Sub

    [/COLOR][color=#007700]Public [/color][color=#0000bb]Sub [/color][color=#007700]New([/color][color=#0000bb]ByVal Frm [/color][color=#007700]As [/color][color=#0000bb]Form[/color][color=#007700], [/color][color=#0000bb]ByVal MakeRound [/color][color=#007700]As [/color][color=#0000bb]Boolean[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]dad [/color][color=#007700]= [/color][COLOR=#0000bb]Frm
        [/COLOR][color=#007700]If [/color][COLOR=#0000bb]MakeRound Then
            RoundShape[/COLOR][COLOR=#007700]()
            [/COLOR][color=#0000bb]AddHandler Btn_exit[/color][color=#007700].[/color][color=#0000bb]Click[/color][color=#007700], [/color][COLOR=#0000bb]AddressOf Close_Click
            AddHandler Btn_Min[/COLOR][color=#007700].[/color][color=#0000bb]Click[/color][color=#007700], [/color][COLOR=#0000bb]AddressOf Min_Click
        End [/COLOR][COLOR=#007700]If
        [/COLOR][color=#0000bb]AddHandler dad[/color][color=#007700].[/color][color=#0000bb]MouseDown[/color][color=#007700], [/color][COLOR=#0000bb]AddressOf Form1_MouseDown
        AddHandler dad[/COLOR][color=#007700].[/color][color=#0000bb]MouseUp[/color][color=#007700], [/color][COLOR=#0000bb]AddressOf Form1_MouseUp
        AddHandler dad[/COLOR][color=#007700].[/color][color=#0000bb]MouseMove[/color][color=#007700], [/color][COLOR=#0000bb]AddressOf Form1_MouseMove
    End Sub

    [/COLOR][color=#007700]Public [/color][color=#0000bb]Sub [/color][color=#007700]New([/color][color=#0000bb]ByVal pnl [/color][color=#007700]As [/color][color=#0000bb]Control[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]dd [/color][color=#007700]= [/color][COLOR=#0000bb]pnl
        AddHandler dd[/COLOR][color=#007700].[/color][color=#0000bb]MouseDown[/color][color=#007700], [/color][COLOR=#0000bb]AddressOf Form1_MouseDown
        AddHandler dd[/COLOR][color=#007700].[/color][color=#0000bb]MouseUp[/color][color=#007700], [/color][COLOR=#0000bb]AddressOf Form1_MouseUp
        AddHandler dd[/COLOR][color=#007700].[/color][color=#0000bb]MouseMove[/color][color=#007700], [/color][COLOR=#0000bb]AddressOf Form1_MouseMove
    End Sub

    [/COLOR][color=#007700]Public [/color][color=#0000bb]Sub RoundShape[/color][COLOR=#007700]()
        Try
            [/COLOR][color=#0000bb]dad[/color][color=#007700].[/color][color=#0000bb]FormBorderStyle [/color][color=#007700]= [/color][color=#0000bb]FormBorderStyle[/color][color=#007700].[/color][COLOR=#0000bb]None
            Dim gr [/COLOR][color=#007700]= New [/color][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]Drawing[/color][color=#007700].[/color][color=#0000bb]Drawing2D[/color][color=#007700].[/color][color=#0000bb]GraphicsPath[/color][COLOR=#007700]()
            [/COLOR][color=#0000bb]gr[/color][color=#007700].[/color][color=#0000bb]AddPie[/color][color=#007700]([/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]40[/color][color=#007700], [/color][color=#0000bb]40[/color][color=#007700], [/color][color=#0000bb]180[/color][color=#007700], [/color][color=#0000bb]90[/color][COLOR=#007700])
            [/COLOR][color=#0000bb]gr[/color][color=#007700].[/color][color=#0000bb]AddPie[/color][color=#007700]([/color][color=#0000bb]dad[/color][color=#007700].[/color][color=#0000bb]Width [/color][color=#007700]- [/color][color=#0000bb]40[/color][color=#007700], [/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]40[/color][color=#007700], [/color][color=#0000bb]40[/color][color=#007700], [/color][color=#0000bb]270[/color][color=#007700], [/color][color=#0000bb]90[/color][COLOR=#007700])
            [/COLOR][color=#0000bb]gr[/color][color=#007700].[/color][color=#0000bb]AddPie[/color][color=#007700]([/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]dad[/color][color=#007700].[/color][color=#0000bb]Height [/color][color=#007700]- [/color][color=#0000bb]40[/color][color=#007700], [/color][color=#0000bb]40[/color][color=#007700], [/color][color=#0000bb]40[/color][color=#007700], [/color][color=#0000bb]90[/color][color=#007700], [/color][color=#0000bb]90[/color][COLOR=#007700])
            [/COLOR][color=#0000bb]gr[/color][color=#007700].[/color][color=#0000bb]AddPie[/color][color=#007700]([/color][color=#0000bb]dad[/color][color=#007700].[/color][color=#0000bb]Width [/color][color=#007700]- [/color][color=#0000bb]40[/color][color=#007700], [/color][color=#0000bb]dad[/color][color=#007700].[/color][color=#0000bb]Height [/color][color=#007700]- [/color][color=#0000bb]40[/color][color=#007700], [/color][color=#0000bb]40[/color][color=#007700], [/color][color=#0000bb]40[/color][color=#007700], [/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]90[/color][COLOR=#007700])

            [/COLOR][color=#0000bb]gr[/color][color=#007700].[/color][color=#0000bb]AddRectangle[/color][color=#007700](New [/color][color=#0000bb]Drawing[/color][color=#007700].[/color][color=#0000bb]Rectangle[/color][color=#007700]([/color][color=#0000bb]20[/color][color=#007700], [/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]dad[/color][color=#007700].[/color][color=#0000bb]Width [/color][color=#007700]- [/color][color=#0000bb]40[/color][color=#007700], [/color][color=#0000bb]dad[/color][color=#007700].[/color][color=#0000bb]Height[/color][COLOR=#007700]))
            [/COLOR][color=#0000bb]gr[/color][color=#007700].[/color][color=#0000bb]AddRectangle[/color][color=#007700](New [/color][color=#0000bb]Drawing[/color][color=#007700].[/color][color=#0000bb]Rectangle[/color][color=#007700]([/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]20[/color][color=#007700], [/color][color=#0000bb]20[/color][color=#007700], [/color][color=#0000bb]dad[/color][color=#007700].[/color][color=#0000bb]Height [/color][color=#007700]- [/color][color=#0000bb]40[/color][COLOR=#007700]))
            [/COLOR][color=#0000bb]gr[/color][color=#007700].[/color][color=#0000bb]AddRectangle[/color][color=#007700](New [/color][color=#0000bb]Drawing[/color][color=#007700].[/color][color=#0000bb]Rectangle[/color][color=#007700]([/color][color=#0000bb]dad[/color][color=#007700].[/color][color=#0000bb]Width [/color][color=#007700]- [/color][color=#0000bb]20[/color][color=#007700], [/color][color=#0000bb]20[/color][color=#007700], [/color][color=#0000bb]20[/color][color=#007700], [/color][color=#0000bb]dad[/color][color=#007700].[/color][color=#0000bb]Height [/color][color=#007700]- [/color][color=#0000bb]40[/color][COLOR=#007700]))

            [/COLOR][color=#0000bb]dad[/color][color=#007700].[/color][color=#0000bb]Region [/color][color=#007700]= New [/color][color=#0000bb]Region[/color][color=#007700]([/color][color=#0000bb]gr[/color][COLOR=#007700])


            [/COLOR][color=#0000bb]Btn_exit[/color][color=#007700].[/color][color=#0000bb]Cursor [/color][color=#007700]= [/color][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]Windows[/color][color=#007700].[/color][color=#0000bb]Forms[/color][color=#007700].[/color][color=#0000bb]Cursors[/color][color=#007700].[/color][COLOR=#0000bb]Hand
            Btn_exit[/COLOR][color=#007700].[/color][color=#0000bb]FlatAppearance[/color][color=#007700].[/color][color=#0000bb]BorderSize [/color][color=#007700]= [/color][COLOR=#0000bb]0
            Btn_exit[/COLOR][color=#007700].[/color][color=#0000bb]FlatAppearance[/color][color=#007700].[/color][color=#0000bb]MouseDownBackColor [/color][color=#007700]= [/color][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]Drawing[/color][color=#007700].[/color][color=#0000bb]Color[/color][color=#007700].[/color][color=#0000bb]FromArgb[/color][color=#007700]([/color][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]255[/color][color=#007700], [/color][color=#0000bb]Byte[/color][color=#007700]), [/color][color=#0000bb]Integer[/color][color=#007700]), [/color][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]128[/color][color=#007700], [/color][color=#0000bb]Byte[/color][color=#007700]), [/color][color=#0000bb]Integer[/color][color=#007700]), [/color][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]Byte[/color][color=#007700]), [/color][color=#0000bb]Integer[/color][COLOR=#007700]))
            [/COLOR][color=#0000bb]Btn_exit[/color][color=#007700].[/color][color=#0000bb]FlatAppearance[/color][color=#007700].[/color][color=#0000bb]MouseOverBackColor [/color][color=#007700]= [/color][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]Drawing[/color][color=#007700].[/color][color=#0000bb]Color[/color][color=#007700].[/color][color=#0000bb]FromArgb[/color][color=#007700]([/color][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]192[/color][color=#007700], [/color][color=#0000bb]Byte[/color][color=#007700]), [/color][color=#0000bb]Integer[/color][color=#007700]), [/color][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]64[/color][color=#007700], [/color][color=#0000bb]Byte[/color][color=#007700]), [/color][color=#0000bb]Integer[/color][color=#007700]), [/color][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]Byte[/color][color=#007700]), [/color][color=#0000bb]Integer[/color][COLOR=#007700]))
            [/COLOR][color=#0000bb]Btn_exit[/color][color=#007700].[/color][color=#0000bb]FlatStyle [/color][color=#007700]= [/color][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]Windows[/color][color=#007700].[/color][color=#0000bb]Forms[/color][color=#007700].[/color][color=#0000bb]FlatStyle[/color][color=#007700].[/color][COLOR=#0000bb]Flat
            Btn_exit[/COLOR][color=#007700].[/color][color=#0000bb]Location [/color][color=#007700]= New [/color][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]Drawing[/color][color=#007700].[/color][color=#0000bb]Point[/color][color=#007700]([/color][color=#0000bb]dad[/color][color=#007700].[/color][color=#0000bb]Width [/color][color=#007700]- [/color][color=#0000bb]18[/color][color=#007700], [/color][color=#0000bb]0[/color][COLOR=#007700])
            [/COLOR][color=#0000bb]Btn_exit[/color][color=#007700].[/color][color=#0000bb]Name [/color][color=#007700]= [/color][COLOR=#dd0000]"BtnClose"
            [/COLOR][color=#0000bb]Btn_exit[/color][color=#007700].[/color][color=#0000bb]Size [/color][color=#007700]= New [/color][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]Drawing[/color][color=#007700].[/color][color=#0000bb]Size[/color][color=#007700]([/color][color=#0000bb]18[/color][color=#007700], [/color][color=#0000bb]21[/color][COLOR=#007700])
            [/COLOR][color=#0000bb]Btn_exit[/color][color=#007700].[/color][color=#0000bb]TabIndex [/color][color=#007700]= [/color][COLOR=#0000bb]6
            Btn_exit[/COLOR][color=#007700].[/color][color=#0000bb]Text [/color][color=#007700]= [/color][COLOR=#dd0000]"X"
            [/COLOR][color=#0000bb]Btn_exit[/color][color=#007700].[/color][color=#0000bb]UseVisualStyleBackColor [/color][color=#007700]= [/color][COLOR=#0000bb]True
            Btn_exit[/COLOR][color=#007700].[/color][color=#0000bb]BringToFront[/color][COLOR=#007700]()

            [/COLOR][color=#0000bb]Btn_Min[/color][color=#007700].[/color][color=#0000bb]Cursor [/color][color=#007700]= [/color][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]Windows[/color][color=#007700].[/color][color=#0000bb]Forms[/color][color=#007700].[/color][color=#0000bb]Cursors[/color][color=#007700].[/color][COLOR=#0000bb]Hand
            Btn_Min[/COLOR][color=#007700].[/color][color=#0000bb]FlatAppearance[/color][color=#007700].[/color][color=#0000bb]BorderSize [/color][color=#007700]= [/color][COLOR=#0000bb]0
            Btn_Min[/COLOR][color=#007700].[/color][color=#0000bb]FlatAppearance[/color][color=#007700].[/color][color=#0000bb]MouseDownBackColor [/color][color=#007700]= [/color][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]Drawing[/color][color=#007700].[/color][color=#0000bb]Color[/color][color=#007700].[/color][color=#0000bb]FromArgb[/color][color=#007700]([/color][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]255[/color][color=#007700], [/color][color=#0000bb]Byte[/color][color=#007700]), [/color][color=#0000bb]Integer[/color][color=#007700]), [/color][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]128[/color][color=#007700], [/color][color=#0000bb]Byte[/color][color=#007700]), [/color][color=#0000bb]Integer[/color][color=#007700]), [/color][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]Byte[/color][color=#007700]), [/color][color=#0000bb]Integer[/color][COLOR=#007700]))
            [/COLOR][color=#0000bb]Btn_Min[/color][color=#007700].[/color][color=#0000bb]FlatAppearance[/color][color=#007700].[/color][color=#0000bb]MouseOverBackColor [/color][color=#007700]= [/color][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]Drawing[/color][color=#007700].[/color][color=#0000bb]Color[/color][color=#007700].[/color][color=#0000bb]FromArgb[/color][color=#007700]([/color][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]192[/color][color=#007700], [/color][color=#0000bb]Byte[/color][color=#007700]), [/color][color=#0000bb]Integer[/color][color=#007700]), [/color][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]64[/color][color=#007700], [/color][color=#0000bb]Byte[/color][color=#007700]), [/color][color=#0000bb]Integer[/color][color=#007700]), [/color][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]Byte[/color][color=#007700]), [/color][color=#0000bb]Integer[/color][COLOR=#007700]))
            [/COLOR][color=#0000bb]Btn_Min[/color][color=#007700].[/color][color=#0000bb]FlatStyle [/color][color=#007700]= [/color][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]Windows[/color][color=#007700].[/color][color=#0000bb]Forms[/color][color=#007700].[/color][color=#0000bb]FlatStyle[/color][color=#007700].[/color][COLOR=#0000bb]Flat
            Btn_Min[/COLOR][color=#007700].[/color][color=#0000bb]Location [/color][color=#007700]= New [/color][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]Drawing[/color][color=#007700].[/color][color=#0000bb]Point[/color][color=#007700]([/color][color=#0000bb]dad[/color][color=#007700].[/color][color=#0000bb]Width [/color][color=#007700]- [/color][color=#0000bb]36[/color][color=#007700], [/color][color=#0000bb]0[/color][COLOR=#007700])
            [/COLOR][color=#0000bb]Btn_Min[/color][color=#007700].[/color][color=#0000bb]Name [/color][color=#007700]= [/color][COLOR=#dd0000]"BtnClose"
            [/COLOR][color=#0000bb]Btn_Min[/color][color=#007700].[/color][color=#0000bb]Size [/color][color=#007700]= New [/color][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]Drawing[/color][color=#007700].[/color][color=#0000bb]Size[/color][color=#007700]([/color][color=#0000bb]18[/color][color=#007700], [/color][color=#0000bb]21[/color][COLOR=#007700])
            [/COLOR][color=#0000bb]Btn_Min[/color][color=#007700].[/color][color=#0000bb]TabIndex [/color][color=#007700]= [/color][COLOR=#0000bb]6
            Btn_Min[/COLOR][color=#007700].[/color][color=#0000bb]Text [/color][color=#007700]= [/color][COLOR=#dd0000]"_"
            [/COLOR][color=#0000bb]Btn_Min[/color][color=#007700].[/color][color=#0000bb]UseVisualStyleBackColor [/color][color=#007700]= [/color][COLOR=#0000bb]True
            Btn_Min[/COLOR][color=#007700].[/color][color=#0000bb]BringToFront[/color][COLOR=#007700]()

            [/COLOR][color=#0000bb]dad[/color][color=#007700].[/color][color=#0000bb]Controls[/color][color=#007700].[/color][color=#0000bb]Add[/color][color=#007700]([/color][color=#0000bb]Btn_exit[/color][COLOR=#007700])
            [/COLOR][color=#0000bb]dad[/color][color=#007700].[/color][color=#0000bb]Controls[/color][color=#007700].[/color][color=#0000bb]Add[/color][color=#007700]([/color][color=#0000bb]Btn_Min[/color][COLOR=#007700])
        Catch
        [/COLOR][color=#0000bb]End [/color][COLOR=#007700]Try
    [/COLOR][COLOR=#0000bb]End Sub

    [/COLOR][color=#007700]Private [/color][color=#0000bb]Sub Close_Click[/color][color=#007700]([/color][color=#0000bb]ByVal sender [/color][color=#007700]As [/color][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]Object[/color][color=#007700], [/color][color=#0000bb]ByVal e [/color][color=#007700]As [/color][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]EventArgs[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]sender[/color][color=#007700], [/color][color=#0000bb]Button[/color][color=#007700]).[/color][color=#0000bb]FindForm[/color][color=#007700].[/color][color=#0000bb]Close[/color][COLOR=#007700]()
    [/COLOR][COLOR=#0000bb]End Sub

    [/COLOR][color=#007700]Private [/color][color=#0000bb]Sub Min_Click[/color][color=#007700]([/color][color=#0000bb]ByVal sender [/color][color=#007700]As [/color][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]Object[/color][color=#007700], [/color][color=#0000bb]ByVal e [/color][color=#007700]As [/color][color=#0000bb]System[/color][color=#007700].[/color][color=#0000bb]EventArgs[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]CType[/color][color=#007700]([/color][color=#0000bb]sender[/color][color=#007700], [/color][color=#0000bb]Button[/color][color=#007700]).[/color][color=#0000bb]FindForm[/color][color=#007700].[/color][color=#0000bb]WindowState [/color][color=#007700]= [/color][color=#0000bb]FormWindowState[/color][color=#007700].[/color][COLOR=#0000bb]Minimized
    End Sub

    [/COLOR][color=#007700]Public [/color][color=#0000bb]Shared Sub CaptureAllCtrls[/color][color=#007700]([/color][color=#0000bb]ByVal fr [/color][color=#007700]As [/color][color=#0000bb]Control[/color][COLOR=#007700])
        For [/COLOR][color=#0000bb]Each cnt [/color][color=#007700]As [/color][color=#0000bb]Control In fr[/color][color=#007700].[/color][COLOR=#0000bb]Controls
            [/COLOR][color=#007700]If [/color][COLOR=#0000bb]TypeOf cnt Is Panel Then
                CaptureAllCtrls[/COLOR][color=#007700]([/color][color=#0000bb]cnt[/color][COLOR=#007700])
            Else
                [/COLOR][color=#0000bb]ClsCapture[/color][color=#007700].[/color][color=#0000bb]CaptureMe[/color][color=#007700]([/color][color=#0000bb]cnt[/color][COLOR=#007700])
            [/COLOR][color=#0000bb]End [/color][COLOR=#007700]If
        [/COLOR][COLOR=#0000bb]Next
    End Sub

    [/COLOR][color=#007700]Public [/color][color=#0000bb]Shared Sub CaptureMe[/color][color=#007700]([/color][color=#0000bb]ByVal frm [/color][color=#007700]As [/color][color=#0000bb]Form[/color][color=#007700], [/color][color=#0000bb]Optional ByVal MakeMeRound [/color][color=#007700]As [/color][color=#0000bb]Boolean [/color][color=#007700]= [/color][color=#0000bb]False[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]Dim cc [/color][color=#007700]As New [/color][color=#0000bb]ClsCapture[/color][color=#007700]([/color][color=#0000bb]frm[/color][color=#007700], [/color][color=#0000bb]MakeMeRound[/color][COLOR=#007700])
    [/COLOR][COLOR=#0000bb]End Sub

    [/COLOR][color=#007700]Public [/color][color=#0000bb]Shared Sub CaptureMe[/color][color=#007700]([/color][color=#0000bb]ByVal pnl [/color][color=#007700]As [/color][color=#0000bb]Control[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]Dim cc [/color][color=#007700]As New [/color][color=#0000bb]ClsCapture[/color][color=#007700]([/color][color=#0000bb]pnl[/color][COLOR=#007700])
    [/COLOR][COLOR=#0000bb]End Sub  
[/COLOR][/COLOR]



رابعا : اذهب الى النموذج وفى الحدث Form1_Load اكتب هذا الكود



كود :
[color=#000000][COLOR=#0000bb]ClsCapture[/color][color=#007700].[/color][color=#0000bb]CaptureMe[/color][color=#007700]([/color][color=#0000bb]Button1[/color][COLOR=#007700])  
[/COLOR][color=#0000bb][/color][/COLOR]

خامسا : شغل البرنامج وجرب تحريك الـ Button
}}}}
تم الشكر بواسطة:


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  [VB.NET] تحريك الادوات بالماوس وقت التشغيل Ahmed_online 4 870 26-11-15, 02:28 PM
آخر رد: eldmasy11
  من المنتدى القديم - تحريك الفورم من اي مكان ( للاخ omar2205 ) المبرمج علي نوري 2 734 16-08-15, 05:09 PM
آخر رد: otman_bel
  نبضه 2 - التشغيل العشوائي لملفات صوتيه RaggiTech 0 332 05-10-12, 04:14 AM
آخر رد: RaggiTech
  كيفية تنفيذ عملية في مسار آخر وإظهار النتيجة في التحكمات على النموذج RaggiTech 2 680 05-10-12, 01:45 AM
آخر رد: RaggiTech
  تغيير شكل النموذج لشكل تحدده أنت RaggiTech 0 317 03-10-12, 10:45 AM
آخر رد: RaggiTech
  تعلم أضافة الأدوات على الفورم وقت التشغيل وإضافة أحداث الضغط وما شايه لها RaggiTech 0 425 03-10-12, 09:29 AM
آخر رد: RaggiTech
  تخزين ملف ما ضمن Exe البرنامج أثناء التطوير واستعادته أثناء التشغيل RaggiTech 1 435 03-10-12, 08:14 AM
آخر رد: RaggiTech
  تحريك النافذة وهي في وضعية none ! RaggiTech 0 493 03-10-12, 07:50 AM
آخر رد: RaggiTech
  تحريك الفورم من اى مكان فيها -) RaggiTech 0 1,004 03-10-12, 07:43 AM
آخر رد: RaggiTech
  الدرس الخامس-الادوات في vb.net 2005 (ج 1) RaggiTech 0 1,368 02-10-12, 05:55 PM
آخر رد: RaggiTech

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم