通信,电信,互联网技术论坛
发新话题
打印

用VB.NET轻松制作特效窗体

用VB.NET轻松制作特效窗体

窗体是Windows应用程序的基础。新一代的开发工具Visual Basic.Net为设计制作窗体提供了更多简单而丰富的方法,无需再求助于复杂而易错的API函数,我们就可以轻松制作多种特效窗体:
1、轻松制作透明窗体VB.NET可以轻松制作出任一透明度的窗体:我们只要在窗体的“属性”窗口中,将 Opacity 属性设置为一个介于 0.0(完全透明)与 1.0(完全不透明)之间的值就可以了:
        Dim frm As FrmTrans = New FrmTrans()
        frm.Opacity = 0.5
        frm.ShowDialog()

2、轻松制作始终位于最上层的窗体
在VB6中,要制作一个始终位于最上层的窗体我们只能求助于令人头痛的API函数。然而在 .NET 中,我们只要简单设置窗体的 TopMost 属性就可实现同样效果了!例如:
        Dim frm As frmTopMost = New frmTopMost()
        frm.TopMost = True
        frm.Show()
3、轻松制作不可见的窗体
如果要编写一个不让别人发现的隐藏程序,制作不可见的窗体就是必须实现的第一步。窗体的可见性通常由 Visible 属性控制。但是,如果希望Windows 应用程序的主窗体在应用程序启动时不可见,您将会发现将它的 Visible 属性设置为 False的方法无效,窗体总会自己显示出来(这是因为,启动窗体的生存期决定了应用程序的生存期)。虽然如此,我们还是可以通过简单将应用程序的启动设置为一个模块,从而从窗体的生存期分出应用程序的生存期,轻松实现不可见的窗体。在下面这个例子中,窗体在特定的时间内自动隐藏:
(1)在 Visual Basic 中,右击项目并选择“添加模块”以将模块添加到 Windows 应用程序。
(2)在已添加的模块(或类)内,创建可作为项目启动对象的 Main 函数:
    Sub main()
        Dim f1 As New Form1()
        f1.Visible = False
        While Hour(Date.Now) < 15   ‘如果当前时间早于15点,窗体自动隐藏
            Application.DoEvents()
        End While
        f1.ShowDialog()
End Sub
4、轻松编写托盘程序
托盘程序作为一类特殊的窗体,其快捷图标显示在系统托盘中,窗体本身则隐藏不可见。在.NET之前版本的VB中编写托盘程序是十分困难的,但是VB.NET提供的新的NotifyIcon组件却使VB初学者也能轻松编写一个这样的程序:
新建“Windows应用程序”,设置主窗体Opacity属性为0,FormBorderStyle属性为None,ShowInTaskbar属性为False,这样窗体将在启动后隐藏。在窗体上放置一个NotifyIcon组件NotifyIcon1,一个ContextMenu(弹出菜单)组件ContextMenu1,并根据需要为ContextMenu1添加菜单项。
设置NotifyIcon1的ICON属性,这个图标就是应用程序出现在系统托盘中的快捷图标;设置NotifyIcon1的Text属性为“VB.NET托盘程序”,这就是鼠标移动到托盘图标时弹出的文字说明;设置NotifyIcon1的ContextMenu属性为ContextMenu1,也就是右键单击快捷图标时的弹出菜单为ContextMenu1。OK,按F5运行!
几乎不用编写代码,一个托盘程序就这样轻松实现了。

TOP

路过,顺便强势插入

TOP

world's poor will be biggest

The charities that provide food, medicine and other relief on the ground say cutbacks have already started, but it will take months or more before the full impact is felt in the poorest countries of Africa, Latin America and Asia.

Aid agencies face more than just the prospect of plummeting donations. The economic conditions themselves, higher food prices and more joblessness, are greatly increasing the number of people who need assistance.

Philippe Guiton of World Vision told The Associated Press that his agency plans to cut back hiring, which will have implications for delivering aid to the needy overseas.

"What we are going to do now is to issue an order to reduce spending, to delay recruitment, delay purchases of capital assets, etc., until we can see clearer how much our income has dropped," he said.

Robert Glasser, secretary-general of CARE International, said the agency has "a number of major donors who have invested heavily in the markets and have now seen their portfolios take a big hit."

What that will mean on the ground could take months or more to gauge, and perhaps years for a complete recovery, aid groups say.

In impoverished Haiti, funding for projects to rebuild from tropical storms that killed nearly 800 people and destroyed more than half the nation's agriculture hangs in the balance.

"It's too soon to tell yet because we haven't heard back positively or negatively from our major donors," Greg Elder, deputy head of programming for US-based Catholic Relief Services, said by telephone from the battered southern port of Les Cayes.

The group is waiting for word from the US Agency for International Development on whether it will get $2 million for 10 new food-for-work projects, which provide Haitians with rations in exchange for building roads, irrigation systems and environmental projects.

An additional $500,000 is needed to repair 12 existing projects whose work was wiped out by the storms. "It's just we can't start these new projects, these rehabilitation projects, until we get the go-ahead," Elder said.
]—————————————————————————————
from:国际机票
world of warcraft gold
Dofus Kamas
final fantasy xi Gil
Age of Conan Gold




TOP

发新话题