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

  • Home
  • SEARCH
  • 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 8734393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:49:59+00:00 2026-06-13T09:49:59+00:00

We have an application that can be run in Simple or Advanced mode. The

  • 0

We have an application that can be run in Simple or Advanced mode. The difference is what main menu entries are visible. The problem is that RAD Studio XE2 silently deletes the OnClick property value set in the dfm. It points to a procedure hiding some menu items in the Main Menu > File menu.

Steps:
1. A fresh checkout from subversion to a new folder on disk, one that never existed before.
2. Opening the main form’s dfm and pas files in notepad++ to ensure that the “OnClick = MenuItem_File1Click” row is there and that procedure MenuItem_File1Click is in interface and implementation of pas file. Yes, everything looks good.
3. Open project in RAD Studio XE2.
4. OnClick property of File menu item in Object Inspector is blank.

We have some other menu items that were handled in FormShow and they work as expected, hidden in Simple mode and visible in Advanced. The workaround was to move the functionality inside the MenuItem_File1Click to FormShow. But I really want to understand why it happened in the first place.

Can anyone explain this behaviour? Has anyone else come across something like this? I tried renaming the procedure to something definitiely not system-like but the IDE removed it anyway.

  • 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-06-13T09:50:00+00:00Added an answer on June 13, 2026 at 9:50 am

    If you hook up your Menu (or a Button) with an Action, then the Action is supposed to take over the control of all these properties:
    AutoCheck, Caption, Checked, Enabled, HelpContext, Hint, GroupIndex, Bitmap/ImageIndex, ShortCut, Visible and in your case OnClick/Execute.

    That’s the “raison d’etre” of the Actions in the 1st place.

    So if you leave your Action without an Execute event handler, you are de facto putting nil into your Control’s OnClick event.

    And this happens whenever the controls are read from the dfm at the moment the Action specified in the dfm is hooked to the control. Just try to set the OnClick, then switch to View As Text and back (Alt+F12 twice) and your OnClick is gone…

    See the VCL source:

    procedure TMenuItem.ActionChange(Sender: TObject; CheckDefaults: Boolean);
    begin
      if Sender is TCustomAction then
        with TCustomAction(Sender) do
        begin
          if not CheckDefaults or (Self.AutoCheck = False) then
            Self.AutoCheck := AutoCheck;
          if not CheckDefaults or (Self.Caption = '') then
            Self.Caption := Caption;
          if not CheckDefaults or (Self.Checked = False) then
            Self.Checked := Checked;
          if not CheckDefaults or (Self.Enabled = True) then
            Self.Enabled := Enabled;
          if not CheckDefaults or (Self.HelpContext = 0) then
            Self.HelpContext := HelpContext;
          if not CheckDefaults or (Self.Hint = '') then
            Self.Hint := Hint;
          if RadioItem and (not CheckDefaults or (Self.GroupIndex = 0)) then
            Self.GroupIndex := GroupIndex;
          if not CheckDefaults or (Self.ImageIndex = -1) then
            Self.ImageIndex := ImageIndex;
          if not CheckDefaults or (Self.ShortCut = scNone) then
            Self.ShortCut := ShortCut;
          if not CheckDefaults or (Self.Visible = True) then
            Self.Visible := Visible;
          if not CheckDefaults or not Assigned(Self.OnClick) then
            Self.OnClick := OnExecute; // <====== use debug dcus and put a break here...
        end;
    end;
    

    Update: … but this should not happen if you have code in the OnClick event.
    This looks like a bug. When the MenuItem is read from the dfm, the parent Form is not yet fully loaded and the OnClick appears as

    Name            Value
    FOnClick    ($3,$6142210)
        Code    $3
        Data    $6142210
    

    but Assigned(FOnClick) returns False !!!!

    So if not CheckDefaults or (@Self.OnClick=nil) then
    would be a better test

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that can be viewed with landscape and portrait mode. I'm
I'm trying to create a very simple PHP CLI application that can be run
I have an application that can filter a datagridview based on date using a
I have an application that can potentially have hundreds of memory mapped, i.e., mmap()
I have a web application that can load plugins through reflection. It currently uses
I currently have a mobile application that can record speech as either a WAV
I have a java application that people can log into (and do various things
I have a web application that you can use to import information from another
I have application that is up more than 3 days. I can see in
I'm writing a drawing application that includes shapes that can have children. When I

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.