const
MB_TIMEDOUT = $7D00;
function MessageBoxTimeOut(hWnd: HWND; lpText: PChar; lpCaption: PChar; uType:
UINT; wLanguageId: WORD; dwMilliseconds: DWORD): Integer; stdcall; external
user32 name 'MessageBoxTimeoutA';
implementation
procedure TForm1.Button1Click(Sender: TObject);
var
BoxResult : Integer;
BoxFlags : Integer;
begin
BoxFlags := MB_YESNO or MB_SETFOREGROUND or MB_SYSTEMMODAL or
MB_ICONINFORMATION;
BoxResult := MessageBoxTimeout(Application.Handle,
'Ce message se fermera au bout de 5 secondes.',
'Teste', BoxFlags, 0, 5000);
case BoxResult of
IDYES:
ShowMessage('Oui');
IDNO:
ShowMessage('Non');
MB_TIMEDOUT:
ShowMessage('Temps écoulé');
end;
end;