-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainFormUnit.pas
More file actions
618 lines (566 loc) · 15.5 KB
/
Copy pathMainFormUnit.pas
File metadata and controls
618 lines (566 loc) · 15.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
unit MainFormUnit;
interface
uses
Windows,
SysUtils,
Classes,
Controls,
Forms,
Dialogs,
StdCtrls,
{ My units.. }
SCSIUnit,
WNASPI32Unit,
SPC_Unit,
MMC1Unit,
CDFormUtilsUnit,
CDToImageFormUnit,
CommonCDSettingsUnit,
ImageToCDFormUnit,
ATIP_form_Unit,
MSR_form_Unit,
FORM_read_track_info_Unit,
FORM_read_disc_info_Unit,
Tools_Unit,
XPMan, ExtCtrls;
type
TForm1 = class(TForm)
SectorViewerBtn: TButton;
TOCViewerBtn: TButton;
CDToImageBtn: TButton;
Label1: TLabel;
Label2: TLabel;
BTN_image_to_CD: TButton;
BTN_ATIP_form: TButton;
BTN_MSR: TButton;
XPManifest1: TXPManifest;
BTN_read_track_info: TButton;
BTN_read_disc_info: TButton;
RG_interface: TRadioGroup;
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure SectorViewerBtnClick(Sender: TObject);
procedure TOCViewerBtnClick(Sender: TObject);
procedure CDToImageBtnClick(Sender: TObject);
procedure BTN_image_to_CDClick(Sender: TObject);
procedure BTN_ATIP_formClick(Sender: TObject);
procedure BTN_MSRClick(Sender: TObject);
procedure BTN_read_track_infoClick(Sender: TObject);
procedure BTN_read_disc_infoClick(Sender: TObject);
procedure RG_interfaceClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
SCSI : T_SCSI;
CDFormUtils : T_CDFormUtils;
Form4 : TForm4;
Form5 : TForm5;
MSR_form : T_MSR_form;
Form6 : TForm6;
Form7 : TForm7;
CommonCDSettings : T_CommonCDSettings;
Procedure Disable_BTNs;
Procedure Enable_BTNs;
Procedure Open_SPT;
Procedure Open_WNASPI32;
Procedure Calc_new_height_top(in_height : Integer; in_top : Integer; Var new_height : Integer; Var new_top : Integer);
Procedure Calc_new_width_left(in_width : Integer; in_left : Integer; Var new_width : Integer; Var new_left : Integer);
Function Calc_top(in_height : Integer; in_top : Integer) : Integer;
Function Calc_left(in_width : Integer; in_left : Integer) : Integer;
Procedure SetSectorViewerFormNil;
Procedure SetTOCViewerFormNil;
Procedure SetCDToImageFormNil;
Procedure SetImageToCDFormNil;
procedure SetATIPFormNil;
procedure Set_MSRFormNil;
procedure Set_form_read_track_info_Nil;
procedure Set_form_read_disc_info_Nil;
end;
{ Global variables.. }
var
Form1: TForm1;
implementation
{ Private to this unit.. }
Uses
SectorViewerUnit,
TOCViewerUnit;
Var
Form2 : TForm2;
Form3 : TForm3;
ATIP_form : TATIP_form;
{$R *.DFM}
Procedure TForm1.Open_SPT;
Begin
//Create SCSI class object for use with Win32 DeviceIoControl() & SCSI PASS THRUOGH
SCSI:=T_SCSI.Create(U_METHOD_SCSI_PASS_THRU);
CommonCDSettings:=T_CommonCDSettings.Create;
CDFormUtils:=T_CDFormUtils.Create;
RG_interface.ItemIndex:=0;
Enable_BTNs;
End;
Procedure TForm1.Open_WNASPI32;
Var
s : String;
Begin
//Create SCSI class object for use with Adaptec's WNASPI32
SCSI:=T_SCSI.Create(U_METHOD_WNASPI);
//Try to open and link to WNASPI32.DLL
If SCSI.SPC_any_link.WNASPI32.Get_OpenASPIStatus=USER_WNASPI32_OPENASPI_DLL_LOAD_ERR Then
Begin
Show;
s:='WNASPI32.DLL could not be loaded.' + Chr(10) + Chr(13);
s:=s + 'Install or reinstall WinASPI32 drivers.';
MessageDlg(s, mtError, [mbOk], 0);
Disable_BTNs;
//Application.Terminate;
End
Else
Begin
If SCSI.SPC_any_link.WNASPI32.Get_OpenASPIStatus=USER_WNASPI32_OPENASPI_FX_IMPORT_ERR Then
Begin
Show;
s:='Could not import the minimum required functions from WNASPI32.DLL.' + Chr(10) + Chr(13);
s:=s + 'You need to install updated WinASPI32 drivers.';
MessageDlg(s, mtError, [mbOk], 0);
Disable_BTNs;
//Application.Terminate;
End
Else
Begin
If SCSI.SPC_any_link.WNASPI32.Get_SRB_status_OK=False Then
Begin
Show;
s:='Initialisation: GetASPI32SupportInfo function call failed.' + Chr(10) + Chr(13);
s:=s + 'WinASPI32 driver error.' + Chr(10) + Chr(13);
s:=s + SCSI.SPC_any_link.WNASPI32.Get_SRB_err_msg;
MessageDlg(s, mtError, [mbOk], 0);
Disable_BTNs;
//Application.Terminate;
End
Else
Begin
CommonCDSettings:=T_CommonCDSettings.Create;
CDFormUtils:=T_CDFormUtils.Create;
CommonCDSettings.Set_default_timeout_buf;
RG_interface.ItemIndex:=1;
Enable_BTNs;
End;
End;
End;
End;
procedure TForm1.FormCreate(Sender: TObject);
begin
If IsWinNT4OrHigher Then
Begin
Open_SPT;
End
Else
Begin
Open_WNASPI32;
End;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
CommonCDSettings.Free;
CDFormUtils.Free;
SCSI.Free;
end;
Procedure TForm1.Disable_BTNs;
Begin
SectorViewerBtn.Enabled:=False;
TOCViewerBtn.Enabled:=False;
CDToImageBtn.Enabled:=False;
BTN_image_to_CD.Enabled:=False;
BTN_MSR.Enabled:=False;
BTN_ATIP_form.Enabled:=False;
BTN_read_track_info.Enabled:=False;
BTN_read_disc_info.Enabled:=False;
End;
Procedure TForm1.Enable_BTNs;
Begin
SectorViewerBtn.Enabled:=True;
TOCViewerBtn.Enabled:=True;
CDToImageBtn.Enabled:=True;
BTN_image_to_CD.Enabled:=True;
BTN_MSR.Enabled:=True;
BTN_ATIP_form.Enabled:=True;
BTN_read_track_info.Enabled:=True;
BTN_read_disc_info.Enabled:=True;
End;
Procedure TForm1.Calc_new_height_top(in_height : Integer; in_top : Integer; Var new_height : Integer; Var new_top : Integer);
Begin
new_height:=Screen.DesktopHeight-200;
new_top:=in_top - (new_height-in_height) Div 2;
End;
Procedure TForm1.Calc_new_width_left(in_width : Integer; in_left : Integer; Var new_width : Integer; Var new_left : Integer);
Begin
new_width:=Screen.DesktopWidth-500;
new_left:=in_left - (new_width-in_width) Div 2;
End;
Function TForm1.Calc_top(in_height : Integer; in_top : Integer) : Integer;
Var
new_top : Integer;
Begin
//Check if form will be cut off at the top of the screen.
If in_top<0 Then
Begin
new_top:=0;
End
Else
Begin
//Check if form will be cut off at the bottom of the screen.
If (in_top+in_height)>Screen.DesktopHeight Then
Begin
new_top:=Screen.DesktopHeight-in_height;
End
Else
Begin
new_top:=-1;
End;
End;
Result:=new_top;
End;
Function TForm1.Calc_left(in_width : Integer; in_left : Integer) : Integer;
Var
new_left : Integer;
Begin
//Check if form will be cut off at the left of the screen.
If in_left<0 Then
Begin
new_left:=0;
End
Else
Begin
//Check if form will be cut off at the right of the screen.
If (in_left+in_width)>Screen.DesktopWidth Then
Begin
new_left:=Screen.DesktopWidth-in_width;
End
Else
Begin
new_left:=-1;
End;
End;
Result:=new_left;
End;
Procedure TForm1.SetSectorViewerFormNil;
Begin
Form2:=Nil;
End;
procedure TForm1.SectorViewerBtnClick(Sender: TObject);
var
new_height : Integer;
new_top : Integer;
new_width : Integer;
new_left : Integer;
begin
If Form2=Nil Then
Begin
Form2:=TForm2.Create(Form1);
End;
If Form2<>Nil Then
Begin
Form2.Show;
Self.Visible:=False;
Calc_new_height_top(Form2.Height, Form2.Top, new_height, new_top);
If new_height>Form2.Height Then
Begin
Form2.Top:=new_top;
Form2.Height:=new_height;
End;
new_top:=Calc_top(Form2.Height, Form2.Top);
If new_top>-1 Then
Begin
Form2.Top:=new_top;
End;
Calc_new_width_left(Form2.Width, Form2.Left, new_width, new_left);
If new_width>Form2.Width Then
Begin
Form2.Left:=new_left;
Form2.Width:=new_width;
End;
new_left:=Calc_left(Form2.Width, Form2.Left);
If new_left>-1 Then
Begin
Form2.Left:=new_left;
End;
End;
end;
Procedure TFOrm1.SetTOCViewerFormNil;
Begin
Form3:=Nil;
End;
procedure TForm1.TOCViewerBtnClick(Sender: TObject);
var
new_height : Integer;
new_top : Integer;
new_width : Integer;
new_left : Integer;
begin
If Form3=Nil Then
Begin
Form3:=TForm3.Create(Form1);
End;
If Form3<>Nil Then
Begin
Form3.Show;
Self.Visible:=False;
Calc_new_height_top(Form3.Height, Form3.Top, new_height, new_top);
If new_height>Form3.Height Then
Begin
Form3.Top:=new_top;
Form3.Height:=new_height;
End;
new_top:=Calc_top(Form3.Height, Form3.Top);
If new_top>-1 Then
Begin
Form3.Top:=new_top;
End;
Calc_new_width_left(Form3.Width, Form3.Left, new_width, new_left);
If new_width>Form3.Width Then
Begin
Form3.Left:=new_left;
Form3.Width:=new_width;
End;
new_left:=Calc_left(Form3.Width, Form3.Left);
If new_left>-1 Then
Begin
Form3.Left:=new_left;
End;
End;
end;
Procedure TForm1.SetCDToImageFormNil;
Begin
Form4:=Nil;
End;
procedure TForm1.CDToImageBtnClick(Sender: TObject);
var
new_top : Integer;
new_left : Integer;
begin
If Form4=Nil Then
Begin
Form4:=TForm4.Create(Form1);
End;
If Form4<>Nil Then
Begin
Form4.Show;
Self.Visible:=False;
new_top:=Calc_top(Form4.Height, Form4.Top);
If new_top>-1 Then
Begin
Form4.Top:=new_top;
End;
new_left:=Calc_left(Form4.Width, Form4.Left);
If new_left>-1 Then
Begin
Form4.Left:=new_left;
End;
End
end;
Procedure TForm1.SetImageToCDFormNil;
Begin
Form5:=Nil;
End;
procedure TForm1.BTN_image_to_CDClick(Sender: TObject);
var
new_height : Integer;
new_top : Integer;
new_width : Integer;
new_left : Integer;
begin
If Form5=Nil Then
Begin
Form5:=TForm5.Create(Form1);
End;
If Form5<>Nil Then
Begin
Form5.Show;
Self.Visible:=False;
new_top:=Calc_top(Form5.Height, Form5.Top);
If new_top>-1 Then
Begin
Form5.Top:=new_top;
End;
new_left:=Calc_left(Form5.Width, Form5.Left);
If new_left>-1 Then
Begin
Form5.Left:=new_left;
End;
End
end;
Procedure TForm1.SetATIPFormNil;
Begin
ATIP_form:=Nil;
End;
procedure TForm1.BTN_ATIP_formClick(Sender: TObject);
var
new_height : Integer;
new_top : Integer;
new_width : Integer;
new_left : Integer;
begin
If ATIP_form=Nil Then
Begin
ATIP_form:=TATIP_form.Create(Form1);
End;
If ATIP_form<>Nil Then
Begin
ATIP_form.Show;
Self.Visible:=False;
Calc_new_height_top(ATIP_form.Height, ATIP_form.Top, new_height, new_top);
If new_height>ATIP_form.Height Then
Begin
ATIP_form.Top:=new_top;
ATIP_form.Height:=new_height;
End;
new_top:=Calc_top(ATIP_form.Height, ATIP_form.Top);
If new_top>-1 Then
Begin
ATIP_form.Top:=new_top;
End;
Calc_new_width_left(ATIP_form.Width, ATIP_form.Left, new_width, new_left);
If new_width>ATIP_form.Width Then
Begin
ATIP_form.Left:=new_left;
ATIP_form.Width:=new_width;
End;
new_left:=Calc_left(ATIP_form.Width, ATIP_form.Left);
If new_left>-1 Then
Begin
ATIP_form.Left:=new_left;
End;
End
end;
Procedure TForm1.Set_MSRFormNil;
Begin
MSR_form:=Nil;
End;
procedure TForm1.BTN_MSRClick(Sender: TObject);
var
new_height : Integer;
new_top : Integer;
new_width : Integer;
new_left : Integer;
begin
If MSR_form=Nil Then
Begin
MSR_form:=T_MSR_form.Create(Form1);
End;
If MSR_form<>Nil Then
Begin
MSR_form.Show;
Self.Visible:=False;
new_top:=Calc_top(MSR_form.Height, MSR_form.Top);
If new_top>-1 Then
Begin
MSR_form.Top:=new_top;
End;
new_left:=Calc_left(MSR_form.Width, MSR_form.Left);
If new_left>-1 Then
Begin
MSR_form.Left:=new_left;
End;
End
end;
Procedure TForm1.Set_form_read_track_info_Nil;
Begin
Form6:=Nil;
End;
procedure TForm1.BTN_read_track_infoClick(Sender: TObject);
var
new_height : Integer;
new_top : Integer;
new_width : Integer;
new_left : Integer;
begin
If Form6=Nil Then
Begin
Form6:=TForm6.Create(Form6);
End;
If Form6<>Nil Then
Begin
Form6.Show;
Self.Visible:=False;
Calc_new_height_top(Form6.Height, Form6.Top, new_height, new_top);
If new_height>Form6.Height Then
Begin
Form6.Top:=new_top;
Form6.Height:=new_height;
End;
new_top:=Calc_top(Form6.Height, Form6.Top);
If new_top>-1 Then
Begin
Form6.Top:=new_top;
End;
Calc_new_width_left(Form6.Width, Form6.Left, new_width, new_left);
If new_width>Form6.Width Then
Begin
Form6.Left:=new_left;
Form6.Width:=new_width;
End;
new_left:=Calc_left(Form6.Width, Form6.Left);
If new_left>-1 Then
Begin
Form6.Left:=new_left;
End;
End
end;
Procedure TForm1.Set_form_read_disc_info_Nil;
Begin
Form7:=Nil;
End;
procedure TForm1.BTN_read_disc_infoClick(Sender: TObject);
var
new_height : Integer;
new_top : Integer;
new_width : Integer;
new_left : Integer;
begin
If Form7=Nil Then
Begin
Form7:=TForm7.Create(Form7);
End;
If Form7<>Nil Then
Begin
Form7.Show;
Self.Visible:=False;
Calc_new_height_top(Form7.Height, Form7.Top, new_height, new_top);
If new_height>Form7.Height Then
Begin
Form7.Top:=new_top;
Form7.Height:=new_height;
End;
new_top:=Calc_top(Form7.Height, Form7.Top);
If new_top>-1 Then
Begin
Form7.Top:=new_top;
End;
Calc_new_width_left(Form7.Width, Form7.Left, new_width, new_left);
If new_width>Form7.Width Then
Begin
Form7.Left:=new_left;
Form7.Width:=new_width;
End;
new_left:=Calc_left(Form7.Width, Form7.Left);
If new_left>-1 Then
Begin
Form7.Left:=new_left;
End;
End
end;
procedure TForm1.RG_interfaceClick(Sender: TObject);
begin
Case RG_interface.ItemIndex Of
0: Begin
SCSI.Free;
Open_SPT;
End;
1: Begin
SCSI.Free;
Open_WNASPI32;
End;
End;
end;
end.