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 625437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:18:33+00:00 2026-05-13T19:18:33+00:00

I frequently find myself declaring a simple procedure type TMessageProc = procedure(const AMsg: String);

  • 0

I frequently find myself declaring a simple procedure type

  TMessageProc  = procedure(const AMsg: String);

in Delphi. The purpose is to allow passing callback procedures to processing functions so that they can update the user interface without having to be aware of the user interface.

Surely this must be a common paradigm in Delphi programming. Does there exist an standard procedure type declaration in one of the commonly used units that I can use for this? Unfortunately, with the roll-my-own approach I’m not entirely consistent between projects in the way I name or declare the type.

  • 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-13T19:18:34+00:00Added an answer on May 13, 2026 at 7:18 pm

    The “common Delphi paradigm” is event (event handler). Eg, you can write

    type
      TMessageProc  = procedure(const AMsg: String);
    
    procedure DoSomething(OnProgress: TMessageProc);
    begin
    //  ...
      if Assigned(OnProgress) then OnProgress('123');
    //  ...
    end;
    

    Normally the events in Delphi are implemented as methods, so the standard Delphi code for the above example is:

    type
      TForm1 = class(TForm)
        Button1: TButton;
        Label1: TLabel;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
        procedure ShowProgress(const AMsg: String);
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    type
      TMessageProc  = procedure(const AMsg: String) of object;  // declare event type
    
    procedure DoSomething(OnProgress: TMessageProc);
    begin
    //  ...
      if Assigned(OnProgress) then OnProgress('123');   // trigger event
    //  ...
    end;
    
    procedure TForm1.ShowProgress(const AMsg: String);  // event handler
    begin
      Label1.Caption:= AMsg;
      Application.ProcessMessages;
    end;
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      DoSomething(ShowProgress);
    end;
    

    There is nothing wrong in declaring your personal event types, but sure you can find standard events in VCL. For example, classes.pas unit containes the declaration

      TGetStrProc = procedure(const S: string) of object;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 338k
  • Answers 338k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer After lots of reading and searching I have found the… May 14, 2026 at 4:18 am
  • Editorial Team
    Editorial Team added an answer Your query should work fine. The only thing you should… May 14, 2026 at 4:18 am
  • Editorial Team
    Editorial Team added an answer I suppose you can use placement new. int arr[4]; //uninitialized… May 14, 2026 at 4:18 am

Related Questions

I frequently find myself writing code like this: List<int> list = new List<int> {
When persisting domain objects using Grails/GORM I frequently find myself wondering why a save()
Regarding the classic test pattern of Arrange-Act-Assert , I frequently find myself adding a
When writing Perl scripts I frequently find the need to obtain the current time
I love list comprehensions in Python, because they concisely represent a transformation of a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.