Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-07

simple messagebox for windows

6 messages · 5 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

John Lee

I need a simple messagebox (or msgbox) for windows - that doesn't depend (use) a whole load of lcl or other stuff - did I miss this in the fpc docs - sounds as if it ought to be in sysutils - but isn't! I just want to output a message to a titled box, and maybe get an ok button press, with a n sec timeout.

Seems as if 'dialogs' has the functionality, but it not sure what other stuff I need to compile it.

Alternatively maybe I should make my own using the windows api- anyone got a short example of this?

Any ideas welcome...

John

Reply by email

Felipe Monteiro de Carvalho
to John Lee
John Lee wrote 5 lines
I need a simple messagebox (or msgbox) for windows - that doesn't depend (use) a whole load of lcl or other stuff - did I miss this in the fpc docs - sounds as if it ought to be in sysutils - but isn't!  I just want to output a message to a titled box, and maybe get an ok button press, with a n sec timeout.

SysUtils? SysUtils is part of the RTL, there is no cross-platform GUI routine in the entire RTL. The RTL and FCL don't contain GUI code because that would make the development of non-gui software a mess.

The simplest option is using Windows.MessageBox (which obviously only works in Windows)

MSDN docs: http://msdn.microsoft.com/en-us/library/ms645505(VS.85).aspx

Or use your IDE to find the declaration of Windows.MessageBox

Felipe Monteiro de Carvalho

Reply by email

John Lee
to Felipe Monteiro de Carvalho

Trying to implement a win messagebox with timeout, I googled & found a mention of an undocumented messageboxtimeout api & its delphi call.

See noddy program below - works for messagebox() with boolean false, unfortunately fails with boolean true & gives 'not found in user32' message in my xp.

Anyone know if there is a messageboxtimeout or similar functionality in win or a fpc implementation of this?

John

uses windows;
function MessageBoxtimeout(w1:longint;l1,l2:pointer;w2:longint;l,t:longint)
 :longint; stdcall; external 'user32' name 'MessageBoxtimeoutA';
function MessageBox(w1:longint;l1,l2:pointer;w2:longint)
 :longint; stdcall; external 'user32' name 'MessageBoxA';
var errorbuf:string;
    l,n,t:longint;
begin
 errorbuf:='1234567';
 l:=0;
 t:=1000;
 if false
  then
   n:=MessageBoxtimeout(0,@ErrorBuf[1],pchar('Error'),0,l,t)
  else
   n:=MessageBox(0,@ErrorBuf[1],pchar('Error'),0);
 writeln(n);
end.

Reply by email

José Mejuto
to John Lee

Hello FPC-Pascal,

Tuesday, July 5, 2011, 6:54:37 PM, you wrote:

JL> Trying to implement a win messagebox with timeout, I googled & found a JL> mention of an undocumented messageboxtimeout api & its delphi call.

JL> See noddy program below - works for messagebox() with boolean false, JL> unfortunately fails with boolean true & gives 'not found in user32' message JL> in my xp.

MessageBoxtimeoutA = NO
MessageBoxTimeoutA = YES

Check the casing (capital T). For XP or later.

Best regards, José

Reply by email

Unknown author
to José Mejuto

Thanks - thought win stuff always case independent! John

José Mejuto wrote
Hello FPC-Pascal,
Tuesday, July 5, 2011, 6:54:37 PM, you wrote:
JL> Trying to implement a win messagebox with timeout, I googled & found a JL> mention of an undocumented messageboxtimeout api & its delphi call.
Show quoted text 6 lines
JL> See noddy program below - works for messagebox() with boolean false, JL> unfortunately fails with boolean true & gives 'not found in user32' message JL> in my xp.
MessageBoxtimeoutA = NO MessageBoxTimeoutA = YES
Check the casing (capital T). For XP or later.
Show quoted text 5 lines
-- Best regards, José
Show quoted text 5 lines
_______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email