zoukankan      html  css  js  c++  java
  • 在delphi中添加一个菜单项到Windows的系统菜单


        为什么Windows的系统菜单总是一成不变?这个例子教你如何往系统菜单添加一个菜单项如about或information等。
        这个例子将一个菜单项加到系统菜单中去。我们需要两个东西,一个是项名,这可以是如何整数;我们还需要一个程序去收取Windows对确认点击我们创建的菜单项的信息。
    Unit OhYeah;
    Interface
    Uses
        SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls, Forms, Dialogs, Menus;
    Type
       TForm1 = Class (TForm)
          Procedure FormCreate (Sender : TObject);
              Private {Private declarations}
       Public {Public declarations}
          Procedure WinMsg (Var Msg : TMsg; Var Handled : Boolean);
          Procedure DoWhatEever;
    End;
    Var
       Form1 : TForm1;
    Implementation
    {$R *.DFM}
    Const
         ItemID = 99; // 这个ID number代表你的菜单项,可以是任何值。
    Procedure Tform1.WinMsg (Var Msg : TMsg; Var Handled : Boolean);
    Begin
         If Msg.Message = WM_SYSCOMMAND Then
            If Msg.WParam = ItemID Then DoWhatEver;
    End;
    Procedure TForm1.FormCreate (Sender : TObject);
    Begin
         Application.OnMessage := WinMsg;
         AppendMenu (GetSystemMenu (Form1.Handle, False), MF_SEPARATOR, 0, '');
         AppendMenu (GetSystemMenu (Form1.Handle, False), MF_BYPOSITION, ItemID, '&My menu');
         AppendMenu (GetSystemMenu (Application.Handle, False), MF_SEPARATOR, 0, '');
         AppendMenu (GetSystemMenu (Application.Handle, False), MF_BYPOSITION, ItemID,'&My menu minimized');
    End;
    Procedure TForm1.DoWhatEver;
    Begin
         Exit; //你可以添加任何你想加的东西到这里
    End;
    End.
  • 相关阅读:
    CentOS 7拨号上网(ADSL & PPPoE)
    linux使用nmcli重新生成网卡配置文件
    Linux 内存缓存占用过大,Centos7设置定时清除buff/cache的脚本
    部署redis6.0 常见问题
    ssh 升级导致的hadoop 主备切换失败
    配置zookeeper的 ACL权限
    sqoop 创建跟mysql相同表结构的hive表报错
    vim中显示不可见字符
    supervisor 使用
    使用hive streaming 统计Wordcount
  • 原文地址:https://www.cnblogs.com/taobataoma/p/776151.html
Copyright © 2011-2022 走看看