Ignore:
Timestamp:
Dec 3, 2014, 9:09:42 PM (10 years ago)
Author:
chronos
Message:
  • Added: Support for high DPI screens. If not detected automatically correctly then user can specify desired values.
  • Updated: Common package to newer version.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/UCommon.pas

    r55 r59  
    4848function LoggedOnUserNameEx(Format: TUserNameFormat): string;
    4949function SplitString(var Text: string; Count: Word): string;
     50function GetBitCount(Variable: QWord; MaxIndex: Integer): Integer;
    5051function GetBit(Variable: QWord; Index: Byte): Boolean;
     52procedure SetBit(var Variable: Int64; Index: Byte; State: Boolean); overload;
    5153procedure SetBit(var Variable: QWord; Index: Byte; State: Boolean); overload;
    5254procedure SetBit(var Variable: Cardinal; Index: Byte; State: Boolean); overload;
     
    336338end;
    337339
     340function GetBitCount(Variable: QWord; MaxIndex: Integer): Integer;
     341var
     342  I: Integer;
     343begin
     344  Result := 0;
     345  for I := 0 to MaxIndex - 1 do
     346    if ((Variable shr I) and 1) = 1 then Inc(Result);
     347end;
     348
    338349function GetBit(Variable:QWord;Index:Byte):Boolean;
    339350begin
     
    341352end;
    342353
     354procedure SetBit(var Variable: Int64; Index: Byte; State: Boolean);
     355begin
     356  Variable := (Variable and ((1 shl Index) xor High(QWord))) or (Int64(State) shl Index);
     357end;
     358
    343359procedure SetBit(var Variable:QWord;Index:Byte;State:Boolean); overload;
    344360begin
    345   Variable := (Variable and ((1 shl Index) xor QWord($ffffffffffffffff))) or (QWord(State) shl Index);
     361  Variable := (Variable and ((1 shl Index) xor High(QWord))) or (QWord(State) shl Index);
    346362end;
    347363
    348364procedure SetBit(var Variable:Cardinal;Index:Byte;State:Boolean); overload;
    349365begin
    350   Variable := (Variable and ((1 shl Index) xor Cardinal($ffffffff))) or (Cardinal(State) shl Index);
     366  Variable := (Variable and ((1 shl Index) xor High(Cardinal))) or (Cardinal(State) shl Index);
    351367end;
    352368
    353369procedure SetBit(var Variable:Word;Index:Byte;State:Boolean); overload;
    354370begin
    355   Variable := (Variable and ((1 shl Index) xor Word($ffff))) or (Word(State) shl Index);
     371  Variable := (Variable and ((1 shl Index) xor High(Word))) or (Word(State) shl Index);
    356372end;
    357373
Note: See TracChangeset for help on using the changeset viewer.