关于delphi中的RzGroupBar的问题1
发布网友
发布时间:2024-02-27 05:43
我来回答
共1个回答
热心网友
时间:2024-12-03 12:49
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, RzGroupBar, StdCtrls;type
TForm1 = class(TForm)
RzGroupBar1: TRzGroupBar;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
Button1: TButton;
procere N1Click(Sender: TObject);
procere Button1Click(Sender: TObject);
procere N2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procere SubItemClick(Sender: TObject);
end;var
Form1: TForm1;implementation{$R *.dfm}procere TForm1.Button1Click(Sender: TObject);
var
AIndex: Integer;
begin for AIndex := 0 to RzGroupBar1.GroupCount - 1 do
begin
if RzGroupBar1.Groups[AIndex].Opened then
ShowMessage(RzGroupBar1.Groups[AIndex].Caption);
end;
end;procere TForm1.N1Click(Sender: TObject);
var
MainName: String;
Group: TRzGroup;
begin
MainName:= InputBox('请输入主菜单名称:','主菜单:','');
if MainName = '' then
Exit;
Group:= TRzGroup.Create(RzGroupBar1);
Group.Caption:= MainName;
RzGroupBar1.AddGroup(Group);
end;procere TForm1.N2Click(Sender: TObject);
var
SubName: String;
AIndex: Integer;
GroupItem: TRzGroupItem;
begin
SubName:= InputBox('请输入子菜单名称:','子菜单','');
if SubName = '' then
Exit;
for AIndex := 0 to RzGroupBar1.GroupCount - 1 do
begin
if RzGroupBar1.Groups[AIndex].Opened then
begin
GroupItem:= RzGroupBar1.Groups[AIndex].Items.Add;
GroupItem.Caption:= SubName;
GroupItem.Selected:= True;
GroupItem.Data:= PAnsiChar('C:\WINDOWS\system32\calc.exe');
GroupItem.OnClick:= SubItemClick;
end;
end;end;procere TForm1.SubItemClick(Sender: TObject);
begin
WinExec(TRzGroupItem(Sender).Data,SW_NORMAL);
end;end.