人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當前位置:蘿卜系統下載站 > 技術開發教程 > 詳細頁面

.net中PictureBox中圖片的拖動

.net中PictureBox中圖片的拖動

更新時間:2022-09-07 文章作者:未知 信息來源:網絡 閱讀次數:

.net中PictureBox中圖片的拖動
首先在Form窗體上放一個PictureBox,并指定一個圖片顯示

定義一系列變量處理圖片拖動
 '處理圖片拖動
        Private m_Leftx As Integer
        Private m_Lefty As Integer
        Dim m_MousePosX As Integer
        Dim m_MousePosY As Integer
        Dim m_DriftX As Integer
        Dim m_DriftY As Integer
并給賦初值,可以在Form初始化時做
  Me.m_Leftx = Me.PictureBox1.Location.X
        Me.m_Lefty = Me.PictureBox1.Location.Y

定義處理鼠標按下的事件

 '當鼠標按下時,將鼠標變成手形,并且記錄下當前鼠標的位置
  Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown

            Me.Cursor = System.Windows.Forms.Cursors.Hand
            m_MousePosX = e.X
            m_MousePosY = e.Y

        End Sub
定義處理鼠標抬起的事件
 '處理鼠標按鍵抬起的事件,根據鼠標按下時保存的鼠標位置,和當前鼠標的位置,計算鼠標移動偏移量,借此調用移動圖片的函數,移動圖片
        Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
          
            m_DriftX = m_MousePosX - e.X
            m_DriftY = m_MousePosY - e.Y
         
            m_Leftx = m_Leftx - m_DriftX
            m_Lefty = m_Lefty - m_DriftY
          
            picturemove(sender, e)
            Me.Cursor = System.Windows.Forms.Cursors.Arrow

        End Sub


 '根據偏移量計算出的圖片位置,重畫圖片
        Private Sub picturemove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
            Dim myBit As New System.Drawing.Bitmap(PictureBox1.Image)

            Dim myPicGrh As System.Drawing.Graphics = Me.PictureBox1.CreateGraphics
            myPicGrh.Clear(Me.PictureBox1.BackColor)
           
            myPicGrh.DrawImageUnscaled(myBit, m_Leftx - 152, m_Lefty)

            myBit.Dispose()
            myPicGrh.Dispose()


        End Sub


溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

網站地圖xml | 網站地圖html
主站蜘蛛池模板: 五家渠市| 伊川县| 阜宁县| 七台河市| 海安县| 茌平县| 东丰县| 彝良县| 交口县| 黄浦区| 永城市| 芦山县| 大悟县| 天门市| 金堂县| 汝州市| 霍城县| 丰顺县| 南靖县| 临猗县| 库尔勒市| 哈巴河县| 颍上县| 抚顺市| 延长县| 阿城市| 宝坻区| 天等县| 临西县| 当涂县| 祥云县| 额济纳旗| 平原县| 武城县| 九龙城区| 应用必备| 清镇市| 乐安县| 平武县| 通城县| 闽侯县|