, , . , , -.
(Windows GUI MySQL), Delphi 7.
. Factory (), , , .
, .
, , . , , . , .
, - :
:
unit bitwise;
interface
Const
Adm = 01;
Rws = 02;
Ros = 04;
Rwp = 08;
Rop = 16;
roa = 32;
acc = 64;
function IsBitSet(const val: byte; const TheBit: Byte): Boolean;
function BitOn(const val: byte; const TheBit: Byte): byte;
function BitOff(const val: byte; const TheBit: Byte): byte;
function BitToggle(const val: byte; const TheBit: Byte): byte;
implementation
function IsBitSet(const val: byte; const TheBit: Byte): Boolean;
begin
Result := (val and (TheBit)) <> 0;
end;
function BitOn(const val: byte; const TheBit: Byte): byte;
begin
Result := val or (TheBit);
end;
function BitOff(const val: byte; const TheBit: Byte): byte;
begin
Result := val and not (TheBit);
end;
function BitToggle(const val: byte; const TheBit: Byte): byte;
begin
Result := val xor (TheBit);
end;
end.
, , -, , .
Function TForm1.HasRights(Need: Byte; Msg: String;): Boolean;
Begin
If Not IsBitSet(rights, Need) Then
Begin
showdialog('Security', 'You have insufficient Security Rights!', 'You must have ' +
Msg + ' access to perform the action you have attempted.', '', '', false, False, True);
Result := False;
End
Else
Result := True;
End;
:
If HasRights(Rop Or Rwp Or Adm, '"Read Only Production" or "Read / Write Production"') Then
Begin
End
, IsBitSet :
If IsBitSet(rights, Adm) Then
Begin
// Do stuff
end;
, ShowDialog.. , , .
Function TForm1.showdialog(Const DialogTitle: WideString; Const FirstCaption: WideString;
Const SecondCaption: widestring; Const ConfirmBCaption: widestring; Const CancelBCaption:
widestring; LeftButton, RightButton, MiddleButton: Boolean): boolean;
Var
whattheysaid: boolean;
craigsdialog: Tcraigsdialog;
Begin
// Modal1Button and Modal2Button can have modified captions whereas Modal3Button
// is always "Ok". If the only button a user needs is "Ok" then make it visible
// and receive a modalresult of 3 when clicked. This 3rd button is for appearance
// only and just makes it a bit neater.
Whattheysaid := False;
Craigsdialog := Tcraigsdialog.Create(nil);
With Craigsdialog Do
Begin
// Set the Dialog details as required
Caption := DialogTitle;
Label1.Caption := FirstCaption;
Label2.Caption := SecondCaption;
Modal1Button.Visible := leftbutton;
Modal2Button.Visible := rightbutton;
Modal3Button.Visible := Middlebutton;
modal1button.Caption := ConfirmBCaption;
modal2button.Caption := CancelBCaption;
Case ShowModal Of
1: whattheysaid := True
2: whattheysaid := False
3: whattheysaid := True
End;
End;
FreeAndNil(craigsdialog);
Result := whattheysaid;
End;
, , .
source
share