Wątek przeniesiony 2015-10-20 16:50 z C# i .NET przez Ktos.

tłumaczenie małego kodu z C# na VB - przesuwanie formatki

0
Boolean isMoving = false;
Point offset = new Point ();
private void Form1_MouseDown (object sender, MouseEventArgs e)
{
    isMoving = true;
    offset = new Point (Cursor.Position.X - this.Location.X, Cursor.Position.Y - this.Location.Y);
}
private void Form1_MouseUp (object sender, MouseEventArgs e)
{
    isMoving = false;
}
private void Form1_MouseMove (object sender, MouseEventArgs e)
{
    if (isMoving)
        this.Location = new Point (Cursor.Position.X - offset.X, Cursor.Position.Y - offset.Y);
}

czy koś mi to przetłumaczy bo ja nie umiem tego zrobić (albo napisać w kodzie chodzi oto aby forma bez ramki mogła być przesuwana po pulpicie bo normalnie wraz z utratą ramki traci właściwość) Z góry dzięki za pomoc

1

To nie jest C++, ale raczej C#. Temat poprawiłem.

Public Class Form1
    Private isMoving As Boolean
    Private offset As Point

    Private Sub Form1_MouseDown(sender As Object, e As MouseEventArgs) Handles MyBase.MouseDown
        isMoving = True
        offset = New Point(Cursor.Position.X - Location.X, Cursor.Position.Y - Location.Y)
    End Sub

    Private Sub Form1_MouseUp(sender As Object, e As MouseEventArgs) Handles MyBase.MouseUp
        isMoving = False
    End Sub

    Private Sub Form1_MouseMove(sender As Object, e As MouseEventArgs) Handles MyBase.MouseMove
        If (isMoving) Then
            Location = New Point(Cursor.Position.X - offset.X, Cursor.Position.Y - offset.Y)
        End If
    End Sub
End Class

Napisałem to bez znajomości VB.NET i chyba działa.

0

Dzięki działa i leci najlepsza a tak na poboczu wiesz jak rozszerzać takie okno

1 użytkowników online, w tym zalogowanych: 0, gości: 1