Einzelnen Beitrag anzeigen

Reinhard Kern

Registriert seit: 22. Okt 2006
772 Beiträge
 
#3

Re: Trackbar: Größe von Slider und Channel getrennt einstell

  Alt 21. Aug 2009, 16:18
Zitat von Bertram:
Ich möchte meine Frage nochmal nach oben holen. Vielleicht kann ja doch jemand was dazu sagen.
Danke,
Bertram
Hallo Bertram,

falls du bereit bist, auch WIN32-Code anstelle reiner VCL zu akzeptieren - das Folgende ist ein Code-Schnipsel, das eine Progressbar in die Statusbar der Form einpasst (und dabei natürlich Breite und Höhe anpasst).

Delphi-Quellcode:
procedure TProcessGauge.connect (B : TProgressBar; L : TLabel);
begin
PG := B;
PGL := L;
SB := nil;
end;

  { call this from FormShow after create and connect }
procedure TProcessGauge.IntoStatusBar (ParentSB : TStatusBar; PBPanel,LPanel : integer);
var xe,ye : integer;
    PBRect : TRect;
    PBStyle : integer;
begin
if not Assigned (PG) then exit;
if not Assigned (ParentSB) then exit;
SB := ParentSB;
SBPanel := PBPanel;
SBText := LPanel;
SB.Perform (SB_GETRECT,SBPanel,integer (@PBRect));
PG.Parent := SB; { Progressbar in Statusbar }
PBStyle := GetWindowLong (PG.Handle,GWL_EXSTYLE);
PBStyle := PBStyle and not WS_EX_STATICEDGE;
SetWindowLong(PG.Handle,GWL_EXSTYLE,PBStyle);
with PBRect do
  begin
  xe := GetSystemMetrics (SM_CXEDGE);
  ye := GetSystemMetrics (SM_CYEDGE);
  Left := Left + xe + 1;
  Top := Top + ye + 1;
  Right := Right - xe - 1;
  Bottom := Bottom - ye - 1;
  end;
PG.BoundsRect := PBRect;
PG.Visible := false;
Application.ProcessMessages; { redraw  statusbar }
end;
Und bitte keine Belehrungen drüber dass das nicht ins Forum passt, ich wollte nur dem Fragesteller helfen und wem der Code nicht passt der darf ihn wegwerfen.

Gruss Reinhard
  Mit Zitat antworten Zitat