明輝手游網(wǎng)中心:是一個免費(fèi)提供流行視頻軟件教程、在線學(xué)習(xí)分享的學(xué)習(xí)平臺!

運(yùn)行時拉伸與移動控件的類

[摘要]Public Class Resize '移動了嗎? Private IsMoving As Boolean = False '控件最后的寬 Private ctrlLastWidth As Integer = 0 '控件最后的高 ...
 

Public Class Resize

    '移動了嗎?

    Private IsMoving As Boolean = False

    '控件最后的寬

    Private ctrlLastWidth As Integer = 0

    '控件最后的高

    Private ctrlLastHeight As Integer = 0

    '控件原來的寬

    Private ctrlWidth As Integer

    '最后的左側(cè)坐標(biāo)

    Private ctrlLastLeft As Integer

    '最后的頂部坐標(biāo)

    Private ctrlLastTop As Integer

    '控件原來的高

    Private ctrlHeight As Integer

    '控件的左側(cè)坐標(biāo)

    Private ctrlLeft As Integer

    '控件的頂部坐標(biāo)

    Private ctrlTop As Integer

    '光標(biāo)的左側(cè)坐標(biāo)

    Private cursorL As Integer

    '光標(biāo)的頂部坐標(biāo)

    Private cursorT As Integer

 

    '

    Private Htap As Integer

    Private Wtap As Integer

 

    Private ctrlIsResizing As Boolean = False

    '控件的大小矩形

    Private ctrlRectangle As System.Drawing.Rectangle = New System.Drawing.Rectangle()

    Private ctrl As Control '操作的控件

    Private frm As Form '控件的父親窗體

    '構(gòu)造函數(shù)

    Public Sub New(ByVal c As Control, ByVal frm As Form)

        ctrl = c

        Me.frm = frm

        '標(biāo)題欄和橫向滾動條以及邊框的寬

        Me.Htap = Me.frm.Height - Me.frm.ClientRectangle.Height

        '縱向滾動條和邊框的寬

        Me.Wtap = Me.frm.Width - Me.frm.ClientRectangle.Width

        AddHandler ctrl.MouseDown, AddressOf MouseDown

        AddHandler ctrl.MouseMove, AddressOf MouseMove

        AddHandler ctrl.MouseUp, AddressOf MouseUp

    End Sub

 

    '鼠標(biāo)按下后的處理

    Private Sub MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)

        If frm Is Nothing Then

            Return

        End If

        MessageBox.Show(e.Y.ToString)

        MessageBox.Show((Me.ctrl.Height - 10).ToString)

        MessageBox.Show(e.X.ToString)

        MessageBox.Show((Me.ctrl.Width - 10).ToString)

        '設(shè)置第一次有效單擊的范圍

        If e.X < Me.ctrl.Width - 10 OrElse e.Y < Me.ctrl.Height - 10 Then

            Me.IsMoving = True

            '指定要繪制的虛線框的坐標(biāo)(相對屏幕)

            Me.ctrlLeft = Me.frm.DesktopLocation.X + Me.Wtap + Me.ctrl.Left

            Me.ctrlTop = Me.frm.DesktopLocation.Y + Me.Htap + Me.ctrl.Top


[1] [2] [3]  下一頁