BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Pause im Programm

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc
View previous topic :: View next topic  
Author Message
Joachim Tilgner
Guest





PostPosted: Mon Oct 31, 2005 1:34 pm    Post subject: Pause im Programm Reply with quote



Hallo,

wie kann ich in einem Programm eine Pause programmieren und doch das
Programm-Fenster in der Programmpause per Maus-Click minimieren?

Danke.

Joachim Tilgner

Back to top
Maarten Wiltink
Guest





PostPosted: Mon Oct 31, 2005 2:03 pm    Post subject: Re: Pause im Programm Reply with quote



"Joachim Tilgner" <tilgner (AT) ifg-adlershof (DOT) de> wrote


Quote:
wie kann ich in einem Programm eine Pause programmieren und doch das
Programm-Fenster in der Programmpause per Maus-Click minimieren?

Can you minimise the application while it's _not_ "pausing"? Your program
is probably a long list of event handlers; every handler, once it's called,
runs to completion and Windows is out of the loop for that time. It should
not be very hard to put some job on hold and continue it from the next
event handler, which you then wire to a timer component.

Groetjes,
Maarten Wiltink



Back to top
Andreas Koch
Guest





PostPosted: Mon Oct 31, 2005 5:43 pm    Post subject: Re: Pause im Programm Reply with quote



Joachim Tilgner wrote:

Quote:
wie kann ich in einem Programm eine Pause programmieren und doch das
Programm-Fenster in der Programmpause per Maus-Click minimieren?

Willkommen in der wunderbaren Welt der eventbasierten Programmierung ;-)

Schlecht:
DoSomeThing;
Sleep(10000);
DoOtherThing;

Nicht wirklich hübsch:
DoSomeThing;
For n:=1 to 100 do
begin
Application.ProcessMessages;
Sleep(100);
end;
DoOtherThing;

Sauberer:
TTimer aufs Form Droppen
Interval:=10000;
Enabled:=False;

...
DoSomeThing
Timer1.Enabled:=True;
end;

Procedure Timer1Timer (per Doppelclick aufs Event vom Timer
erzeugen lassen)

begin
Timer1.Enabled:=False;
DoOtherthing;
end;


Back to top
J French
Guest





PostPosted: Tue Nov 01, 2005 10:04 am    Post subject: Re: Pause im Programm Reply with quote

On Mon, 31 Oct 2005 14:34:20 +0100, Joachim Tilgner
<tilgner (AT) ifg-adlershof (DOT) de> wrote:

Quote:
Hallo,

wie kann ich in einem Programm eine Pause programmieren und doch das
Programm-Fenster in der Programmpause per Maus-Click minimieren?


Here is another version similar to that of Andreas, but more
'procedural'

The difference is that WaitMessage is used to yield to the OS, but the
Timer acts as a 'Message Pump' to ensure that the system gets a
Message that allows it to return from WaitMessage

It will return unexpectedly every 49.7 days

The whole thing should really be wrapped in a Class, but like this it
is simpler to see what is going on.

Procedure YieldTicks( Const Ticks:Integer );
Var
Bump :Integer;
Count :DWord;
Begin
Bump := Ticks Div 10;
If Bump <= 0 Then
Bump := 10;
// Use a Timer as a message pump
Form1.Timer1.Interval := Bump;
Form1.Timer1.Enabled := True;
Count := GetTickCount;
While Abs(GetTickCount - Count) < Ticks Do
Begin
WaitMessage;
Form1.Caption := Form1.Caption + '.';
Application.ProcessMessages;
End;
Timer1.Enabled := False;
End;


procedure TForm1.Button1Click(Sender: TObject);
Var
ST :TDateTime;
begin
ST := Time;
YieldTicks( 5000 );
ShowMessage( 'Done'#13
+ TimeToStr( ST ) + #13
+ TimeToStr( Time ) );
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
// Do Nothing, but we need it here
// for the Timer Tick to generate a Msg
end;


Back to top
J French
Guest





PostPosted: Tue Nov 01, 2005 11:35 am    Post subject: Re: Pause im Programm Reply with quote

On Tue, 1 Nov 2005 10:04:25 +0000 (UTC), [email]erewhon (AT) nowhere (DOT) uk[/email] (J French)
wrote:

Here is a tighter version :-

Var
DoneFlag :Boolean;

Procedure TimerProc( Const Hnd, ID, Ev, SysTime :DWORD );
Begin
DoneFlag := True;
End;

Procedure YieldTicks( Const Ticks :Integer );
Var
Hnd :Integer;
Begin
DoneFlag := False;
Hnd := Windows.SetTimer( 0, 123, Ticks, Addr(TimerProc) );
While DoneFlag = False Do
Begin
WaitMessage;
Application.ProcessMessages;
End;
Windows.KillTimer( 0, Hnd );
End;


procedure TForm1.Button1Click(Sender: TObject);
Var
HTime :TDate;
begin
HTime := Time;
YieldTicks( 5000 );
ShowMessage( TimeToStr( HTime ) + #13
+ TimeToStr( Time ) );
end;

Back to top
Paul E. Schoen
Guest





PostPosted: Thu Jan 12, 2006 3:11 am    Post subject: Re: Pause im Programm Reply with quote

This seems to be very similar to my problem, which is discussed in my thread
"Delay or suspend Application waiting for thread to complete". I have
written a unit that performs this function as Delay(mSec), and may improve
on it.

Paul E. Schoen

"J French" <erewhon (AT) nowhere (DOT) uk> wrote

Quote:
On Tue, 1 Nov 2005 10:04:25 +0000 (UTC), [email]erewhon (AT) nowhere (DOT) uk[/email] (J French)
wrote:

Here is a tighter version :-

snip




Back to top
La Mygale
Guest





PostPosted: Thu Jan 12, 2006 1:48 pm    Post subject: Windows Popup Menu Reply with quote

Hi people.
In a listbox showing file names, I would like a right-click to open a
popup menu similar to the Windows explorer popup menu (the one with
Open, Open with..., Send to, Copy, Paste, etc).
How can I do that ?
Thank you
LM
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.