Ignore:
Timestamp:
Jan 7, 2017, 11:32:14 AM (7 years ago)
Author:
chronos
Message:
  • Modified: Formated all project source files using Delphi formatter as original indentation and other formatting was really bad.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/PVSB.pas

    r2 r6  
    11{$INCLUDE switches}
    2 
    32unit PVSB;
    43
     
    65
    76uses
    8   Windows,Messages,SysUtils;
     7  Windows, Messages, SysUtils;
    98
    109type
    11 TPVScrollbar=record h:integer;si:TScrollInfo end;
     10  TPVScrollbar = record
     11    h: integer;
     12    si: TScrollInfo end;
    1213
    13 procedure CreatePVSB(var sb:TPVScrollbar;Handle,y0,x1,y1:integer);
    14 procedure InitPVSB(var sb:TPVScrollbar;max,Page:integer);
    15 function ProcessPVSB(var sb:TPVScrollbar;const m:TMessage):boolean;
    16 function ProcessMouseWheel(var sb:TPVScrollbar;const m:TMessage):boolean;
    17 procedure ShowPVSB(var sb:TPVScrollbar; Visible: boolean);
    18 procedure EndPVSB(var sb:TPVScrollbar);
     14    procedure CreatePVSB(var sb: TPVScrollbar; Handle, y0, x1, y1: integer);
     15    procedure InitPVSB(var sb: TPVScrollbar; max, Page: integer);
     16    function ProcessPVSB(var sb: TPVScrollbar; const m: TMessage): boolean;
     17    function ProcessMouseWheel(var sb: TPVScrollbar; const m: TMessage)
     18      : boolean;
     19    procedure ShowPVSB(var sb: TPVScrollbar; Visible: boolean);
     20    procedure EndPVSB(var sb: TPVScrollbar);
    1921
    2022implementation
    2123
    2224const
    23 Count:integer= 0;
     25  Count: integer = 0;
    2426
    2527procedure CreatePVSB;
    2628begin
    27 inc(Count);
    28 sb.h:=CreateWindowEx(0,'SCROLLBAR',pchar('PVSB'+IntToStr(Count)),
    29   SBS_VERT or WS_CHILD or SBS_RIGHTALIGN,x1-100,y0,100,y1-y0,Handle,0,0,nil);
    30 sb.si.cbSize:=28;
     29  inc(Count);
     30  sb.h := CreateWindowEx(0, 'SCROLLBAR', pchar('PVSB' + IntToStr(Count)),
     31    SBS_VERT or WS_CHILD or SBS_RIGHTALIGN, x1 - 100, y0, 100, y1 - y0,
     32    Handle, 0, 0, nil);
     33  sb.si.cbSize := 28;
    3134end;
    3235
    3336procedure InitPVSB;
    3437begin
    35 with sb.si do
     38  with sb.si do
    3639  begin
    37   nMin:=0;nMax:=max;npos:=0;nPage:=Page;
    38   FMask:=SIF_PAGE or SIF_POS or SIF_RANGE;
     40    nMin := 0;
     41    nMax := max;
     42    npos := 0;
     43    nPage := Page;
     44    FMask := SIF_PAGE or SIF_POS or SIF_RANGE;
    3945  end;
    40 SetScrollInfo(sb.h,SB_CTL,sb.si,true);
    41 if max<Page then ShowWindow(sb.h,SW_HIDE) else ShowWindow(sb.h,SW_SHOW)
     46  SetScrollInfo(sb.h, SB_CTL, sb.si, true);
     47  if max < Page then
     48    ShowWindow(sb.h, SW_HIDE)
     49  else
     50    ShowWindow(sb.h, SW_SHOW)
    4251end;
    4352
    4453function ProcessPVSB;
    4554var
    46 NewPos:integer;
     55  NewPos: integer;
    4756begin
    48 with sb.si do
    49   if nMax<integer(nPage) then result:=false
    50   else
     57  with sb.si do
     58    if nMax < integer(nPage) then
     59      result := false
     60    else
    5161    begin
    52     if m.wParamLo in[SB_THUMBPOSITION,SB_THUMBTRACK] then
    53       begin result:=m.wParamHi<>npos;npos:=m.wParamHi;end
    54     else
     62      if m.wParamLo in [SB_THUMBPOSITION, SB_THUMBTRACK] then
    5563      begin
    56       case m.wParamLo of
    57         SB_LINEUP:NewPos:=npos-1;SB_LINEDOWN:NewPos:=npos+1;
    58         SB_PAGEUP:NewPos:=npos-integer(nPage);SB_PAGEDOWN:NewPos:=npos+integer(nPage);
    59         else NewPos:=npos
     64        result := m.wParamHi <> npos;
     65        npos := m.wParamHi;
     66      end
     67      else
     68      begin
     69        case m.wParamLo of
     70          SB_LINEUP:
     71            NewPos := npos - 1;
     72          SB_LINEDOWN:
     73            NewPos := npos + 1;
     74          SB_PAGEUP:
     75            NewPos := npos - integer(nPage);
     76          SB_PAGEDOWN:
     77            NewPos := npos + integer(nPage);
     78        else
     79          NewPos := npos
    6080        end;
    61       if NewPos<0 then NewPos:=0;
    62       if NewPos>nMax-integer(nPage)+1 then NewPos:=nMax-integer(nPage)+1;
    63       result:=NewPos<>npos;
    64       if (NewPos<>npos) or (m.wParamLo=SB_ENDSCROLL) then
     81        if NewPos < 0 then
     82          NewPos := 0;
     83        if NewPos > nMax - integer(nPage) + 1 then
     84          NewPos := nMax - integer(nPage) + 1;
     85        result := NewPos <> npos;
     86        if (NewPos <> npos) or (m.wParamLo = SB_ENDSCROLL) then
    6587        begin
    66         npos:=NewPos;FMask:=SIF_POS;
    67         SetScrollInfo(sb.h,SB_CTL,sb.si,true);
     88          npos := NewPos;
     89          FMask := SIF_POS;
     90          SetScrollInfo(sb.h, SB_CTL, sb.si, true);
    6891        end;
    6992      end
     
    7396function ProcessMouseWheel;
    7497var
    75 NewPos:integer;
     98  NewPos: integer;
    7699begin
    77 with sb.si do
    78   if nMax<integer(nPage) then result:=false
    79   else
     100  with sb.si do
     101    if nMax < integer(nPage) then
     102      result := false
     103    else
    80104    begin
    81     NewPos:=npos-m.wParam div (1 shl 16*40);
    82     if NewPos<0 then NewPos:=0;
    83     if NewPos>nMax-integer(nPage)+1 then NewPos:=nMax-integer(nPage)+1;
    84     result:=NewPos<>npos;
    85     if NewPos<>npos then
     105      NewPos := npos - m.wParam div (1 shl 16 * 40);
     106      if NewPos < 0 then
     107        NewPos := 0;
     108      if NewPos > nMax - integer(nPage) + 1 then
     109        NewPos := nMax - integer(nPage) + 1;
     110      result := NewPos <> npos;
     111      if NewPos <> npos then
    86112      begin
    87       npos:=NewPos;FMask:=SIF_POS;
    88       SetScrollInfo(sb.h,SB_CTL,sb.si,true);
     113        npos := NewPos;
     114        FMask := SIF_POS;
     115        SetScrollInfo(sb.h, SB_CTL, sb.si, true);
    89116      end
    90117    end
    91118end;
    92119
    93 procedure ShowPVSB(var sb:TPVScrollbar; Visible: boolean);
     120procedure ShowPVSB(var sb: TPVScrollbar; Visible: boolean);
    94121begin
    95 if not Visible or (sb.si.nMax<integer(sb.si.nPage)) then
    96   ShowWindow(sb.h,SW_HIDE)
    97 else ShowWindow(sb.h,SW_SHOW)
     122  if not Visible or (sb.si.nMax < integer(sb.si.nPage)) then
     123    ShowWindow(sb.h, SW_HIDE)
     124  else
     125    ShowWindow(sb.h, SW_SHOW)
    98126end;
    99127
    100 procedure EndPVSB(var sb:TPVScrollbar);
     128procedure EndPVSB(var sb: TPVScrollbar);
    101129begin
    102 with sb.si do
     130  with sb.si do
    103131  begin
    104   if nMax<integer(nPage) then npos:=0 // hidden
    105   else
     132    if nMax < integer(nPage) then
     133      npos := 0 // hidden
     134    else
    106135    begin
    107     sb.si.npos:=nMax-integer(nPage)+1;
    108     sb.si.FMask:=SIF_POS;
    109     SetScrollInfo(sb.h,SB_CTL,sb.si,true);
     136      sb.si.npos := nMax - integer(nPage) + 1;
     137      sb.si.FMask := SIF_POS;
     138      SetScrollInfo(sb.h, SB_CTL, sb.si, true);
    110139    end
    111140  end
     
    113142
    114143end.
    115 
Note: See TracChangeset for help on using the changeset viewer.