[VB] Form verschieben Formboarderstyle = None

03/05/2012 14:09 .Mars#1
Wie lautet der code zum verschieben einer Form,
wenn Formboarderstyle = None ist?
Habe eine Imagebox als Form, da meine Form transparent ist.
Kennt jemand den Code? Es ist auf jedenfall nicht der
gleiche, wie als wenn man einfach nur formboarderstyle auf "none" setzt.
03/05/2012 14:38 Al Kappaccino#2
Vielleicht mal Google usen?

Code:
Dim Point As New System.Drawing.Point()
Dim X, Y As Integer

    Private Sub Main_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
        If e.Button = MouseButtons.Left Then
            Point = Control.MousePosition
            Point.X = Point.X - (X)
            Point.Y = Point.Y - (Y)
            Me.Location = Point
        End If
    End Sub


    Private Sub Main_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
        X = Control.MousePosition.X - Me.Location.X
        Y = Control.MousePosition.Y - Me.Location.Y
    End Sub
03/05/2012 14:57 .Mars#3
Nein, der Code geht nicht.
03/05/2012 15:04 Al Kappaccino#4
Natürlich tut er das...
03/05/2012 15:05 .Mars#5
Nein, bei mir nicht.
03/05/2012 15:09 Al Kappaccino#6
Weis ja nicht was du falsch machst, aber ich kann den Code einfach C&P'en und er funzt direkt <.<

Btw. Schreibt er das auch in den Eventhanlder der Form rein? Wenn nicht, wie wäre es mit manuel eintragen ;o

Edit: Sehe gerade erst, dassu ja anscheinend eine PictureBox über die ganze Form gelegt hast und nicht einfach nur das Backgroundimage verändert hast, in dem Fall muss der Code natürlich in das Event von der PictureBox, weil sonst die Mausbefehle gar nicht ankommen <.<
03/05/2012 15:15 .Mars#7
Hab dich mal skype geaddet (:
03/05/2012 18:01 Kraizy​#8
Nicht mal C&P-Codes kann man heutzutage anwenden..
03/05/2012 18:14 .Mars#9
Lol.
Ich habe es ganz anders gemacht, du hast keine Ahnung xKraizy ;D
Habe es aber jetzt.
03/06/2012 09:42 .Yuzuru#10
I don't understand clearly.
Do you need a code moving the form with the noborder style?
03/06/2012 10:27 Al Kappaccino#11
Quote:
Originally Posted by .Yuzuru View Post
I don't understand clearly.
Do you need a code moving the form with the noborder style?
Yeah, because as u might know, the windowform can't be moved directly with the mouse while there is no WindowStyle. But his problem is solved ;)
03/07/2012 22:50 vdd#12
Funktioniert 100%ig

PHP Code:
    Private Sub Label1_MouseDown(ByVal sender As ObjectByVal e As System.Windows.Forms.MouseEventArgsHandles Label1.MouseDown
        
If (e.Button Windows.Forms.MouseButtons.LeftThen
            Label1
.Capture False
            Me
.WndProc(Message.Create(Me.Handle, &HA1CType(&H2IntPtr), IntPtr.Zero))


        Else : 
End If
    
End Sub 
Besser wäre es wenn du statt einem Label ein Panel nimmst:

PHP Code:
    Private Sub Panel1_MouseDown(ByVal sender As ObjectByVal e As System.Windows.Forms.MouseEventArgsHandles Panel1.MouseDown
        
If (e.Button Windows.Forms.MouseButtons.LeftThen
            Panel1
.Capture False
            Me
.WndProc(Message.Create(Me.Handle, &HA1CType(&H2IntPtr), IntPtr.Zero))


        Else : 
End If
    
End Sub