-
Notifications
You must be signed in to change notification settings - Fork 1
/
SgnonCnf.pas
602 lines (540 loc) · 18.4 KB
/
SgnonCnf.pas
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
{ **************************************************************
Package: XWB - Kernel RPCBroker
Date Created: Sept 18, 1997 (Version 1.1)
Site Name: Oakland, OI Field Office, Dept of Veteran Affairs
Developers: Danila Manapsal, Don Craven, Joel Ivey
Description: Signon Form Configuration Dialog.
Current Release: Version 1.1 Patch 40 (January 7, 2005))
*************************************************************** }
{**************************************************
1.1P31 - Modified to store signon configuration under
the HKCU key - this permits users on NT2000
machines who have USER access to set their
configuration. Also, makes configuration specific
to users on machines which might be shared.
Also make it so that configuration is only written
to the registry when the user indicates that it
should be saved (previously the default values
were written into the registry as well as applied
to the window if data was not in the registry).
The default values previously stored in the registry
would override any changes in the signon window
design via coding. To overcome this, if the user
does not have saved configuration data, the window
generated on opening will be used as the default, and
the default data written into the registry as defaults.
This will permit the user to restore to the current
window defaults if desired, but will not overwrite
changes released for the window in later patches.
************************************************************}
unit Sgnoncnf;
interface
uses Classes, Graphics, Forms, Controls, Buttons,
StdCtrls, ExtCtrls, Dialogs, SysUtils, MFunStr, XWBut1;
type
TSignonValues = class(TObject)
private
FHeight: Integer;
FWidth: Integer;
FTextColor: LongInt;
FPosition: String;
FSize: String;
FIntroFont: String;
FIntroFontStyles: String;
FBackColor: LongInt;
FFont: TFont;
FFontStyles: TFontStyles;
FTop: Integer;
FLeft: Integer;
procedure SetSize(const Value: String);
procedure SetPosition(const Value: String);
procedure SetIntroFont(const Value: String);
procedure SetIntroFontStyles(const Value: String);
procedure SetFont(Value: TFont);
procedure SetTextColor(Value: LongInt);
public
procedure Clear; virtual;
constructor Create;
destructor Destroy; override;
procedure SetEqual(EqualToValue: TSignonValues);
property Height: Integer read FHeight write FHeight;
property Width: Integer read FWidth write FWidth;
property TextColor: LongInt read FTextColor write SetTextColor;
property Position: String read FPosition write SetPosition;
property Size: String read FSize write SetSize;
property IntroFont: String read FIntroFont write SetIntroFont;
property IntroFontStyles: String read FIntroFontStyles write SetIntroFontStyles;
property BackColor: LongInt read FBackColor write FBackColor;
property Font: TFont read FFont write SetFont;
property FontStyles: TFontStyles read FFontStyles write FFontStyles;
property Top: Integer read FTop write FTop;
property Left: Integer read FLeft write FLeft;
end;
TSignonConfiguration = class;
{
This class is the form shown for configuration of the signon form
}
TfrmSignonConfig = class(TForm)
OKBtn: TBitBtn;
CancelBtn: TBitBtn;
HelpBtn: TBitBtn;
Bevel1: TBevel;
rgrWindowPosition: TRadioGroup;
rgrWindowSize: TRadioGroup;
FontDialog1: TFontDialog;
GroupBox1: TGroupBox;
Button1: TButton;
btnDefaults: TBitBtn;
rgrIntroBackClr: TRadioGroup;
ColorDialog1: TColorDialog;
procedure Button1Click(Sender: TObject);
procedure OKBtnClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure rgrIntroBackClrClick(Sender: TObject);
private
{ Private declarations }
FController: TSignonConfiguration;
public
property Controller: TSignonConfiguration read FController write FController;
{ Public declarations }
end;
{
This class handles the processing for signon configuration
}
TSignonConfiguration = class(TObject)
private
OrigHelp: String;
FIntroBackColor: LongInt;
FIntroFontValue: String;
FIntroFontStyles: String;
FIntroTextColor: LongInt;
FPosition: String;
FSize: String;
protected
procedure ResetToDefaults; virtual;
procedure UserClickedOK; virtual;
procedure IntroBackColor; virtual;
procedure FontDialog; virtual;
procedure UpdateWindow;
public
function ShowModal: Integer; virtual;
procedure ReadRegistrySettings;
constructor Create;
end;
function StoreFontStyle(Values: TFontStyles): string;
function RestoreFontStyles(Value: String): TFontStyles;
var
frmSignonConfig: TfrmSignonConfig;
strPosition, strSize: string;
InitialValues: TSignonValues;
SignonDefaults: TSignonValues;
IsSharedBroker: Boolean;
{
const
DfltWidth: integer = 794; // 631; // 611; // 608;
DfltHeight: integer = 591; // 467; // 300;
DfltIntroClr: longint = clWindow;
DfltPosition: string = '0';
DfltSize: string = '0';
DfltIntroFont: string = ''; // 'Fixedsys^8'; // 'Courier New^8';
DfltIntroFontStyle: TFontStyles = [fsBold];
DfltBackClr: integer = 0;
p:string = '[';
}
implementation
{$R *.DFM}
uses LoginFrm, fSgnonDlg, Trpcb;
procedure TfrmSignonConfig.Button1Click(Sender: TObject);
begin
// FontDialog1.Execute;
Controller.FontDialog;
end;
procedure TfrmSignonConfig.OKBtnClick(Sender: TObject);
begin
end;
{-------------- TSignonConfiguration.ReadRegistrySettings --------------
Read Signon related settings from the Registry. Substitute defaults
for missing values.
------------------------------------------------------------------}
procedure TSignonConfiguration.ReadRegistrySettings;
var
strFontStyle: String;
strFontColor: String;
strFontSettings: String;
begin
{ Test handling of Defaults }
// ShowMessage
InitialValues.SetEqual(SignonDefaults);
InitialValues.Position := '0';
InitialValues.Size := '0';
InitialValues.BackColor := clWindow;
InitialValues.TextColor := clWindowText;
{%%%%%%% Sign-on Window Position %%%%%%%}
strPosition := ReadRegDataDefault(HKCU, REG_SIGNON, 'SignonPos','');
if strPosition <> '' then
InitialValues.Position := strPosition;
{%%%%%%% Sign-on Window Size %%%%%%%}
strSize := ReadRegDataDefault(HKCU, REG_SIGNON, 'SignonSiz', '');
if strSize <> '' then
InitialValues.Size := strSize;
{%%%%%%% Intro Text Background Color %%%%%%%}
if ReadRegDataDefault(HKCU, REG_SIGNON, 'IntroBackClr', '') <> '' then
InitialValues.BackColor := StrToInt(ReadRegDataDefault(HKCU, REG_SIGNON, 'IntroBackClr', ''));
{%%%%%%% Intro Text Font %%%%%%%}
strFontSettings := ReadRegDataDefault(HKCU, REG_SIGNON, 'IntroTextFont', '');
if strFontSettings <> '' then
begin
InitialValues.IntroFont := strFontSettings;
InitialValues.Font.Name := Piece(strFontSettings,U,1);
InitialValues.Font.Size := StrToInt(Piece(strFontSettings,U,2));
end;
{%%%%%%% Intro Text Color %%%%%%%}
strFontColor := ReadRegDataDefault(HKCU, REG_SIGNON, 'IntroTextClr', '');
if strFontColor <> '' then
begin
InitialValues.TextColor := StrToInt(strFontColor);
InitialValues.Font.Color := InitialValues.TextColor;
end;
{%%%%%%% Intro Text Font Styles %%%%%%%}
strFontStyle := ReadRegDataDefault(HKCU, REG_SIGNON, 'IntroTextStyle', '');
if strFontStyle <> '' then
begin
InitialValues.IntroFontStyles := strFontStyle;
InitialValues.Font.Style := RestoreFontStyles(strFontStyle)
end;
end;
function StoreFontStyle(Values: TFontStyles): String;
begin
Result := '';
if fsBold in Values then
Result := Result + 'B';
if FsItalic in Values then
Result := Result + 'I';
if fsUnderline in Values then
Result := Result + 'U';
if fsStrikeout in Values then
Result := Result + 'S';
end;
procedure TfrmSignonConfig.FormShow(Sender: TObject);
begin
//
end;
function RestoreFontStyles(Value: String): TFontStyles;
begin
Result := [];
if pos('B',Value) > 0 then
Result := Result + [fsBold];
if pos('I',Value) > 0 then
Result := Result + [fsItalic];
if pos('U',Value) > 0 then
Result := Result + [fsUnderline];
if pos('S',Value) > 0 then
Result := Result + [fsStrikeout];
end;
procedure TfrmSignonConfig.rgrIntroBackClrClick(Sender: TObject);
begin
Controller.IntroBackColor;
end;
function TSignonConfiguration.ShowModal: Integer;
var
ModalValue: Integer;
begin
ReadRegistrySettings;
if frmSignonConfig = nil then
frmSignonConfig := TfrmSignonConfig.Create(Application);
frmSignonConfig.Controller := Self;
OrigHelp := Application.HelpFile; // Save original helpfile.
try
Application.HelpFile := ReadRegData(HKLM, REG_BROKER, 'BrokerDr') +
'\clagent.hlp'; // Identify ConnectTo helpfile.
with frmSignonConfig do
begin
// set selections for entry to form
rgrIntroBackClr.ItemIndex := 0; // Current Background
rgrWindowPosition.ItemIndex := StrToInt(Piece(InitialValues.Position,U,1));
rgrWindowSize.ItemIndex := StrToInt(Piece(InitialValues.Size,U,1));
// initialize font values to current settings
FIntroFontValue := InitialValues.IntroFont;
FIntroTextColor := InitialValues.TextColor;
FIntroFontStyles := InitialValues.IntroFontStyles;
ShowApplicationAndFocusOK(Application);
ModalValue := frmSignonConfig.ShowModal;
if ModalValue = mrOK then // establish changes for user
begin
UserClickedOK
end
else if ModalValue = mrIgnore then // restore default values
ResetToDefaults;
end; // with SignonForm
Result := ModalValue;
finally
frmSignonConfig.Free; // Release; jli 041104
Application.HelpFile := OrigHelp; // Restore helpfile.
end;
end;
{
called if user changes selection for Background Color
selection 0 is to current value
selection 1 is to select new color
}
procedure TSignonConfiguration.IntroBackColor;
var
frmSignonDialog: TfrmSignonDialog;
OldHandle: THandle;
begin
OldHandle := GetForegroundWindow;
if frmSignonConfig.rgrIntroBackClr.ItemIndex = 1 then
begin
frmSignonDialog := TfrmSignonDialog.Create(Application);
// ShowApplicationAndFocusOK(Application);
SetForegroundWindow(frmSignonDialog.Handle);
if frmSignonDialog.ShowModal = mrOK then
FIntroBackColor := clWindow
else
begin
ShowApplicationAndFocusOK(Application);
if IsSharedBroker then
frmSignonConfig.WindowState := wsMinimized;
if frmSignonConfig.ColorDialog1.Execute then
FIntroBackColor := frmSignonConfig.ColorDialog1.Color;
frmSignonConfig.WindowState := wsNormal;
end;
end
else
FIntroBackColor := InitialValues.BackColor;
SetForegroundWindow(OldHandle);
end;
{ called if user selects to change font for signon form }
procedure TSignonConfiguration.FontDialog;
var
frmSignonDialog: TfrmSignonDialog;
OldHandle: THandle;
FFontValue: TFont;
begin
FFontValue := TFont.Create;
OldHandle := GetForegroundWindow;
try
FFontValue.Name := InitialValues.Font.Name;
FFontValue.Size := InitialValues.Font.Size;
FFontValue.Style := InitialValues.Font.Style;
FFontValue.Color := InitialValues.Font.Color;
frmSignonDialog := TfrmSignonDialog.Create(Application);
frmSignonDialog.Label1.Caption := 'Do you want to use the Default Font face and size?';
// ShowApplicationAndFocusOK(Application);
SetForegroundWindow(frmSignonDialog.Handle);
if frmSignonDialog.ShowModal = mrOK then
FFontValue := SignonDefaults.Font
else
begin
// initialize font to current values
frmSignonConfig.FontDialog1.Font.Color := InitialValues.Font.Color;
frmSignonConfig.FontDialog1.Font.Name := InitialValues.Font.Name;
frmSignonConfig.FontDialog1.Font.Size := InitialValues.Font.Size;
frmSignonConfig.FontDialog1.Font.Style := InitialValues.Font.Style;
ShowApplicationAndFocusOK(Application);
if IsSharedBroker then
frmSignonConfig.WindowState := wsMinimized;
if frmSignonConfig.FontDialog1.Execute then
FFontValue := frmSignonConfig.FontDialog1.Font;
frmSignonConfig.WindowState := wsNormal;
end;
FIntroFontValue := FFontValue.Name + U + IntToStr(FFontValue.Size);
FIntroFontStyles := StoreFontStyle(FFontValue.Style);
FIntroTextColor := FFontValue.Color;
finally
FFontValue.Free;
SetForegroundWindow(OldHandle);
end;
end;
procedure TSignonConfiguration.ResetToDefaults;
begin
if MessageDlg('Are you sure you want to reset all settings to their defaults?',
mtWarning, [mbNo, mbYes], 0) = mrYes then
begin
// P31 remove setting of default values into registry -
// remove entries from registry and use default window in app
DeleteRegData(HKCU, REG_SIGNON, 'SignonPos');
DeleteRegData(HKCU, REG_SIGNON, 'SignonSiz');
DeleteRegData(HKCU, REG_SIGNON, 'IntroBackClr');
DeleteRegData(HKCU, REG_SIGNON, 'IntroTextClr');
DeleteRegData(HKCU, REG_SIGNON, 'IntroTextFont');
DeleteRegData(HKCU, REG_SIGNON, 'IntroTextStyle');
strPosition := '0';
strSize := '0';
// Restore values to Defaults at Signon
InitialValues.SetEqual(SignonDefaults);
UpdateWindow;
end;
end;
procedure TSignonConfiguration.UserClickedOK;
var
JPosition: Integer;
JSize: Integer;
begin
JPosition := frmSignonConfig.rgrWindowPosition.ItemIndex;
JSize := frmSignonConfig.rgrWindowSize.ItemIndex;
if JPosition = 0 then
FPosition := '0'
else
FPosition := IntToStr(JPosition)+U+IntToStr(frmSignon.Top)+U+IntToStr(frmSignon.Left);
strPosition := FPosition;
if JSize = 0 then
FSize := '0'
else
FSize := IntToStr(JSize)+U+IntToStr(frmSignon.Width)+U+IntToStr(frmSignon.Height);
strSize := FSize;
if FIntroBackColor <> InitialValues.BackColor then
begin
InitialValues.BackColor := FIntroBackColor;
if InitialValues.BackColor <> SignonDefaults.BackColor then
WriteRegData(HKCU, REG_SIGNON, 'IntroBackClr',IntToStr(FIntroBackColor))
else
DeleteRegData(HKCU, REG_SIGNON, 'IntroBackClr');
end;
if FIntroTextColor <> InitialValues.TextColor then
begin
InitialValues.TextColor := FIntroTextColor;
if InitialValues.BackColor <> SignonDefaults.BackColor then
WriteRegData(HKCU, REG_SIGNON, 'IntroTextClr',IntToStr(FIntroTextColor))
else
DeleteRegData(HKCU, REG_SIGNON, 'IntroTextClr');
end;
if FIntroFontValue <> InitialValues.IntroFont then
begin
InitialValues.IntroFont := FIntrofontValue;
if InitialValues.IntroFont <> SignonDefaults.IntroFont then
WriteRegData(HKCU, REG_SIGNON, 'IntroTextFont',FIntroFontValue)
else
DeleteRegData(HKCU, REG_SIGNON, 'IntroTextFont');
end;
if FIntroFontStyles <> InitialValues.IntroFontStyles then
begin
InitialValues.IntroFontStyles := FIntrofontStyles;
if InitialValues.IntroFontStyles <> SignonDefaults.IntroFontStyles then
WriteRegData(HKCU, REG_SIGNON, 'IntroTextStyle',FIntroFontStyles)
else
DeleteRegData(HKCU, REG_SIGNON, 'IntroTextStyle');
end;
if FPosition <> InitialValues.Position then
begin
InitialValues.Position := FPosition;
if InitialValues.Position <> SignonDefaults.Position then
WriteRegData(HKCU, REG_SIGNON, 'SignonPos',FPosition)
else
DeleteRegData(HKCU, REG_SIGNON, 'SignonPos');
end;
if FSize <> InitialValues.Size then
begin
InitialValues.Size := FSize;
if InitialValues.Size <> SignonDefaults.Size then
WriteRegData(HKCU, REG_SIGNON, 'SignonSiz',FSize)
else
DeleteRegData(HKCU, REG_SIGNON, 'SignonSiz');
end;
UpdateWindow;
end;
constructor TSignonConfiguration.Create;
begin
inherited;
if SignonDefaults = nil then
SignonDefaults := TSignonValues.Create;
if InitialValues = nil then
InitialValues := TSignonValues.Create;
end;
procedure TSignonConfiguration.UpdateWindow;
begin
// TODO -cMM: default body inserted
frmSignon.IntroText.Color := InitialValues.BackColor;
frmSignon.IntroText.Font.Name := InitialValues.Font.Name;
frmSignon.IntroText.Font.Size := InitialValues.Font.Size;
frmSignon.IntroText.Font.Style := InitialValues.Font.Style;
frmSignon.IntroText.Font.Color := InitialValues.Font.Color;
frmSignon.Left := SignonDefaults.Left;
frmSignon.Top := SignonDefaults.Top;
frmSignon.Width := SignonDefaults.Width;
frmSignon.Height := SignonDefaults.Height;
end;
procedure TSignonValues.Clear;
begin
FHeight := 0;
FWidth := 0;
FTextColor := clWindowText;
FPosition := '';
FSize := '';
FIntroFont := '';
FIntroFontStyles := '';
FBackColor := clWindow;
FFont.Name := 'Courier New' ;
FFont.Size := 11;
FFont.Style := [];
end;
constructor TSignonValues.Create;
begin
inherited;
FFont := TFont.Create;
end;
destructor TSignonValues.Destroy;
begin
FFont.Free;
inherited;
end;
procedure TSignonValues.SetSize(const Value: String);
begin
FSize := Value;
if Value <> '0' then
begin
FWidth := StrToInt(Piece(Value,U,2));
FHeight := StrToInt(Piece(Value,U,3));
end;
end;
procedure TSignonValues.SetPosition(const Value: String);
begin
FPosition := Value;
if Value <> '0' then
begin
FTop := StrToInt(Piece(Value,U,2));
FLeft := StrToInt(Piece(Value,U,3));
end;
end;
procedure TSignonValues.SetIntroFont(const Value: String);
begin
FIntroFont := Value;
FFont.Name := Piece(Value,U,1);
FFont.Size := StrToInt(Piece(Value,U,2));
end;
procedure TSignonValues.SetIntroFontStyles(const Value: String);
begin
FIntroFontStyles := Value;
if Value <> '' then
FFont.Style := RestoreFontStyles(Value)
else
FFont.Style := [];
end;
procedure TSignonValues.SetEqual(EqualToValue: TSignonValues);
begin
BackColor := EqualToValue.BackColor;
Font.Name := EqualToValue.Font.Name;
Font.Size := EqualToValue.Font.Size;
FontStyles := EqualToValue.FontStyles;
Height := EqualToValue.Height;
IntroFont := EqualToValue.IntroFont;
IntroFontStyles := EqualToValue.IntroFontStyles;
Left := EqualToValue.Left;
Position := EqualToValue.Position;
Size := EqualToValue.Size;
TextColor := EqualToValue.TextColor;
Top := EqualToValue.Top;
Width := EqualToValue.Width;
end;
procedure TSignonValues.SetFont(Value: TFont);
begin
FFont := Value;
FIntroFont := Value.Name+U+IntToStr(Value.Size);
FIntroFontStyles := StoreFontStyle(FFont.Style)
end;
procedure TSignonValues.SetTextColor(Value: LongInt);
begin
FTextColor := Value;
FFont.Color := Value;
end;
end.