📄 frmmain.vb
字号:
Me.AutoScroll = CType(resources.GetObject("$this.AutoScroll"), Boolean)
Me.AutoScrollMargin = CType(resources.GetObject("$this.AutoScrollMargin"), System.Drawing.Size)
Me.AutoScrollMinSize = CType(resources.GetObject("$this.AutoScrollMinSize"), System.Drawing.Size)
Me.BackgroundImage = CType(resources.GetObject("$this.BackgroundImage"), System.Drawing.Image)
Me.ClientSize = CType(resources.GetObject("$this.ClientSize"), System.Drawing.Size)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label4, Me.Label3, Me.picturePaste, Me.Label2, Me.Label1, Me.rtbPaste, Me.txtPaste})
Me.Dock = CType(resources.GetObject("$this.Dock"), System.Windows.Forms.DockStyle)
Me.Enabled = CType(resources.GetObject("$this.Enabled"), Boolean)
Me.Font = CType(resources.GetObject("$this.Font"), System.Drawing.Font)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.ImeMode = CType(resources.GetObject("$this.ImeMode"), System.Windows.Forms.ImeMode)
Me.Location = CType(resources.GetObject("$this.Location"), System.Drawing.Point)
Me.MaximizeBox = False
Me.MaximumSize = CType(resources.GetObject("$this.MaximumSize"), System.Drawing.Size)
Me.Menu = Me.mnuMain
Me.MinimumSize = CType(resources.GetObject("$this.MinimumSize"), System.Drawing.Size)
Me.Name = "frmMain"
Me.RightToLeft = CType(resources.GetObject("$this.RightToLeft"), System.Windows.Forms.RightToLeft)
Me.StartPosition = CType(resources.GetObject("$this.StartPosition"), System.Windows.Forms.FormStartPosition)
Me.Text = resources.GetString("$this.Text")
Me.Visible = CType(resources.GetObject("$this.Visible"), Boolean)
Me.ResumeLayout(False)
End Sub
#End Region
#Region " Standard Menu Code "
' <System.Diagnostics.DebuggerStepThrough()> has been added to some procedures since they are
' not the focus of the demo. Remove them if you wish to debug the procedures.
' This code simply shows the About form.
<System.Diagnostics.DebuggerStepThrough()> Private Sub mnuAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuAbout.Click
' Open the About form in Dialog Mode
Dim frm As New frmAbout()
frm.ShowDialog(Me)
frm.Dispose()
End Sub
' This code will close the form.
<System.Diagnostics.DebuggerStepThrough()> Private Sub mnuExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuExit.Click
' Close the current form
Me.Close()
End Sub
#End Region
' Copy an image of two dogs to the Clipboard as a bitmap.
Private Sub mnuCopyImageAsBitmap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuCopyImageAsBitmap.Click
Dim myDataObject As New DataObject()
myDataObject.SetData(DataFormats.Bitmap, True, myImage)
Clipboard.SetDataObject(myDataObject, True)
End Sub
' Copy "The Clipboard is Cool!" to the Clipboard as all available
' formats. This can only be done by using a DataObject instance.
' The SetData method is called for all formats, along with their
' format name.
Private Sub mnuCopyTextAsAllFormats_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuCopyTextAsAllFormats.Click
Dim myDataObject As New DataObject()
' Place text version in DataObject as text and unicode
myDataObject.SetData(DataFormats.Text, strText)
myDataObject.SetData(DataFormats.UnicodeText, strText)
' Place HTML version in DataObject
myDataObject.SetData(DataFormats.Html, strHTML)
' Place RTF version in DataObject
myDataObject.SetData(DataFormats.Rtf, strRTF)
' Place XML version in DataObject
myDataObject.SetData("MyInternalXmlFormat", strXML)
' Now place myDataObject, and thus all formats on the Clipboard
Clipboard.SetDataObject(myDataObject, True)
End Sub
' Copy "The Clipboard is Cool!" to the Clipboard as HTML.
' Here the HTML is first added to a DataObject so that the proper
' format can be specified.
Private Sub mnuCopyTextAsHTML_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuCopyTextAsHTML.Click
Dim myDataObject As New DataObject()
myDataObject.SetData(DataFormats.Html, strHTML)
Clipboard.SetDataObject(myDataObject, True)
End Sub
' Copy "The Clipboard is Cool!" to the Clipboard as RTF.
' Here the RTF is first added to a DataObject so that the proper
' format can be specified.
Private Sub mnuCopyTextAsRTF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuCopyTextAsRTF.Click
Dim myDataObject As New DataObject()
myDataObject.SetData(DataFormats.Rtf, strRTF)
Clipboard.SetDataObject(myDataObject, True)
End Sub
' Copy "The Clipboard is Cool!" to the Clipboard as text.
' Here the text is simply copied directly to the clipboard.
Private Sub mnuCopyTextAsText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuCopyTextAsText.Click
Clipboard.SetDataObject(strText, True)
End Sub
' Copy "The Clipboard is Cool!" to the Clipboard as XML.
' Here the XML is first added to a DataObject so that the proper
' format can be specified.
' Since XML is not inherently supported by the clipboard (except as
' Unicode Text), this represents a proprietary format. Since this
' format will likely have little meaning outside of this application,
' the second parameter has been set to false, forcing the Clipboard to
' not allow other applications access to this data.
Private Sub mnuCopyTextAsXML_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuCopyTextAsXML.Click
Dim myDataObject As New DataObject()
myDataObject.SetData("MyInternalXmlFormat", strXML)
Clipboard.SetDataObject(myDataObject, False)
End Sub
' MnuEdit_Popup ensures that the when the Edit menu is clicked that
' the Paste As menu item is fully populated with only those formats
' that the Clipboard can support.
Private Sub mnuEdit_Popup(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuEdit.Popup
Dim myPasteAsMenu As MenuItem ' Used to build the Paste As menu
Dim myTypes() As MenuItem ' used to display different formats
Dim strArray() As String ' array of different supported formats
Dim i As Integer ' for loops
' If the Clipboard is not empty, fill strArray with a
' list of all supported formats
If Not (Clipboard.GetDataObject() Is Nothing) Then
' GetFormats() returns a string array with the suppored formats
strArray = Clipboard.GetDataObject().GetFormats()
ReDim myTypes(strArray.Length - 1)
' Create several new MenuItems each using the
' PasteAsMenuEventHandler method as the event handler.
For i = 0 To strArray.Length - 1
myTypes(i) = New MenuItem(strArray(i), AddressOf PasteAsMenuEventHandler)
Next i
End If
' Ensure that the .NET Framework handles showing the menu
Me.mnuEdit.OwnerDraw = False
' Create the Paste As menu, with the available formats
' as sub-menu items.
myPasteAsMenu = New MenuItem("&Paste As", myTypes)
' If it has been added before, delete it.
If mnuEdit.MenuItems.Count = 3 Then
mnuEdit.MenuItems.RemoveAt(2)
End If
' Add the Paste As menu to the Edit menu.
Me.mnuEdit.MenuItems.Add(myPasteAsMenu)
End Sub
' PasteAsMenuEventHandler handles all of the Paste commands, regardless
' of what format was selected. The string name of the format is passed
' as the Text in the sending MenuItem.
Private Sub PasteAsMenuEventHandler(ByVal sender As Object, ByVal e As System.EventArgs)
Dim strType As String ' holds the value of the Format
Dim obj As Object ' used to hold data to be pasted
' Clear all output boxes for this paste
Me.rtbPaste.Clear()
Me.txtPaste.Clear()
Me.picturePaste.Image = Nothing
' Get the user selected format as a string.
strType = CType(sender, MenuItem).Text
' Ensure that the Clipboard can support the selected format
If Clipboard.GetDataObject().GetDataPresent(strType) Then
' Set obj to the data on the clipboard, in the requested format
obj = Clipboard.GetDataObject().GetData(strType)
If Not obj Is Nothing Then
' Paste into the RichTextBox using the Paste() method
Me.rtbPaste.Paste(DataFormats.GetFormat(strType))
' Paste the textual representation into the TextBox
If obj.GetType().ToString() = "System.String" Then
Me.txtPaste.AppendText(CType(obj, String))
Else
Me.txtPaste.AppendText(obj.GetType.ToString())
End If
' Attempt to paste into the PictureBox
' If it fails, the PictureBox does not support this
' format, so clear the image by setting Image to Nothing.
Try
picturePaste.Image = CType(obj, Image)
Catch ex As Exception
picturePaste.Image = Nothing
End Try
End If
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -