Probleme mit TActionManager & TActionMainMenuBar



  • Hallo zusammen,
    ich möchte zur Laufzeit ein Menü erzeugen und bin fast am Verzweifeln. Wenn ich es über den Objektinspector mache klapp alles ohne Probleme, aber zur Laufzeit...

    Hier mal der QuellCode:

    TAction* Action = new TAction( this->ActionManager1);
    Action->Visible   = true;
    Action->Enabled   = true;
    Action->Caption   = "&Gruß";
    Action->Category  = "&Hallo";
    Action->OnExecute = this->ExecuteHallo;
    
    TActionBarItem* ActionBarItem = this->ActionManager1->ActionBars->Add();
    ActionBarItem->ActionBar = this->ActionMainMenuBar1;
    ActionBarItem->Visible = true;
    ActionBarItem->AutoSize = true;
    
    TActionClientItem* ActionClientItem = this->ActionManager1->ActionBars >operator [](0)->Items->Add();
    ActionClientItem->Caption = "&Gruß";
    ActionClientItem->Visible = true;
    ActionBarItem->ActionBar = this->ActionMainMenuBar1;
    
    TActionClientItem* ActionClientItem1 = ActionClientItem->Items->Add();
    ActionClientItem1->Caption = "&Hallo";
    ActionBarItem->ActionBar = this->ActionMainMenuBar1;
    ActionClientItem1->Action = Action;
    

    Warum nur bleibt mein Menü leer.

    Danke für Eure Hilfe



  • Hallo

    "Klappt nicht" ist keine Ausreichende Fehlerbeschreibung.

    bis bald
    akari



  • Nun gut, solle es so sein. Also, ich sehe keinen Menü-Eintrag, es ist nur die leere MenüBar zu sehen.



  • benutze mal den Debugger



  • versuchs mal so:

    TAction* Action = new TAction( this);
    Action->ActionList = ActionManager1;
    Action->Visible   = true;
    Action->Enabled   = true;
    Action->Caption   = "&Gruß";
    Action->Category  = "&Hallo";
    Action->OnExecute = ExecuteHallo;
    
    TActionBarItem *ActionBarItem = ActionManager1->ActionBars->Add();
    ActionBarItem->ActionBar = ActionMainMenuBar1;
    ActionBarItem->Visible = true;
    ActionBarItem->AutoSize = false;
    
    TActionClientItem *ActionClientItem = ActionBarItem->Items->Add();
    ActionClientItem->Caption = "&Gruß";
    ActionClientItem->Visible = true;
    ActionClientItem->Action = Action;
    

    was ist denn das?

    TActionClientItem* ActionClientItem = this->ActionManager1->ActionBars
     >operator [](0)->Items->Add();
    


  • Hey super, so funktionierts!!! 🙂 Nun Habe ich nur noch eine Frage. Wie schaffe ich es jetzt in den Menüeintrag "Gruß" noch einen Untereintrag hinzu zufügen.

    Vielen Dank Euch Allen. Ihr habt mir sehr weitergeholfen!!!



  • Ich steh vor demselben Problem wie Björnster vor 3 Jahren.
    Es scheint als bekam er damals keine Antwort auf seine Anschlussfrage:

    Nun Habe ich nur noch eine Frage. Wie schaffe ich es jetzt in den Menüeintrag "Gruß" noch einen Untereintrag hinzu zufügen.

    Danke!



  • Wie beim Menü auch, nur daß du die Untereinträge zu dem MenuItem hinzufügst:

    TActionClientItem *SubItem = ActionClientItem->Items->Add();
    SubItem->Caption = "&Untergruß"; // <-- anpassen!!
    SubItem->Visible = true;
    SubItem->Action = UnterGrussAction; // <-- anpassen!!
    

Anmelden zum Antworten