怎样把一个窗口最小化变成右下脚的一个图标?大家救我啊
小弟在这里跪求了
问题点数:100、回复次数:8Top
1 楼wangsaokui(无间道III(终极无间)C#MVP)回复于 2004-09-01 20:40:06 得分 100
使用 Windows 窗体 NotifyIcon 组件向任务栏添加应用程序图标
Windows 窗体 NotifyIcon 组件在任务栏的状态通知区域显示单个图标。若要在状态区域中显示多个图标,则必须使窗体上有多个 NotifyIcon 组件。若要为控件设置所显示的图标,请使用 Icon 属性。也可以在 DoubleClick 事件处理程序中编写代码,以便当用户双击图标时执行相应操作。例如,可以为用户显示一个对话框,以便配置由图标表示的后台处理。
注意 NotifyIcon 组件仅用于通知目的,以提醒用户发生了某一操作或事件,或发生了某种状态更改。您应该使用菜单、工具栏和其他用户界面元素与应用程序进行标准交互。
设置图标
向 Icon 属性赋值。该值的类型必须为 System.Drawing.Icon,并可以从 .ico 文件加载。可以用代码指定图标文件,或单击“属性”窗口中 Icon 属性旁边的省略号按钮 (),然后在显示的“打开”对话框中选择相应的文件。
将 Visible 属性设置为 true。
将 Text 属性设置为相应的工具提示字符串。
在下面的示例中,图标位置的路径设置是 My Documents 文件夹。使用此位置是因为可假定大多数运行 Windows 操作系统的计算机都包含该文件夹。选择此位置还允许具有最低系统访问级别的用户安全地运行应用程序。下面的示例假定窗体已添加了 NotifyIcon 控件。它还假定图标文件的名称为 Icon.ico。
' Visual Basic
' You should replace the bold icon in the sample below
' with an icon of your own choosing.
NotifyIcon1.Icon = New _
System.Drawing.Icon(System.Environment.GetFolderPath _
(System.Environment.SpecialFolder.Personal) _
& "\Icon.ico")
NotifyIcon1.Visible = True
NotifyIcon1.Text = "Antivirus program"
// C#
// You should replace the bold icon in the sample below
// with an icon of your own choosing.
// Note the escape character used (@) when specifying the path.
notifyIcon1.Icon =
new System.Drawing.Icon (System.Environment.GetFolderPath
(System.Environment.SpecialFolder.Personal)
+ @"\Icon.ico");
notifyIcon1.Visible = true;
notifyIcon1.Text = "Antivirus program";
Top
2 楼brightheroes(在地狱中仰望天堂)回复于 2004-09-01 20:40:21 得分 0
托盘Top
3 楼wangsaokui(无间道III(终极无间)C#MVP)回复于 2004-09-01 20:40:38 得分 0
不用跪求,看看帮助就可以了Top
4 楼genius_zhang(每天虚心多一点)回复于 2004-09-01 21:02:54 得分 0
vc非常感谢楼上的极为,能给我个vc++ .net的解决方法吗?求了
小弟是生手,其实对windows变成救不太懂,麻烦了,我用.net
写了一个界面,您说得这些东西改写道哪里呢?Top
5 楼wangsaokui(无间道III(终极无间)C#MVP)回复于 2004-09-01 22:41:30 得分 0
#pragma once
namespace NotifyIcon1
{
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Form1 摘要
///
/// 警告: 如果您更改该类的名称,则需要更改
/// 与该类所依赖的所有 .resx 文件关联的托管资源编译器工具的
/// “资源文件名”属性。 否则,
/// 设计器将不能与此窗体关联的
/// 本地化资源正确交互。
/// </summary>
public __gc class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
}
protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing);
}
private: System::Windows::Forms::NotifyIcon * notifyIcon1;
private: System::ComponentModel::IContainer * components;
private:
/// <summary>
/// 必需的设计器变量。
/// </summary>
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
void InitializeComponent(void)
{
this->components = new System::ComponentModel::Container();
System::Resources::ResourceManager * resources = new System::Resources::ResourceManager(__typeof(NotifyIcon1::Form1));
this->notifyIcon1 = new System::Windows::Forms::NotifyIcon(this->components);
//
// notifyIcon1
//
this->notifyIcon1->Icon = (__try_cast<System::Drawing::Icon * >(resources->GetObject(S"notifyIcon1.Icon")));
this->notifyIcon1->Text = S"This is sample";
this->notifyIcon1->Visible = true;
this->notifyIcon1->DoubleClick += new System::EventHandler(this, notifyIcon1_DoubleClick);
//
// Form1
//
this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
this->ClientSize = System::Drawing::Size(292, 266);
this->Name = S"Form1";
this->ShowInTaskbar = false;
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
this->Text = S"Form1";
this->TopMost = true;
}
private: System::Void notifyIcon1_DoubleClick(System::Object * sender, System::EventArgs * e)
{
Form1::Activate();
Form1::Show();
}
};
}Top
6 楼zhpsam109(JACKY.昊昊)回复于 2004-09-01 22:43:27 得分 0
高手云集!Top
7 楼genius_zhang(每天虚心多一点)回复于 2004-09-02 14:11:15 得分 0
多谢楼上这几位,我看了一下您这段代码,感觉主要是多notifyicon进行了初始化,
我是想在点击最小化按钮时使这个窗口变没,而屏幕右下脚出现一个图标,请问这个怎么实现?
对不起实在麻烦了。Top
8 楼genius_zhang(每天虚心多一点)回复于 2004-09-02 14:51:34 得分 0
需要让这个程序不在任务栏显示
Top




