i am trying to set the status of a tadvsmoothbutton at runtime. i want to have the status be aligned with the left side of the button. how can i calculate a value for leftoffset. i cannot set the leftoffset at design time because the caption changes at runtime. how can i calculate the value for leftoffset for the status to be left justified.
We have already provided a sample code via email, didn't you receive the email?
uses AdvGDIP; procedure TForm1.DoButtonResize(Sender: TObject); var g: TGPGraphics; bmp: TBitmap;begin bmp := TBitmap.Create; g := TGPGraphics.Create(bmp.Canvas.handle); try AdvSmoothButton1.Status.Appearance.CalculateSize(g, AdvSmoothButton1.Status.Caption); finally g.Free; bmp.Free; end; AdvSmoothButton1.Status.OffsetLeft := -AdvSmoothButton1.Width + AdvSmoothButton1.Status.Appearance.GetWidth;end; procedure TForm1.FormCreate(Sender: TObject); begin AdvSmoothButton1.Status.Caption := 'ABC'; AdvSmoothButton1.Status.Visible := True; AdvSmoothButton1.OnResize := DoButtonResize; end;
Pieter Scheldeman2017-03-01 08:36:05
Thanks for the reply, i didn't realize i still had my old email address in my profile that is why i didn't receive your email. i updated my profile with the correct email. I tried the code but the status is too far to the left and not visible. I am trying to have the left side of the status be aligned with the left side of the button.
thanks
i left out of my last post that when i first ran the example code you sent i got the error "cannot access protected symbol tcontrol.onresize" so i called the dobuttonresize procedure with my button as a parameter after setting the status caption.
Hi,
You'll need an update for this code. The OnResize event wasn't published yet. the next update will have this included.
thanks