| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3236 人关注过本帖
标题:右下角提示框
只看楼主 加入收藏
wysh1014
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2009-10-24
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:23 
右下角提示框
语言:
效果:像QQ新闻的提示框(数据来于远程数据库,access)在桌面的右下角,在软件上没有任何点击,当窗体最小化后,鼠标移到图标上就会出现。

搜索更多相关主题的帖子: 提示 
2009-11-16 17:14
不说也罢
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:39
帖 子:1481
专家分:4989
注 册:2007-10-7
收藏
得分:0 
下面是一个例子:
新建一个工程

Form1.Designer.VB:
程序代码:
<Global.Microsoft.()> _
Partial Class Form1
    Inherits System.Windows.Forms.Form

    'Form 重写 Dispose,以清理组件列表。
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    'Windows 窗体设计器所必需的
    Private components As  '注意: 以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改它。
    '不要使用代码编辑器修改它。
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
         = New  resources As  = New (GetType(Form1))
        Me.NotifyIcon1 = New System.Windows.Forms.NotifyIcon()
        Me.LinkLabel1 = New System.Windows.Forms.LinkLabel
        Me.LinkLabel2 = New System.Windows.Forms.LinkLabel
        Me.SuspendLayout()
        '
        'NotifyIcon1
        '
        Me.NotifyIcon1.Icon = CType(resources.GetObject("NotifyIcon1.Icon"), System.Drawing.Icon)
        Me.NotifyIcon1.Text = "NotifyIcon1"
        Me.NotifyIcon1.Visible = True
        '
        'LinkLabel1
        '
        Me.LinkLabel1.AutoSize = True
        Me.LinkLabel1.ForeColor = System.Drawing.Color.Lime
        Me.LinkLabel1.Location = New System.Drawing.Point(8, 61)
        Me.LinkLabel1.MinimumSize = New System.Drawing.Size(150, 0)
        Me.LinkLabel1.Name = "LinkLabel1"
        Me.LinkLabel1.Size = New System.Drawing.Size(150, 12)
        Me.LinkLabel1.TabIndex = 0
        Me.LinkLabel1.TabStop = True
        Me.LinkLabel1.Text = "https://bbs.bccn.net"
        '
        'LinkLabel2
        '
        Me.LinkLabel2.AutoSize = True
        Me.LinkLabel2.Location = New System.Drawing.Point(8, 105)
        Me.LinkLabel2.MinimumSize = New System.Drawing.Size(150, 0)
        Me.LinkLabel2.Name = "LinkLabel2"
        Me.LinkLabel2.Size = New System.Drawing.Size(150, 12)
        Me.LinkLabel2.TabIndex = 1
        Me.LinkLabel2.TabStop = True
        Me.LinkLabel2.Text = "退出本程序"
        '
        'Form1
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(185, 166)
        Me.ControlBox = False
        Me.Controls.Add(Me.LinkLabel2)
        Me.Controls.Add(Me.LinkLabel1)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
        Me.Name = "Form1"
        Me.Opacity = 0.5
        Me.ShowInTaskbar = False
        Me.TransparencyKey = System.Drawing.Color.Yellow
        Me.ResumeLayout(False)
        Me.PerformLayout()
        'Me.SetStyle(ControlStyles.UserPaint, True)
    End Sub
    Friend WithEvents NotifyIcon1 As System.Windows.Forms.NotifyIcon
    Friend WithEvents LinkLabel1 As System.Windows.Forms.LinkLabel
    Friend WithEvents LinkLabel2 As System.Windows.Forms.LinkLabel

End Class

Form1.VB:
程序代码:
Public Class Form1
    Dim x As Double = Me.Width
    Dim y As Double = Me.Height
    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        NotifyIcon1.Dispose()
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        x = Me.Width
        y = Me.Height
        Me.Width = 0
        Me.Height = 0
        Me.Visible = False
    End Sub

    Private Sub NotifyIcon1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseMove
        Me.TopMost = True
        Me.Visible = True
        Me.WindowState = FormWindowState.Normal
        Me.SetBounds(System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width - x, System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height - y, x, y)
        Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
    End Sub

    Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        System.Diagnostics.Process.Start(LinkLabel1.Text)
        Me.Visible = False
    End Sub

    Private Sub LinkLabel2_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel2.LinkClicked
        NotifyIcon1.Dispose()
        End
    End Sub

    Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        If e.X = 0 Or e.X = Me.Width Or e.Y = 0 Or e.Y = Me.Height Then Me.Visible = False
    End Sub

    Public Sub New()
        ' 此调用是 Windows 窗体设计器所必需的。
        InitializeComponent()
        ' 在 InitializeComponent() 调用之后添加任何初始化。
    End Sub

    Protected Overrides Sub Finalize()
        MyBase.Finalize()
    End Sub
End Class



'如果是从SUBMAIN运行,就没有这么复杂

===================================================
讨厌C#的行尾的小尾巴;和一对大括号{ }
===================================================
2009-11-16 19:57
wysh1014
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2009-10-24
收藏
得分:0 
回复 2楼 不说也罢
我把这些代码放上去。有几处下划线,是不是还要有什么引用才行呀?这个是新建的工程,那怎么和我以前做的工程连起来呀?像这样的效果
图片附件: 游客没有浏览图片的权限,请 登录注册
怎么实现。就是当鼠标放在图标上就出来那些提示。提示框里的信息来自远程  access文件
2009-11-16 21:58
不说也罢
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:39
帖 子:1481
专家分:4989
注 册:2007-10-7
收藏
得分:0 
示例工程,解压后打开WindowsApplication1.sln文件即可

WindowsApplication1.rar (65.58 KB)

===================================================
讨厌C#的行尾的小尾巴;和一对大括号{ }
===================================================
2009-11-17 11:44
wysh1014
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2009-10-24
收藏
得分:0 
回复 4楼 不说也罢
运行了你的程序,就是这种效果,但是打不开。提示说我的版本太低了……很想用你的代码……
2009-11-17 12:21
不说也罢
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:39
帖 子:1481
专家分:4989
注 册:2007-10-7
收藏
得分:0 
哦,这我没预计到,我用的是2008,framework3.5

===================================================
讨厌C#的行尾的小尾巴;和一对大括号{ }
===================================================
2009-11-17 13:00
wysh1014
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2009-10-24
收藏
得分:0 
回复 6楼 不说也罢
我是03版的。net
2009-11-17 13:27
不说也罢
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:39
帖 子:1481
专家分:4989
注 册:2007-10-7
收藏
得分:0 
版本虽不同,但过程代码基本没什么区别

窗体中添加两个LABLELINK控件,一个NotifyIcon控件即可,然后将三个控件及窗体的过程代码复制过去就可以了

程序代码:
Public Class Form1
    Dim x As Double = Me.Width
    Dim y As Double = Me.Height
    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        NotifyIcon1.Dispose()
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        x = Me.Width
        y = Me.Height
        Me.Width = 0
        Me.Height = 0
        Me.Visible = False
    End Sub

    Private Sub NotifyIcon1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseMove
        Me.TopMost = True
        Me.Visible = True
        Me.WindowState = FormWindowState.Normal
        Me.SetBounds(System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width - x, System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height - y, x, y)
        Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
    End Sub

    Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        System.Diagnostics.Process.Start(LinkLabel1.Text)
        Me.Visible = False
    End Sub

    Private Sub LinkLabel2_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel2.LinkClicked
        NotifyIcon1.Dispose()
        End
    End Sub

    Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        If e.X = 0 Or e.X = Me.Width Or e.Y = 0 Or e.Y = Me.Height Then Me.Visible = False
    End Sub
End Class

将上述代码复制到窗体FORM1中,在设计时,为NotifyIcon1指定一个ICON图标,不然在托盘里是看不见的

[ 本帖最后由 不说也罢 于 2009-11-17 13:47 编辑 ]

===================================================
讨厌C#的行尾的小尾巴;和一对大括号{ }
===================================================
2009-11-17 13:44
wysh1014
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2009-10-24
收藏
得分:0 
回复 8楼 不说也罢
代码可以了。但是好像大了点。那个提示框的大小能控制吗?还有。提示框中的数据如果是从服务器中(如:http://www.baidu.com)这个网站的数据库(access数据库)上得到的可以吗?当提示框出现一次,就重新访问一次数据库。把最新的数据显示在提示框中……
2009-11-17 14:59
不说也罢
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:39
帖 子:1481
专家分:4989
注 册:2007-10-7
收藏
得分:0 
当提示框出现一次,就重新访问一次数据库。-----这功能可以在NotifyIcon1_MouseMove事件中实现,也可以用定时器定时地访问远程数据库

那个提示框的大小能控制吗?————可以动态实现

程序代码:
Public Class Form1
    Dim x As Double = 200'修改X,Y值即可
    Dim y As Double = 120
    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        NotifyIcon1.Dispose()
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Width = 0
        Me.Height = 0
        Me.Visible = False
    End Sub

    Private Sub NotifyIcon1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseMove
        Me.TopMost = True
        Me.Visible = True
        Me.WindowState = FormWindowState.Normal
        Me.SetBounds(System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width - x - 30, System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height - y, x, y)
        Me.FormBorderStyle = Windows.Forms.FormBorderStyle.Fixed3D
    End Sub

    Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        System.Diagnostics.Process.Start(LinkLabel1.Text)
        Me.Visible = False
    End Sub

    Private Sub LinkLabel2_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel2.LinkClicked
        NotifyIcon1.Dispose()
        End
    End Sub

    Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        If e.X = 0 Or e.X = Me.Width Or e.Y = 0 Or e.Y = Me.Height Then Me.Visible = False
    End Sub

End Class

===================================================
讨厌C#的行尾的小尾巴;和一对大括号{ }
===================================================
2009-11-17 17:40
快速回复:右下角提示框
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024137 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved