home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1994 #1
/
monster.zip
/
monster
/
PROG_PAS
/
TVTOYS.ZIP
/
COMSLECT.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1994-01-03
|
5KB
|
178 lines
(***************************************************************************
COMSelect unit
Select COM port dialog
PJB October 8, 1993, CompuServe mail to INTERNET:d91-pbr@nada.kth.se
Copyright 1993, All Rights Reserved
Free source, use at your own risk.
If modified, please state so if you pass this around.
This is just some code I used for a project of mine where the
baud rate and parity were fixed. You'll have to make another dialog
if you want to control more parameters at the same time.
***************************************************************************)
unit COMSlect;
interface
uses
App, Objects, Dialogs, Views, Validate,
toyPrefs, {$I hcFile}
TVUtils;
var
COMDataRec :
record
SelectCOM : Word; {RadioButtons}
COMAdr : Word; {Inputline (hex)}
IRQ : LongInt; {Inputline (Range)}
end;
function MakeCOMSelectDialog:PDialog;
(***************************************************************************
***************************************************************************)
implementation
type
PCOMRadio = ^TCOMRadio;
TCOMRadio =
object (TRadioButtons)
procedure Draw; virtual;
end;
var
COMAdr : PInputLine;
COMIRQ : PInputLine;
COMRadio : PCOMRadio;
(***************************************************************************
***************************************************************************)
(*******************************************************************
Updates the input lines if the user changes COM port
*******************************************************************)
procedure TCOMRadio.Draw;
var
l : Longint;
begin
inherited Draw;
if Sel<4 then
begin
COMAdr^.Options:=COMAdr^.Options and not ofSelectable;
COMIRQ^.Options:=COMIRQ^.Options and not ofSelectable;
COMAdr^.SetData(MemW[Seg0040:Sel*2]);
l:=4-(Sel and 1);
COMIRQ^.SetData(l);
end
else
begin
COMAdr^.Options:=COMAdr^.Options or ofSelectable;
COMIRQ^.Options:=COMIRQ^.Options or ofSelectable;
end;
end;
(***************************************************************************
***************************************************************************)
(*******************************************************************
Scan through the BIOS entries for non-zero COM port addresses
*******************************************************************)
procedure CheckActiveCOMS;
var
i : Integer;
Mask : Word;
begin
Mask:=0;
for i:=0 to 3 do
if MemW[Seg0040:i*2]=0 then
Inc(Mask, 1 SHL i);
if COMRadio<>Nil then
COMRadio^.SetButtonState(Mask, False);
end;
(*******************************************************************
This code generated by Dialog Design 4.0 available by anonymous
ftp to garbo.uwasa.fi /pc/turbovis. Thanks to David Baldwin
*******************************************************************)
function MakeCOMSelectDialog:PDialog;
var
Dlg : PDialog;
R : TRect;
Control : PView;
begin
R.Assign(19,14,61,27);
New(Dlg, Init(R, 'COM Port Selection'));
Dlg^.Options := $1343;
R.Assign(6,3,18,8);
COMRadio := New(PCOMRadio, Init(R,
NewSItem('COM ~1~',
NewSItem('COM ~2~',
NewSItem('COM ~3~',
NewSItem('COM ~4~',
NewSItem('~O~ther',Nil)))))));
Dlg^.HelpCtx := hctoyCOMRadio;
Dlg^.Insert(COMRadio);
R.Assign(5,2,14,3);
Dlg^.Insert(New(PLabel, Init(R, 'COM ~P~ort', COMRadio)));
R.Assign(25,4,31,5);
COMAdr := New(PInputLine, Init(R, 4));
COMAdr^.HelpCtx := hctoyCOMPortAdr;
Dlg^.Insert(COMAdr);
COMAdr^.Validator := New(PHexValidator, Init(0,$FFFF));
R.Assign(24,3,36,4);
Dlg^.Insert(New(PLabel, Init(R, 'COM ~A~ddress', COMAdr)));
R.Assign(25,7,29,8);
COMIRQ := New(PInputLine, Init(R, 2));
COMIRQ^.HelpCtx := hctoyCOMIRQ;
Dlg^.Insert(COMIRQ);
COMIRQ^.Validator := New(PRangeValidator, Init(0, 16));
COMIRQ^.Validator^.Options := voTransfer;
R.Assign(24,6,28,7);
Dlg^.Insert(New(PLabel, Init(R, '~I~RQ', COMIRQ)));
R.Assign(4,10,14,12);
Control := New(PButton, Init(R, 'O~K~', cmOK, bfDefault));
Control^.HelpCtx := hcOK;
Dlg^.Insert(Control);
R.Assign(16,10,26,12);
Control := New(PButton, Init(R, 'Cancel', cmCancel, bfNormal));
Control^.HelpCtx := hcCancel;
Dlg^.Insert(Control);
R.Assign(28,10,38,12);
Control := New(PButton, Init(R, 'Help', cmHelp, bfNormal));
Dlg^.Insert(Control);
R.Assign(32,4,35,5);
Control := New(PStaticText, Init(R, 'hex'));
Dlg^.Insert(Control);
Dlg^.SelectNext(False);
CheckActiveCOMS;
MakeCOMSelectDialog:=Dlg;
end;
end.