home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 13
/
mediashare_13.zip
/
mediashare_13
/
ZIPPED
/
PROGRAM
/
WTJ9403.ZIP
/
FOLEY
/
EXMETER.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-04-07
|
4KB
|
147 lines
{$S-,R-,V-,I-,B-,F-,W-,A-,G+,X+}
{*********************************************************}
{* EXMETER.PAS 1.00 *}
{* Copyright (c) Brian Foley 1993. *}
{* All rights reserved. *}
{*********************************************************}
program ExMeter;
{-Sample meter control application}
uses
WinTypes, WinProcs,
{$IFDEF Ver15}
wObjects,
{$ELSE}
OWindows, ODialogs,
{$ENDIF}
BWCC, Meter;
{$IFDEF Ver10}
Error: This program does not work with TPW 1.0!
{$ENDIF}
{$R EXMETER.RES}
type
PMainWindow = ^TMainWindow;
TMainWindow = object(TDlgWindow)
Meter : PMeterControl;
Text : PStatic;
OKBtn : PButton;
CancelBtn : PButton;
constructor Init(AParent : PWindowsObject);
procedure Update(N : Word);
end;
OurApplication = object(TApplication)
Count : LongInt;
Percent : Byte;
procedure InitMainWindow; virtual;
{$IFDEF Ver15}
procedure IdleAction; virtual;
{$ELSE}
function IdleAction : Boolean; virtual;
{$ENDIF}
procedure MessageLoop; virtual;
end;
var
OurApp : OurApplication;
{TMainWindow}
constructor TMainWindow.Init(AParent : PWindowsObject);
begin
TDlgWindow.Init(AParent, 'EXMETER');
{initialize control objects}
Text := New(PStatic, InitResource(@Self, 100, 30));
Meter := New(PMeterControl, InitResource(@Self, 101));
OKBtn := New(PButton, InitResource(@Self, id_OK));
CancelBtn := New(PButton, InitResource(@Self, id_Cancel));
end;
procedure TMainWindow.Update(N : Word);
begin
if hWindow <> 0 then begin
{update meter value}
Meter^.SetMeterValue(N);
{when we get to 100%, change the message and switch to the OK button}
if N = 100 then begin
Text^.SetText('Installation complete!');
ShowWindow(OKBtn^.hWindow, sw_Normal);
ShowWindow(CancelBtn^.hWindow, sw_Hide);
{wm_NextDlgCtl works better than SetFocus in this situation}
SendMessage(hWindow, wm_NextDlgCtl, OKBtn^.hWindow, 1);
end;
end;
end;
{OurApplication}
procedure OurApplication.InitMainWindow;
begin
MainWindow := New(PMainWindow, Init(nil));
Count := GetTickCount;
Percent := 0;
end;
{$IFDEF Ver15}
procedure OurApplication.IdleAction;
{$ELSE}
function OurApplication.IdleAction : Boolean;
{$ENDIF}
begin
{$IFNDEF Ver15}
IdleAction := False;
{$ENDIF}
if Percent < 100 then begin
if GetTickCount >= Count+200 then begin
Inc(Percent);
PMainWindow(MainWindow)^.Update(Percent);
Count := GetTickCount;
end;
{$IFNDEF Ver15}
IdleAction := True;
{$ENDIF}
end;
end;
procedure OurApplication.MessageLoop;
var
Message : TMsg;
IsDone : Boolean;
begin
IsDone := False;
repeat
if PeekMessage(Message, 0, 0, 0, pm_Remove) then begin
if Message.Message = wm_Quit then
IsDone := True
else if not ProcessAppMsg(Message) then begin
TranslateMessage(Message);
DispatchMessage(Message);
end
end
else
{$IFDEF Ver15}
IdleAction;
{$ELSE}
if not IdleAction then
WaitMessage;
{$ENDIF}
until IsDone;
Status := Message.wParam;
end;
begin
OurApp.Init('EXMETER');
OurApp.Run;
OurApp.Done;
end.