main.vb

来自「Samples are organized by chapter, and th」· VB 代码 · 共 91 行

VB
91
字号
Public Class Main
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
    Friend WithEvents picDrawingArea As System.Windows.Forms.PictureBox

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.Container

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.picDrawingArea = New System.Windows.Forms.PictureBox()
        Me.SuspendLayout()
        '
        'picDrawingArea
        '
        Me.picDrawingArea.Anchor = (((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right)
        Me.picDrawingArea.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.picDrawingArea.Location = New System.Drawing.Point(4, 4)
        Me.picDrawingArea.Name = "picDrawingArea"
        Me.picDrawingArea.Size = New System.Drawing.Size(356, 296)
        Me.picDrawingArea.TabIndex = 0
        Me.picDrawingArea.TabStop = False
        '
        'Main
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(364, 306)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.picDrawingArea})
        Me.Name = "Main"
        Me.Text = "Drawing Area"
        Me.ResumeLayout(False)

    End Sub

#End Region


    Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim frmTool As New ControlPalette()
        Me.AddOwnedForm(frmTool)
        frmTool.Show()
        picDrawingArea.AllowDrop = True
    End Sub



    Private Sub picDrawingArea_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles picDrawingArea.DragDrop

        Dim g As Graphics = picDrawingArea.CreateGraphics
        g.DrawImage(e.Data.GetData(DataFormats.Bitmap), _
          New Point(e.X - Me.Left - 12, e.Y - Me.Top - 30))

    End Sub

    Private Sub picDrawingArea_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles picDrawingArea.DragEnter

        If (e.Data.GetDataPresent(DataFormats.Bitmap)) Then
            e.Effect = DragDropEffects.Copy
        Else
            e.Effect = DragDropEffects.None
        End If

    End Sub

End Class

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?