惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IT之家
IT之家
腾讯CDC
博客园 - Franky
S
SegmentFault 最新的问题
美团技术团队
阮一峰的网络日志
阮一峰的网络日志
J
Java Code Geeks
Y
Y Combinator Blog
Engineering at Meta
Engineering at Meta
Microsoft Security Blog
Microsoft Security Blog
MongoDB | Blog
MongoDB | Blog
I
InfoQ
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
B
Blog RSS Feed
博客园 - 叶小钗
博客园_首页
有赞技术团队
有赞技术团队
雷峰网
雷峰网
量子位
小众软件
小众软件
月光博客
月光博客
U
Unit 42
D
DataBreaches.Net

博客园 - 岳洋

关键词:vb.net 扑克 cards.dll 网上较好的提取链接的正则表达式 下载网页源代码的程序 一个读取网页源代码的小程序 file manager 0.1 circleliner阅读笔记 用于学习鼠标作图的网页。 写文件时换行的问题[转载] by 東風耐候 - 岳洋 用旧方法文件读写 - 岳洋 - 博客园 Birthday Reminder Framework 1.1版本 Birthday Reminder (R Edition) ver1.0 build 050813正式发布! 050627ReciteDemo0.2 050626诗歌背诵程序demo 050615 B-A-M v1.0源代码 050615 Bact.-Anti-Med.ver1.0正式发布! 新建一个按钮至少需要做的事情…… 我决定不再和窗体设计器争生意了! 050614Bact.-Anti-Med.v0.3最新更新 按钮的突然消失!(小记一次编程失误)
panel的使用
岳洋 · 2005-12-18 · via 博客园 - 岳洋

Imports System
Imports System.Drawing
Imports System.Windows.Forms

Namespace MouseEvent
    
' Summary description for Form1.
    Public NotInheritable Class Form1
        
Inherits System.Windows.Forms.Form
        
Friend WithEvents panel1 As System.Windows.Forms.Panel
        
Private mousePath As System.Drawing.Drawing2D.GraphicsPath
        
Public Shared Sub Main()
            System.Windows.Forms.Application.Run(
New Form1())
        
End Sub
 'Main

        
Public Sub New()

            mousePath 
= New System.Drawing.Drawing2D.GraphicsPath()

            
Me.panel1 = New System.Windows.Forms.Panel()
            
' Mouse Panel
            Me.panel1.Anchor = System.Windows.Forms.AnchorStyles.Top Or _
                                    System.Windows.Forms.AnchorStyles.Left 
Or _
                                    System.Windows.Forms.AnchorStyles.Right
            
Me.panel1.BackColor = System.Drawing.SystemColors.ControlDark
            
Me.panel1.Location = New System.Drawing.Point(16160)
            
Me.panel1.Size = New System.Drawing.Size(664320)

            
            
End Sub
 'New

        
Private Sub panel1_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles panel1.MouseDown
            
' Update the mouse path with the mouse information
            Dim mouseDownLocation As New Point(e.X, e.Y)
            
            
Dim eventString As String = Nothing
            
Select Case e.Button
                
Case MouseButtons.Left
                    eventString 
= "L"
                
Case MouseButtons.Right
                    eventString 
= "R"
                
Case MouseButtons.Middle
                    eventString 
= "M"
                
Case MouseButtons.XButton1
                    eventString 
= "X1"
                
Case MouseButtons.XButton2
                    eventString 
= "X2"
                
Case MouseButtons.None:
                     eventString 
= Nothing              
            
End Select
            
            
If Not (eventString Is NothingThen
                mousePath.AddString(eventString, FontFamily.GenericSerif, 
CInt(FontStyle.Bold), fontSize, mouseDownLocation, StringFormat.GenericDefault)
            
Else
                mousePath.AddLine(mouseDownLocation, mouseDownLocation)
            
End If

            panel1.Focus()
            panel1.Invalidate()
        
End Sub
 
        
        
Private Sub panel1_MouseEnter(sender As Object, e As System.EventArgs) Handles panel1.MouseEnter
            
' Update the mouse event label to indicate the MouseEnter event occurred.
            label1.Text = sender.GetType().ToString() + ": MouseEnter"
        
End Sub

        
        
Private Sub panel1_MouseHover(sender As Object, e As System.EventArgs) Handles panel1.MouseHover
            
' Update the mouse event label to indicate the MouseHover event occurred.
            label1.Text = sender.GetType().ToString() + ": MouseHover"
        
End Sub

        
        
Private Sub panel1_MouseLeave(sender As Object, e As System.EventArgs) Handles panel1.MouseLeave
            
' Update the mouse event label to indicate the MouseLeave event occurred.
            label1.Text = sender.GetType().ToString() + ": MouseLeave"
        
End Sub

        
        
Private Sub panel1_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles panel1.MouseMove
            
' Update the mouse path that is drawn onto the Panel.
            Dim mouseX As Integer = e.X
            
Dim mouseY As Integer = e.Y
            
            mousePath.AddLine(mouseX, mouseY, mouseX, mouseY)
        
End Sub

        
Private Sub panel1_MouseWheel(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles panel1.MouseWheel
            
' Update the drawing based upon the mouse wheel scrolling.
            Dim numberOfTextLinesToMove As Integer = e.Delta * SystemInformation.MouseWheelScrollLines / 120 ' WHEEL_DATA
            Dim numberOfPixelsToMove As Integer = numberOfTextLinesToMove * fontSize
            
            
If numberOfPixelsToMove <> 0 Then
                
Dim translateMatrix As New System.Drawing.Drawing2D.Matrix()
                translateMatrix.Translate(
0, numberOfPixelsToMove)
                mousePath.Transform(translateMatrix)
            
End If

            panel1.Invalidate()
        
End Sub

        
Private Sub panel1_MouseUp(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles panel1.MouseUp
            
Dim mouseUpLocation = New System.Drawing.Point(e.X, e.Y)
            
            
' Show the number of clicks in the path graphic.
            Dim numberOfClicks As Integer = e.Clicks
            mousePath.AddString(
"     " + numberOfClicks.ToString(), _
                                FontFamily.GenericSerif, 
CInt(FontStyle.Bold), _
                                fontSize, mouseUpLocation, StringFormat.GenericDefault)

            panel1.Invalidate()
        
End Sub

        
        
Private Sub panel1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles panel1.Paint
            
' Perform the painting of the Panel.
            e.Graphics.DrawPath(System.Drawing.Pens.DarkRed, mousePath)
        
End Sub

        
        
Private Sub clearButton_Click(sender As Object, e As System.EventArgs) Handles clearButton.Click
            
' Clear the Panel display.
            mousePath.Dispose()
            mousePath 
= New System.Drawing.Drawing2D.GraphicsPath()
            panel1.Invalidate()
        
End Sub

        
    
End Class
 'Form1
End Namespace