Changeset 6 for trunk/LocalPlayer/PVSB.pas
- Timestamp:
- Jan 7, 2017, 11:32:14 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/PVSB.pas
r2 r6 1 1 {$INCLUDE switches} 2 3 2 unit PVSB; 4 3 … … 6 5 7 6 uses 8 Windows, Messages,SysUtils;7 Windows, Messages, SysUtils; 9 8 10 9 type 11 TPVScrollbar=record h:integer;si:TScrollInfo end; 10 TPVScrollbar = record 11 h: integer; 12 si: TScrollInfo end; 12 13 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); 19 21 20 22 implementation 21 23 22 24 const 23 Count:integer= 0;25 Count: integer = 0; 24 26 25 27 procedure CreatePVSB; 26 28 begin 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; 31 34 end; 32 35 33 36 procedure InitPVSB; 34 37 begin 35 with sb.si do38 with sb.si do 36 39 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; 39 45 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) 42 51 end; 43 52 44 53 function ProcessPVSB; 45 54 var 46 NewPos:integer;55 NewPos: integer; 47 56 begin 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 51 61 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 55 63 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 60 80 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 65 87 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); 68 91 end; 69 92 end … … 73 96 function ProcessMouseWheel; 74 97 var 75 NewPos:integer;98 NewPos: integer; 76 99 begin 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 80 104 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 86 112 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); 89 116 end 90 117 end 91 118 end; 92 119 93 procedure ShowPVSB(var sb: TPVScrollbar; Visible: boolean);120 procedure ShowPVSB(var sb: TPVScrollbar; Visible: boolean); 94 121 begin 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) 98 126 end; 99 127 100 procedure EndPVSB(var sb: TPVScrollbar);128 procedure EndPVSB(var sb: TPVScrollbar); 101 129 begin 102 with sb.si do130 with sb.si do 103 131 begin 104 if nMax<integer(nPage) then npos:=0 // hidden 105 else 132 if nMax < integer(nPage) then 133 npos := 0 // hidden 134 else 106 135 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); 110 139 end 111 140 end … … 113 142 114 143 end. 115
Note:
See TracChangeset
for help on using the changeset viewer.