1、new -->application

2、在form1中加入一个tPopMenu 命名为pm1

3、uses ShellAPI;

4、定义一个常量在
const
WM_TRAYMSG = WM_USER + 101;

5、在private中生命变量
NotifyIcon: TNotifyIconData;

6.声明两个消息

 procedure TfrmMain.WMSysCommand(var Msg: TMessage);
begin
if Msg.WParam = SC_ICON then
Self.Visible := False
else
DefWindowProc(Self.Handle, Msg.Msg, Msg.WParam, Msg.LParam);
end; procedure TfrmMain.WMTrayMsg(var Msg: TMessage);//声明托盘消息
var
p: TPoint;
begin
case Msg.LParam of
WM_LBUTTONDOWN: Self.Visible := True; //显示窗体
WM_RBUTTONDOWN:
begin
SetForegroundWindow(Self.Handle); //把窗口提前
GetCursorPos(p);
pm1.Popup(p.X, p.Y);
end;
end; end;

7、oncreate中

  with NotifyIcon do
begin
cbSize := SizeOf(TNotifyIconData);
Wnd := Self.Handle;
uID := ;
uFlags := NIF_ICON + NIF_MESSAGE + NIF_TIP; //图标、消息、提示信息
uCallbackMessage := WM_TRAYMSG;
hIcon := Application.Icon.Handle;
szTip := 'erp服务';
end;
Shell_NotifyIcon(NIM_ADD, @NotifyIcon); //去掉关闭按钮
EnableMenuItem(GetSystemMenu(Handle, FALSE), SC_CLOSE, MF_BYCOMMAND or MF_GRAYED);

8、ondestroy中
Shell_NotifyIcon(NIM_DELETE, @NotifyIcon);

整体代码

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ShellAPI, Menus; const
WM_TRAYMSG = WM_USER + ; type
TForm1 = class(TForm)
pm1: TPopupMenu;
N1: TMenuItem;
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
NotifyIcon: TNotifyIconData;
procedure WMTrayMsg(var Msg: TMessage); message WM_TRAYMSG; //声明托盘消息
procedure WMSysCommand(var Msg: TMessage); message WM_SYSCOMMAND;
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormDestroy(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE, @NotifyIcon);
end; procedure TForm1.FormCreate(Sender: TObject);
begin
with NotifyIcon do
begin
cbSize := SizeOf(TNotifyIconData);
Wnd := Self.Handle;
uID := ;
uFlags := NIF_ICON + NIF_MESSAGE + NIF_TIP; //图标、消息、提示信息
uCallbackMessage := WM_TRAYMSG;
hIcon := Application.Icon.Handle;
szTip := 'erp服务';
end;
Shell_NotifyIcon(NIM_ADD, @NotifyIcon); //去掉关闭按钮
EnableMenuItem(GetSystemMenu(Handle, FALSE), SC_CLOSE, MF_BYCOMMAND or MF_GRAYED);
end; { TForm1 } procedure TForm1.WMSysCommand(var Msg: TMessage);
begin
if Msg.WParam = SC_ICON then
Self.Visible := False
else
DefWindowProc(Self.Handle, Msg.Msg, Msg.WParam, Msg.LParam);
end; procedure TForm1.WMTrayMsg(var Msg: TMessage);
var
p: TPoint;
begin
case Msg.LParam of
WM_LBUTTONDOWN: Self.Visible := True; //显示窗体
WM_RBUTTONDOWN:
begin
SetForegroundWindow(Self.Handle); //把窗口提前
GetCursorPos(p);
pm1.Popup(p.X, p.Y);
end;
end; end; end.

//这是从网上找的在delphi7测试通过(引用的哪忘了)--- http://blog.csdn.net/akof1314/article/details/6411179 这个列牛B

delphi 实现最小化系统托盘(rz控件最简单 评论)的更多相关文章

  1. delphi 实现最小化系统托盘

    1.new -->application 2.在form1中加入一个tPopMenu 命名为pm1 3.uses ShellAPI; 4.定义一个常量在 const WM_TRAYMSG = W ...

  2. Delphi - 利用TRzTrayIcon实现WinFrm工程最小化到托盘

    第三方RC控件的安装 浏览器搜索Delphi Rz控件下载,找到下载一个安装文件,解压后点击RC3.exe一键安装. Delphi WinFrm工程最小化到托盘 Delphi新建WinFrm工程,在主 ...

  3. VC++ 最小化到托盘、恢复

    所谓的“托盘”,在Windows系统界面中,指的就是下面任务条右侧,有系统时间等等的标志的那一部分.在程序最小化或挂起时,但有不希望占据任务栏的时候,就可以把程序放到托盘区. 一.托盘编程相关函数   ...

  4. outlook新邮件到达提醒设置以及outlook最小化到托盘设置

    有些邮件是需要马上处理的,因此希望能在收到邮件之后马上就知道,但是有不希望频繁的去检查有没有.outlook可以帮我们轻松做到新邮件到达提醒. 一 .设置outlook新邮件到达提醒:选项->电 ...

  5. vc++ 最小化到托盘的详细实现

    在VC++中,想实现将MFC最小化到系统托盘,需要调用NOTIFYICONDATA类,并注册相应的消息,以下详细讲解如何实现: 1.声明一个NOTIFYICONDATA类,也就是NOTIFYICOND ...

  6. (WinForm)文件夹状态监控,最小化到托盘,开机自启动

    原文 (WinForm)文件夹状态监控,最小化到托盘,开机自启动 . 文件夾監控(監測文件夾中的文件動態): //MSDN上的例子 public class Watcher { public stat ...

  7. WinForm 之 窗口最小化到托盘及右键图标显示菜单

    Form最小化是指整个Form都缩小到任务栏上,但是窗体以Form的标题栏形式显示在任务栏上, 若是想让Form以Icon的形式显示在任务栏右下角,则需要给Form添加一个NotifyIcon控件. ...

  8. C# 最小化到托盘,托盘右击菜单显示

    添加notifyIcon控件,并添加Icon,否则托盘没有图标(托盘右键菜单也可直接在属性里添加): 主要的代码: public partial class Form1 : Form { #regio ...

  9. 【VS开发】最小化到托盘 shell_notifyicon和NOTIFYICONDATA

    shell_notifyicon和NOTIFYICONDATA Shell_NotifyIcon函数,向任务栏的状态栏发送一个消息 函数原型 BOOL Shell_NotifIcon( DWORD d ...

随机推荐

  1. 一个类似indexOf()的功能的函数

    之前面试的时候遇到了这样的一道题,不过写的时候有些细节没注意到,现在重新写了一下. 写一个类似indexOf()的功能的函数 var str = "dafdfgvdahjfbhyuyvtur ...

  2. asp.net core网关Ocelot的简单介绍& Ocelot集成Identity认证

    文章简介  Ocelot网关简介 Ocelot集成Idnetity认证处理 Ocelot网关简介 Ocelot是一个基于netcore实现的API网关,本质是一组按特定顺序排列的中间件.Ocelot内 ...

  3. Naive RNN vs LSTM vs GRU、attention基础

    原文地址:https://www.jianshu.com/p/b8653f8b5b2b 一.Recurrent Neural Network 二.Naive RNN Naive RNN更新参数时易出现 ...

  4. 2019河北省大学生程序设计竞赛(重现赛)J-舔狗 (拓扑排序)

    题目链接:https://ac.nowcoder.com/acm/contest/903/J 题意:给你 n 个舔狗和他喜欢的人,让你俩俩配对(只能和喜欢它的和它喜欢的),求剩下的单身狗数量. 思路: ...

  5. java实现邮件定时发送

    最近做项目时客户提出了一个需求:系统定时发送E-mail到其客户,达到通知的效果.先将实例分享给大家,如果确实有一些帮助的话,请大家来点掌声! 首先介绍java定时器(java.util.Timer) ...

  6. Day 19:面向对象【类方法】静态属性/静态属性/类方法

    静态属性  @property  class Mom: gender = "woman" def __init__(self,name,weight): self.name = n ...

  7. Python翻译

    translator.py # -*- coding: utf-8 -*- # author: inspurer(月小水长) # pc_type lenovo # create_time: 2019/ ...

  8. Organizing Containers of Balls

    题目 David has several containers, each with a number of balls in it. He has just enough containers to ...

  9. ArrayList、Vector、LinkedList的区别

    ArrayList.Vector.LinkedList的区别 1.底层数据结构: ArrayList底层实现是动态数组 Vector底层实现是动态数组 LinkedList底层实现是双链表  2.扩容 ...

  10. C语言指针和字符串

    #include <stdio.h> int main() { /********************************************* * 内存: * 1.常量区 * ...