ich suche so was wie
showmessage(messagetext, timeout_in_ms)
gibt es so was ? (ja, ich weiss, ich kann mir so was proggen, will ich aber nicht wenns das ferig schon gibt)
gruss und dank
w.

Code: Alles auswählen
var
aDialog1,aDialog2:TForm;
function TimeoutMsg(const aMessage: string; const aTimeOut: word): TModalResult;
var
aStart,aPast: longword;
aBitmap: TCustomBitmap;
x: integer;
pDialog: ^TForm;
begin
//close old dialog if a new one is opened
if assigned(aDialog1) then
begin
aDialog1.ModalResult:=mrCancel;
aDialog1.Hide;
aDialog1:=nil;
pDialog:=addr(aDialog2);
end else
begin
if assigned(aDialog2) then
begin
aDialog2.ModalResult:=mrCancel;
aDialog2.Hide;
aDialog2:=nil;
end;
pDialog:=addr(aDialog1);
end;
//just cancel dlg
if aTimeOut=0 then
exit;
pDialog^:=CreateMessageDialog(aMessage,mtConfirmation,[mbYes,mbNo]);
with pDialog^ do
try
FormStyle:=fsStayOnTop;
Position:=poMainFormCenter;
Show;//not modal
aStart:=GetTickCount;
aBitmap:=GetDialogIcon(idDialogConfirm);
aBitmap.Canvas.Brush.Style:=bsSolid;
aBitmap.Canvas.Pen.Style:=psClear;
aBitmap.Canvas.Brush.Color:=clBtnFace;
x:=0;
repeat
aPast:=(GetTickCount-aStart) div 1000;
if (aPast>0) and (aPast<>x) then
begin
Canvas.Brush.Color:=clGreen;
Canvas.FillRect(Bounds(0,0,round(Width*aPast/aTimeOut),2));
if aTimeOut-aPast<10 then
Caption:=Language.Plural(rPoll_TimeOut,aTimeOut-aPast);
x:=aPast;
end;
Enabled:=ModalResult<>mrCancel;
try
sleep(1);
Application.ProcessMessages;
except
raise;
end;
if Application.Terminated then
ModalResult:=mrCancel;
if ModalResult<>mrNone then
break;
if (aPast>=aTimeOut) then
ModalResult:=mrTimeout;
until (ModalResult<>mrNone) or (Visible=false);
Result:=ModalResult;
finally
aBitmap.Free;
Free;
pDialog^:=nil;
end;
end;
...
if TimeoutMsg('Hello World',30)=mrYes then...
Hallo Wolfgang,wbeppler hat geschrieben:ich suche so was wie
showmessage(messagetext, timeout_in_ms)
gibt es so was ?
Code: Alles auswählen
...
type
{ TTimedMsgForm }
TTimedMsgForm = class(TForm)
Timer1 : TTimer;
procedure FormActivate(Sender : TObject);
procedure Timer1Timer(Sender : TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
TimedMsgForm : TTimedMsgForm;
implementation
{$R *.lfm}
{ TTimedMsgForm }
procedure TTimedMsgForm.FormActivate(Sender : TObject);
begin
Timer1.Enabled := true;
Timer1.Interval := 5000;
end;
procedure TTimedMsgForm.Timer1Timer(Sender : TObject);
begin
Timer1.Enabled := false;
Close;
end;
end.
Code: Alles auswählen
TimedMsgForm.ShowModal;