Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共13 条记录, 每页显示 10 条, 页签: [1] [2]
[浏览完整版]

标题:[求助]请问这个代码在全局代码中应该怎么修改呢

1楼
81538475 发表于:2024/1/3 23:32:00
Private Sub OpacityTimer_Tick(sender As Object, e As EventArgs) Handles opacityTimer.Tick
        Me.Opacity -= opacityStep

        If Me.Opacity <= 0.0 Then
            opacityTimer.Stop()
            Me.Close()
        End If
    End Sub
2楼
有点蓝 发表于:2024/1/4 8:40:00
如果只有单独这个函数,没有办法改,也用不了。如果是放到class里面的,请把整个class的代码一起发上来
3楼
81538475 发表于:2024/1/4 9:18:00
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms

Public Class MainForm
    Inherits Form

    Private WithEvents opacityTimer As Timer
    Private opacityStep As Double = 0.1
    Private fadeInterval As Integer = 100

    Public Sub New()
        Me.Text = "绘制SP图案"
        Me.Size = New Size(500, 300)
        Me.FormBorderStyle = FormBorderStyle.None ' 禁用窗口边框

        Dim path As New GraphicsPath()
        Dim radius As Integer = 50 ' 增加圆角的半径
        Dim rect As New Rectangle(0, 0, Me.Width, Me.Height)

        path.AddArc(rect.X, rect.Y, radius, radius, 180, 90) ' 左上角
        path.AddArc(rect.Width - radius, rect.Y, radius, radius, 270, 90) ' 右上角
        path.AddArc(rect.Width - radius, rect.Height - radius, radius, radius, 0, 90) ' 右下角
        path.AddArc(rect.X, rect.Height - radius, radius, radius, 90, 90) ' 左下角
        path.CloseFigure()

        Me.Region = New Region(path)

        opacityTimer = New Timer()
        opacityTimer.Interval = fadeInterval
        opacityTimer.Start()
    End Sub

    Protected Overrides Sub OnPaintBackground(e As PaintEventArgs)
        Dim graphics = e.Graphics
        graphics.SmoothingMode = SmoothingMode.AntiAlias ' 启用抗锯齿
        graphics.Clear(Color.White) ' 设置窗口背景颜色
    End Sub

    Private Sub OpacityTimer_Tick(sender As Object, e As EventArgs) Handles opacityTimer.Tick
        Me.Opacity -= opacityStep

        If Me.Opacity <= 0.0 Then
            opacityTimer.Stop()
            Me.Close()
        End If
    End Sub

    Public Shared Sub Main()
        Application.Run(New MainForm())
    End Sub
End Class
4楼
有点蓝 发表于:2024/1/4 9:40:00
去掉前面3个Imports的行 ,其它代码照搬到全局代码,补齐里面的命名空间即可
5楼
81538475 发表于:2024/1/4 10:49:00
 贴上去提示这个了图片点击可在新窗口打开查看
[此贴子已经被作者于2024/1/4 10:49:06编辑过]
6楼
有点蓝 发表于:2024/1/4 10:58:00
完整代码?
7楼
81538475 发表于:2024/1/4 11:00:00
Public Class MainForm
   ’ Inherits Form

    Private WithEvents opacityTimer As Timer
    Private opacityStep As Double = 0.1
    Private fadeInterval As Integer = 100

    Public Sub New()
        Me.Text = "绘制SP图案"
        Me.Size = New Size(500, 300)
        Me.FormBorderStyle = FormBorderStyle.None ' 禁用窗口边框

        Dim path As New GraphicsPath()
        Dim radius As Integer = 50 ' 增加圆角的半径
        Dim rect As New Rectangle(0, 0, Me.Width, Me.Height)

        path.AddArc(rect.X, rect.Y, radius, radius, 180, 90) ' 左上角
        path.AddArc(rect.Width - radius, rect.Y, radius, radius, 270, 90) ' 右上角
        path.AddArc(rect.Width - radius, rect.Height - radius, radius, radius, 0, 90) ' 右下角
        path.AddArc(rect.X, rect.Height - radius, radius, radius, 90, 90) ' 左下角
        path.CloseFigure()

        Me.Region = New Region(path)

        opacityTimer = New Timer()
        opacityTimer.Interval = fadeInterval
        opacityTimer.Start()
    End Sub

    Protected Overrides Sub OnPaintBackground(e As PaintEventArgs)
        Dim graphics = e.Graphics
        graphics.SmoothingMode = SmoothingMode.AntiAlias ' 启用抗锯齿
        graphics.Clear(Color.White) ' 设置窗口背景颜色
    End Sub

    Private Sub OpacityTimer_Tick(sender As Object, e As EventArgs) Handles opacityTimer.Tick
        Me.Opacity -= opacityStep

        If Me.Opacity <= 0.0 Then
            opacityTimer.Stop()
            Me.Close()
        End If
    End Sub

    Public Shared Sub Main()
        Application.Run(New MainForm())
    End Sub
End Class
8楼
有点蓝 发表于:2024/1/4 11:00:00
这句不能注释掉啊,这才是关键的功能

’ Inherits Form
9楼
linyunu 发表于:2024/1/4 11:01:00
System.Drawing.Rectangle    补齐命名空间
10楼
81538475 发表于:2024/1/4 11:23:00
好了,可以了。在弱弱的问一句,这个应该怎么调用呀图片点击可在新窗口打开查看
共13 条记录, 每页显示 10 条, 页签: [1] [2]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .03320 s, 2 queries.