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.
  • 相关阅读:
    try里有return,finally 里还会执行吗?
    OKR与KPI
    读阿里规范笔记
    Maven lifeCycle简要说明
    LK AH 技术对比
    HTTP请求 工具类
    HTTPS 流程
    指数基金投资指南-读书笔记
    mybatis-generator
    《富爸爸穷爸爸》---读后感
  • 原文地址:https://www.cnblogs.com/taobataoma/p/776151.html
Copyright © 2011-2022 走看看