Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6643633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:04:22+00:00 2026-05-26T00:04:22+00:00

My question is how to catch which menu item was pressed in some form?

  • 0

My question is how to catch which menu item was pressed in some form? For an example :

I have a form with a button. When I pressed the button the menu of the application will be on focus and the child form wait to choose a menu item. After I choose one the child form show a message with the name of the menu item which I pressed.

Can anyone tell me how to do this?

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:04:22+00:00Added an answer on May 26, 2026 at 12:04 am
    • 1/ By default you set all the TMenuItem OnClick event handler to Nil.
    • 2/ When you click the form button you assign an event to each TMenuItem, this event will be only called once, and will record the ‘trigger’.
    • 3/ When the event is called you reset all the TMenuitem.OnClick to Nil
    • 4/ To make this easyer, you store all your MenuItems in a TList.

    example:

    global variables (private declaration in TMyForm):

    MyTriggerItem: TMenuItem; // used as pointer
    MyMenuItemList: TList; // used to store all TMenuItem which are 'listened to'
    

    your TButton handler:

    Procedure TMyForm.ButtonClick(Sender: TObject);
    Var
      i: Integer;
    Begin
      For i:= 0 To Pred(MyMenuItemList.Count) Do TMenuItem(MyMenuItemList[i]).OnCLick := CommonMenuItemClick;    
    End;        
    

    your TMenuItem event handler:

    Procedure TMyForm.CommonMenuItemClick(Sender: TObject);
    Var
      i: Integer;
    Begin
      MyTriggerItem := TMenuItem(Sender);
      For i:= 0 To Pred(MyMenuItemList.Count) Do TMenuItem(MyMenuItemList[i]).OnCLick := Nil;
    End;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question which is similar to some questions at stackoverflow but none
My primary question is which approach is faster. Some briefing I'm developing an application
I have a question about how to catch the exception in the initialization list.
I have a simple question hopefully - how does one free memory which was
We have an application which needs to detect duplicates in certain fields on create.
I have an MVC masterpage set up which loads a dynamic menu using AJAX
I have a Question table which joins to a Solution table. The solutions are
ORIGINAL QUESTION Our application uses CSocket which requires the message pump to be running
I have the following code in which dbh constructor may throw exception. The question
I've just seen a question on try-catch , which people (including Jon Skeet) say

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.