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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:20:06+00:00 2026-05-31T05:20:06+00:00

I am developing application which intend to be cross platform. I used to use

  • 0

I am developing application which intend to be cross platform. I used to use Windows Messages but now I am dropping it out. I replaced messages with callbacks but regardless I can use different technologies I am not aware of different possibilites when not using windows messages.

Well I have main exe aplication and some dll plugins. I have some objects and threads in dll and I would like to notify main application about some changes that DLL made to data structure.

As I said I am currently working with some callbacks. To provide compatibility with different languages (C++, VB, C#) I have non-object type of callback. I am not sure if other languages supports callback of object.

So my questions are:

  • What are the alternatives (cross-platform) to windows messages? Can callbacks replace messages?
  • Do other languages support callback of object?
  • I guess other languages have different technologies as alternative to messages?
  • 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-31T05:20:07+00:00Added an answer on May 31, 2026 at 5:20 am

    So my questions are:
    What are the alternatives (cross-platform) to windows messages? Can callbacks replace messages?

    Yes you can replace messages with callbacks.

    Do other languages support callback of object?

    You shouldn’t use object methods as callbacks. Common practice in portable code is use of handles (notify calling convention):

    DLL source:

    type
      THandle = LongWord;
      {$IF SizeOf(THandle) < SizeOf(Pointer))}
      {$MESSAGE Error 'Invallid handle type'}
      {$ENDIF}
    
      TCallback = procedure(const aHandle: THandle); cdecl;
    
      var
          gCallback: record
            Routine: TCallback;
            Obj: TObject;
            Info: string
      end;
    
      function Object2Handle(const aObj: TObject): THandle;
      begin
        Result:= THandle(Pointer(aObj))
      end;
    
      function Handle2Object(const aHandle: THandle; out aObj: TObject): Boolean;
      begin
        if gCallback.Obj <> nil then
          if aHandle = Object2Handle(gCallback.Obj) then
          begin
            aObj:= gCallback.Obj;
            Result:= true;
            Exit // WARRNING: program flow disorder
          end;
    
        aObj:= nil;
        Result:= false
      end;
    
    procedure DoCallback();
    begin
      if Assigned(gCallback.Routine) then
        gCallback.Routine(Object2Handle(gCallback.Obj))
    end;
    
    procedure SetupCallback(const aCallback: TCallback); cdecl;
    begin
      gCallback.Routine:= aCallback;
    end;
    
    procedure DoSomething(const aHandle: THandle; out aInfo: string); cdecl;
    var
      O: TObject;
    begin
      if Handle2Object(aHandle, O) then
        aInfo:= Format('%s class object %s', [O.ClassName(), gCallback.Info])
    end;
    
    procedure Test();
    begin
      gCallback.Obj:= TStream.Create();
      try
        gCallback.Info:= 'created';
        DoCallback();
      finally
        FreeAndNil(gCallback.Obj)
      end;
      gCallback.Obj:= TMemoryStream.Create();
      try
        gCallback.Info:= 'will be freed';
        DoCallback();
      finally
        FreeAndNil(gCallback.Obj)
      end
    end;
    
    exports
      SetupCallback,
      DoSomething,
      Test;
    

    Executable source:

    procedure Cb(const aHandle: THandle); cdecl;
    const
      STUPID: THandle = 1;
      EQUALLY_STUPID = $DEAD;
    var
      S: string;
    begin
      DoSomething(STUPID, S);
      DoSomething(aHandle, S);
      DoSomething(EQUALLY_STUPID, S)
    end;
    
    begin
      SetupCallback(@Cb);
      Test()
    end.
    

    Edited: You can’t shoot yourself in you leg now.

    I guess other languages have different technologies as alternative to messages?

    OS have a few message alternatives. However not many truly portable.

    You can also use:

    • sockets,
    • (IMO too big in this case?) ready messaging system (my favorite 0MQ)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing an application which make use of display lists offered by OpenGL. My
i am developing application which send and receive data between two computers but there
I am developing an application in which I used VideoView to play a video.
I'm developing an asp.net application which has Windows Authentication enabled(anonymous access disabled). I've created
I intend to start developing an ASP.NET application and I am wondering which database
I am developing windows application which supports two language Arabic and English. I want
I am developing c# application in which to send and get requests we use
I am developing an application which connects devices over bluetooth and exchanges messages. It
I am developing a new application which hopefully will use a barcode reader to
Im developing one application which used SeekBar to control volume in MediaPlayer. The problem

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.