Ciao,
sono sempre in ballo con il componente di un post di questi giorni.
Il componente consiste in una progressbar in stile Windows XP con diversi colori (attualmente bcGreen e bcOrange).
Questa è la parte di codice che disegna e aggiorna la progressbar.
NB: la funzione DrawStep disegna "on the fly" e restituisce via TBitmap un quadratino che andrà a comporre la progressbar per il supporto "nativo" della grafica xpstyle. FOrientation è una proprietà del componente che determina l'orientamento della progressbar (pbHorizontal e pbVertical). FPosition è una proprietà del componente che ne determina lo stato di progressione su una scala da FMin a FMax.codice:procedure TJvXPProgressBar.Paint; var i: integer; Bmp: TBitmap; Step: real; begin Bmp := TBitmap.Create; Bmp.Transparent := True; Bmp.TransparentColor := clFuchsia; if FOrientation = pbHorizontal then begin Step := FMax / Round((Width - 6) / 8); Bmp.LoadFromResourceName(HInstance, 'LEFTCORNER_H'); Canvas.Draw(0, 0, Bmp); for i := 0 to (Round((Width - 6) / 8)- 1) do begin if (Round(FPosition / Step) > i) then Canvas.Draw(3 + (8 * i), 0, DrawStep) else begin Bmp.LoadFromResourceName(HInstance, 'PROGRESSEMPTY_H'); Canvas.Draw(3 + (8 * i), 0, Bmp); end; end; Bmp.LoadFromResourceName(HInstance, 'RIGHTCORNER_H'); Canvas.Draw(Round((Width - 6) / 8) * 8 + 3, 0, Bmp); Width := Round((Width - 6) / 8) * 8 + 6; end else begin Step := FMax / Round((Height - 6) / 8); Bmp.LoadFromResourceName(HInstance, 'LEFTCORNER_V'); Canvas.Draw(0, 0, Bmp); for i := 0 to (Round((Height - 6) / 8)- 1) do begin if (Round(FPosition / Step) > i) then Canvas.Draw(0, Height - 11 - (8 * i), DrawStep) else begin Bmp.LoadFromResourceName(HInstance, 'PROGRESSEMPTY_V'); Canvas.Draw(0, Height - 11 - (8 * i), Bmp); end; end; Bmp.LoadFromResourceName(HInstance, 'RIGHTCORNER_V'); Canvas.Draw(0, Round((Height - 6) / 8) * 8 + 3, Bmp); Height := Round((Height - 6) / 8) * 8 + 6; end; end;
Le domande sono: 1. sapreste darmi qualche consiglio *pratico* per evitare che si manifesti quel fastidioso sfarfallio durante la progressione della barra? 2. sapreste indicarmi un tool simile ad Apiary OCX Expert per convertire componenti VCL in OCX?
Screenshot senza supporto nativo
Screenshot con supporto nativo
Grazie!

Rispondi quotando
