AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

TMenuItem.Tag

Ein Thema von DerMondistunsereSonne · begonnen am 27. Mär 2025 · letzter Beitrag vom 28. Mär 2025
Antwort Antwort
stifflersmom

Registriert seit: 8. Dez 2005
Ort: 24994 Holt
388 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#1

AW: TMenuItem.Tag

  Alt 27. Mär 2025, 13:17
Ich denke, Du vertust Dich mit dem "richtigen" Zugriff auf die Menuitems

Hier ein Formular mit einem simplen Menu
Delphi-Quellcode:
object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 441
  ClientWidth = 624
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -12
  Font.Name = 'Segoe UI'
  Font.Style = []
  Menu = Mainmenu1
  TextHeight = 15
  object Button1: TButton
    Left = 48
    Top = 48
    Width = 241
    Height = 25
    Caption = 'EnabledDiableButton'
    TabOrder = 0
    OnClick = Button1Click
  end
  object Mainmenu1: TMainMenu
    Left = 304
    Top = 224
    object Enabled11: TMenuItem
      Caption = 'Enabled/Disabled'
      object Enables21: TMenuItem
        Caption = 'Enabled'
      end
      object Enabled1: TMenuItem
        Caption = 'Enabled'
      end
      object Disabled1: TMenuItem
        Tag = 1
        Caption = 'Disabled'
      end
    end
  end
end
Und hier der Code mit einem Button, der alle Menüenträge des ersten "Hauptmenüeintrages" durchiteriert und dann asublendet, wenn das Tag 1 asl Wert hat.
Delphi-Quellcode:
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Menus;

type
  TForm1 = class(TForm)
    Mainmenu1: TMainMenu;
    Enabled11: TMenuItem;
    Enables21: TMenuItem;
    Enabled1: TMenuItem;
    Disabled1: TMenuItem;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
    i : Integer;
begin

      for i := 0 to MainMenu1.items[0].Count -1 do
      begin
        MainMenu1.Items[0][i].Visible := (Mainmenu1.Items[0][i].Tag = 0);
      end;
end;

end.
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:48 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz