Question : Getting the Windows.MessageBox handle

A simple beginner question...

I have a collection of several user defined functions in the formless unit.
Can't figure out just now if it is possible to call Windows.MessageBox here... The problem seems to be getting the Handle?
The basic idea here is to avoid problems such as ShowMessage(), which can be hidden behind a modal opened form.
procedure CustomMsgBox(msg,capt:string);
  // Example :  CustomMsgBox('This i a message to the user','This is the Caption');
  Windows.MessageBox(handle, PChar(msg), PChar(capt), MB_TOPMOST);

Answer : Getting the Windows.MessageBox handle

Maybe I've misunderstood something.
Do you need to have a topmost MessageBox even if there's any other modal form showed?

If this is the case you can again use messagebox with some additional parameters.

In example, calling

MessageBox(0,'Hello, this is a Console Application','Hello',MB_SYSTEMMODAL or MB_SETFOREGROUND or MB_TOPMOST or MB_ICONHAND) ;

You'll have a topmost Message dialog box with a OK button

the most important piece is the last parameter. The "MB_SYSTEMMODAL or MB_SETFOREGROUND or MB_TOPMOST" ensures the message box is system modal, top most and becomes the foreground window.

    * MB_SYSTEMMODAL flag ensures that the user must respond to the message box before continuing work in the window identified by the hWnd parameter.
    * MB_TOPMOST flag specifies that the message box should be placed above all non-topmost windows and should stay above them, even when the window is deactivated.
    * MB_SETFOREGROUND flag ensures that the message box becomes the foreground window.

Random Solutions  
programming4us programming4us