Forum > LCL

[SOLVED] Range of numbers

(1/2) > >>

Pe3s:
Hi I have this code , how can I make a range from 0 to 100.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.FormMouseWheel(Sender: TObject; Shift: TShiftState;  WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);begin  if WheelDelta < 0 then  begin     FCounter := FCounter -5;  end else begin     FCounter := FCounter +5;  end;  Label1.Caption := IntToStr(FCounter);end;

Handoko:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  // ... do some calculation   // ... put these at the end of the calculation   If WheelDelta < 0 then WheelDelta := 0;  If WheelDeltea > 100 then WheelDelta := 100;

Pe3s:
unfortunately it doesn't work

Handoko:
Basically, there are 3 different range limited types in graphics programming:

1. It won't go beyond a certain limit but stay at the nearest point of the limit

If Position < LowestLimit then Position := LowestLimit;
If Position > HighestLimit then Position := HighestLimit;

2. When it goes beyond a certain limit, it appears at the opposite side

If Position < LowestLimit then Position := HighestLimit;
If Position > HigestLimit then Position := LowestLimit;

3. When reaching a certain limit, it switches to the opposite direction

If (Position <= LowestLimit) or (Position >= HighestLimit) then
  Direction := -Direction;
Position := Position + Direction;


Which one do you want? Perhaps you can show us your whole source code. Why my code not working questions, usually can be solved quickly if we can inspect the whole source code.

howardpc:
Try this:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.FormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint;  var Handled: Boolean);begin  case (WheelDelta < 0) of    True:  Dec(FCounter, 5);    False: Inc(FCounter, 5);  end;  if FCounter < 0 then    FCounter := 0  else if FCounter > 100 then    FCounter := 100;  Label1.Caption := IntToStr(FCounter);  Handled := True;end;

Navigation

[0] Message Index

[#] Next page

Go to full version