source: cprs/trunk/BDK32/Samples/RPCBroker/SilentSignOn/fXWBOnFail.pas@ 1085

Last change on this file since 1085 was 829, checked in by Kevin Toppenberg, 14 years ago

Upgrade to version 27

File size: 2.9 KB
RevLine 
[829]1unit fXWBOnFail;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 StdCtrls, Trpcb, Rpcconf1, ExtCtrls, frmVistAAbout, Menus;
8
9type
10 TfrmXWBOnFail = class(TForm)
11 btnConnect: TButton;
12 RPCB: TRPCBroker;
13 rgrSelectAction: TRadioGroup;
14 btnExit: TButton;
15 Memo1: TMemo;
16 edtErrorText: TEdit;
17 edtLoginError: TEdit;
18 lblLogin_ErrorText: TLabel;
19 cbxBadAccess: TCheckBox;
20 MainMenu1: TMainMenu;
21 File1: TMenuItem;
22 Exit1: TMenuItem;
23 Help1: TMenuItem;
24 About1: TMenuItem;
25 procedure btnConnectClick(Sender: TObject);
26 procedure btnExitClick(Sender: TObject);
27 procedure FormCreate(Sender: TObject);
28 procedure Exit1Click(Sender: TObject);
29 procedure About1Click(Sender: TObject);
30 private
31 { Private declarations }
32 public
33 { Public declarations }
34 procedure MyErrorHandler(RPCBroker: TRPCBroker);
35 end;
36
37var
38 frmXWBOnFail: TfrmXWBOnFail;
39
40implementation
41
42{$R *.DFM}
43
44procedure TfrmXWBOnFail.MyErrorHandler(RPCBroker: TRPCBroker);
45var
46 ErrorText: String;
47 Path: String;
48 StrLoc: TStringList;
49 NowVal: TDateTime;
50begin
51 NowVal := Now;
52 ErrorText := RPCB.RPCBError;
53 StrLoc := TStringList.Create;
54 Path := ExtractFilePath(Application.ExeName);
55 Path := Path + 'Error.Log';
56 if FileExists(Path) then
57 StrLoc.LoadFromFile(Path);
58 StrLoc.Add(FormatDateTime('mm/dd/yyyy hh:mm:ss ',NowVal) + ErrorText);
59 StrLoc.SaveToFile(Path);
60end;
61
62procedure TfrmXWBOnFail.btnConnectClick(Sender: TObject);
63begin
64 if btnConnect.Caption = 'Connect' then
65 begin
66 edtErrorText.Text := ''; // Clear out old values
67 edtLoginError.Text := '';
68 RPCB.AccessVerifyCodes := '';
69 RPCB.KernelLogIn := True;
70 if cbxBadAccess.Checked then
71 RPCB.AccessVerifyCodes := 'monkeysee;monkeydo';
72 RPCB.OnRPCBFailure := nil;
73 RPCB.ShowErrorMsgs := semRaise;
74 case rgrSelectAction.ItemIndex of //
75 0: RPCB.OnRPCBFailure := MyErrorHandler;
76 1: RPCB.ShowErrorMsgs := semRaise;
77 2: RPCB.ShowErrorMsgs := semQuiet;
78 end; // case
79 try
80 RPCB.Connected := True;
81 if RPCB.Connected then
82 btnConnect.Caption := 'Disconnect';
83 finally
84 edtErrorText.Text := RPCB.RPCBError;
85 edtLoginError.Text := RPCB.LogIn.ErrorText;
86 end;
87 end
88 else
89 begin
90 RPCB.Connected := False;
91 btnConnect.Caption := 'Connect';
92 end;
93end;
94
95procedure TfrmXWBOnFail.btnExitClick(Sender: TObject);
96begin
97 halt;
98end;
99
100procedure TfrmXWBOnFail.FormCreate(Sender: TObject);
101var
102 Server: String;
103 Port: String;
104begin
105 GetServerInfo(Server, Port);
106 RPCB.Server := Server;
107 RPCB.ListenerPort := StrToInt(Port);
108end;
109
110procedure TfrmXWBOnFail.Exit1Click(Sender: TObject);
111begin
112 Halt;
113end;
114
115procedure TfrmXWBOnFail.About1Click(Sender: TObject);
116begin
117 ShowAboutBox;
118end;
119
120end.
Note: See TracBrowser for help on using the repository browser.