Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Progress Bar

Status
Not open for further replies.

htb222

Programmer
Jan 18, 2006
6
RO
Hi there.
I want to code something but instead of a classic progress bar i need something with stars.
I have in my app one function who calculates ratings of products and i want to shown those ones in "Star view" but not use a grid view.
I hope you will understant, english is not my native language.
 
If you dont need many stars e.g 1 - 5. Why no create a small bitmap star using the image editor, and then use the canvas. fill rect method to draw these onto your form wher required

from the delphi help
Code:
var
  Bitmap: TBitmap;
begin
  Bitmap := TBitmap.Create;
  try
    Bitmap.LoadFromFile('MyStar.bmp');
    Form1.Canvas.Brush.Bitmap := Bitmap;
    Form1.Canvas.FillRect(Rect(0,0,100,100));
  finally
    Form1.Canvas.Brush.Bitmap := nil;
    Bitmap.Free;
  end;

end;

the postion and size are defined by the rect parameter simply increse the left value to move to the next star position.

There is more to this but maybe it will give you a start.



[red]GNBM 4th Feb[/red] More on and other neat UK stuff at forum1091
Steve: Delphi a feersum engin indeed.
 
Yes, it good, but if i have a 1.43 star rating?
 
Make a bitmap comntaining the maximum number of stars
put it on an Timage and set the stretch, center and autosize to false, then vary the width of the image programaticaly, then you can have parts of a star showing.

crudly
Code:
procedure TUpdateScan.Button3Click(Sender: TObject);
var a: integer;
begin
   for a := 150 downto 10 do
     begin
        image.Width := a;
        image.Update;
        sleep(100);
     end;

end;

[red]GNBM 4th Feb[/red] More on and other neat UK stuff at forum1091
Steve: Delphi a feersum engin indeed.
 
My opinion... make the stars small like 10px wide & high and make 11 images (showing 0,10,20..100% star). That way
you dont have to fuss around with the 0.0# and itll look
really nifty. Just use an imagelist and calculate which
picture is to be used.

[bobafett] BobbaFet [bobafett]
Code:
if not Programming = 'Severe Migraine' then
                       ShowMessage('Eureka!');
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top