Results 1 to 1 of 1

Thread: Code VB : วิธีการ เคลื่อนย้าย Form ที่ FormBorderStyle = None นะครับ

  1. #1
    Junior Member
    Join Date
    Jul 2010
    Posts
    24


    Code VB : วิธีการ เคลื่อนย้าย Form ที่ FormBorderStyle = None นะครับ

    สังเกตุได้ว่า เมื่อ เราปรับ FormBorderStyle เป็น None แล้วรันโปรแกรมเรียบร้อยแล้ว Form ของเราจะ ไม่สามารถ เคลื่อนย้ายได้ ผมมี Code แก้ ทำให้ Form BorderStyle None สามารถ เคลื่อนย้ายได้ มาฝาก

    Code ที่ผมใช้นะครับ
    Unhidden Content - Enjoy The View!

    ให้ใส่ใว้ใน Public Class Form นะครับ

    Code:
      Private IsFormBeingDragged As Boolean = False
        Private MouseDownX As Integer
        Private MouseDownY As Integer
    
        Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseDown
    
            If e.Button = MouseButtons.Left Then
                IsFormBeingDragged = True
                MouseDownX = e.X
                MouseDownY = e.Y
            End If
        End Sub
    
        Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseUp
    
            If e.Button = MouseButtons.Left Then
                IsFormBeingDragged = False
            End If
        End Sub
    
        Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseMove
    
            If IsFormBeingDragged Then
                Dim temp As Point = New Point()
    
                temp.X = Me.Location.X + (e.X - MouseDownX)
                temp.Y = Me.Location.Y + (e.Y - MouseDownY)
                Me.Location = temp
                temp = Nothing
            End If
        End Sub
    'By SmileSiam
    ลองใช้กันดูนะครับ
    Last edited by SmileSiam; 30-07-2010 at 11:59 AM.

Similar Threads

  1. Replies: 3
    Last Post: 01-08-2010, 10:21 PM
  2. Replies: 2
    Last Post: 01-08-2010, 06:23 PM
  3. Replies: 3
    Last Post: 01-08-2010, 03:05 PM
  4. VB Code Make Transparent [สร้างความโปร่งใสให้กับ Form] # 2
    By CkW in forum แนะความรู้ด้าน Programming ต่างๆ
    Replies: 0
    Last Post: 22-08-2009, 09:43 PM
  5. VB Code Make Transparent [สร้างความโปร่งใสให้กับ Form]
    By CkW in forum แนะความรู้ด้าน Programming ต่างๆ
    Replies: 2
    Last Post: 22-08-2009, 04:49 PM

Members who have read this thread : 0

Actions : (View-Readers)

There are no names to display.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •