| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3236 人关注过本帖
标题:右下角提示框
只看楼主 加入收藏
wysh1014
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2009-10-24
收藏
得分:0 
回复 10楼 不说也罢
那访问数据库的代码要怎么写??不好意思。我是新手……很我都不懂的
2009-11-17 17:51
不说也罢
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:39
帖 子:1481
专家分:4989
注 册:2007-10-7
收藏
得分:20 
建议你找本入门的书先研究一下,不要急于写程序,好吗?

从你问的问题看不应当是刚入门的,应当有一定基础的哦

===================================================
讨厌C#的行尾的小尾巴;和一对大括号{ }
===================================================
2009-11-17 18:06
不说也罢
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:39
帖 子:1481
专家分:4989
注 册:2007-10-7
收藏
得分:0 
这是一个带有动画的:

程序代码:
Public Class Form1
    Dim x As Double = 200
    Dim y As Double = 120
    Dim i As Integer
    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
        If Me.Visible = True And Me.Top = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height - y Then Exit Sub
        Me.TopMost = True
        Me.Visible = True
        Me.WindowState = FormWindowState.Normal
        Do While i < y
            i = i + 1
            Me.SetBounds(System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width - x - 30, System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height - i, x, y)
        Loop
        i = 0
        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 - 10 Or e.Y = 0 Or e.Y >= Me.Height - 5 Then Me.Visible = False
    End Sub

End Class

===================================================
讨厌C#的行尾的小尾巴;和一对大括号{ }
===================================================
2009-11-17 18:59
wysh1014
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2009-10-24
收藏
得分:0 
回复 13楼 不说也罢
我现在换一种方法来实现,但有点小问题,请教一下。比如我在窗体form1的代码中放入
Private Sub NotifyIcon1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseMove
        Dim show As New Form2
        show.Show()
    End Sub
就是当鼠标移动到图标时就出现窗体form2,但是会出现无数个窗体2,这个该怎么解决。再一个,出现的窗体2没在右下角?
版主能不能帮解决这两个问题,因为从窗体2中,我就可以访问远程数据库并做到显示一次重新访问一次了
2009-11-17 19:30
不说也罢
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:39
帖 子:1481
专家分:4989
注 册:2007-10-7
收藏
得分:0 
你要学会举一反三:

FORM1代码:

程序代码:
Public Class Form1
'此窗体只需要一个NotifyIcon1控件
    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
        Form2.Show()
    End Sub

End Class

FORM2代码:

程序代码:
Public Class Form2
    ' 此窗体需要一个Label1控件,一个LinkLabel1控件
    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim r As New Random
        Dim i As Integer = r.Next
        Me.Visible = False
        Me.ShowInTaskbar = False
        Me.SetBounds(System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width - 250, System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height - 200, 200, 200)
        Me.Visible = True
        Me.TopMost = True
        Label1.Text = i '这是随机数,FORM2每次加载都不一样,这里就可以读取数据库了
    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 - 10 Or e.Y = 0 Or e.Y >= Me.Height - 5 Then Me.Close()
    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'修改一下,不然不会随机显示,改为下面一行
        Me.Close()
    End Sub
End Class



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

===================================================
讨厌C#的行尾的小尾巴;和一对大括号{ }
===================================================
2009-11-17 20:04
不说也罢
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:39
帖 子:1481
专家分:4989
注 册:2007-10-7
收藏
得分:0 
如果继续想实现单击托盘图标退出本程序的话

FORM1窗体中还需要添加一个ContextMenuStrip控件,并将NotifyIcon1控件的ContextMenuStrip属性设置与之关联

然后在ContextMenuStrip事件中写退出程序的代码

===================================================
讨厌C#的行尾的小尾巴;和一对大括号{ }
===================================================
2009-11-17 20:35
wysh1014
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2009-10-24
收藏
得分:0 
回复 15楼 不说也罢
嗯。窗体2可以在右下角实现了,也可以重新访问数据了。但是还有一个问题,就是还是会有很多窗体2出现在右下角,重叠在一起,怎么才能让窗体只出现一次呢?
2009-11-17 20:54
不说也罢
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:39
帖 子:1481
专家分:4989
注 册:2007-10-7
收藏
得分:0 
程序代码:
Public Class Form1
    '此窗体只需要一个NotifyIcon1控件
    Public isShow As Boolean = False
    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
        If isShow = True Then Exit Sub
        Form2.Show()
    End Sub

 End Class

程序代码:
Public Class Form2
    ' 此窗体需要一个Label1控件,一个LinkLabel1控件
    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Form1.isShow = True
        Dim r As New Random
        Dim i As Integer = r.Next
        Me.Visible = False
        Me.ShowInTaskbar = False
        Me.SetBounds(System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width - 250, System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height - 200, 200, 200)
        Me.Visible = True
        Me.TopMost = True
        Label1.Text = i '这是随机数,FORM2每次加载都不一样,这里就可以读取数据库了
    End Sub

    Private Sub Form2_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        Form1.isShow = False
    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 - 10 Or e.Y = 0 Or e.Y >= Me.Height - 5 Then Me.Close()
    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.Close()
    End Sub

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

让窗体只出现一次


.

===================================================
讨厌C#的行尾的小尾巴;和一对大括号{ }
===================================================
2009-11-18 12:33
wysh1014
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2009-10-24
收藏
得分:0 
回复 18楼 不说也罢
Form1.isShow = True
        放到窗体2里出现下划线,( 提示对非共享成员的引用要求对象引用)???怎么处理?
2009-11-18 12:44
不说也罢
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:39
帖 子:1481
专家分:4989
注 册:2007-10-7
收藏
得分:0 
form1中有定义,你没有复制FORM1中的代码:

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



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

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