Forum Replies Created
-
AuthorPosts
-
April 28, 2021 at 6:19 am in reply to: TRzPageControl: Dynamic images on the tabs or their positions to use elsewhere #2468
Hi Ray,
thank you for the example. As I said in my initial post, that’s something I’ve tried first – well, it’s similar. This approach is somewhat limited.
In my attempt I had a round image with a transparent background and some gradient in the ImageList (one that is being used in other places of the application). I then was “exporting” the bitmap, then using it’s canvas to draw the text and thenreplacing the image in the ImageList with the new one.
This worked to some extent, but not in the way I would like it to be. The text was always white, although I set it to black as in the article. It also was always bold and looked somehow stretched or whatever and the transparency was gone – not usable in the end.
Plus this also affects the height of the tab / tab sheet, while UI adorner don’t.
Using your example, I would “lose” the look of the original image as well, but that aside, I can’t draw a rounded rect for some reason. Modified code:
procedure TForm2.RzButton1Click(Sender: TObject); var B: TBitmap; R: TRect; S: string; begin R := Rect( 0, 0, 16, 16 ); B := TBitmap.Create; B.Width := 16; B.Height := 16; B.Canvas.Brush.Color := clRed; B.Canvas.Pen.Color := clWhite; B.Canvas.Pen.Width := 1; //B.Canvas.Rectangle( R ); B.Canvas.RoundRect( R, 8, 8 ); B.Canvas.Font.Color := clWhite; B.Canvas.Brush.Style := bsClear; S := '23'; //B.Canvas.TextRect( R, 2, 2, '23' ); B.Canvas.TextRect( R, S, [tfCenter] ); ImageList1.Replace( 0, B, nil ); end;
With B.Canvas.RoundRect( R, 8, 8 ); only, there is no image visible. Only if I do both lines:
B.Canvas.Rectangle( R );
B.Canvas.RoundRect( R, 8, 8 );
I see the image again, but with the first one (rectangle) being in the background of the second one. Tried different values for the radius and also Ellipse instead of RoundRect.Couldn’t find an explanation on the internet.
March 18, 2021 at 5:15 am in reply to: TRzPageControl: Dynamic images on the tabs or their positions to use elsewhere #2422Hi Ray,
as I said, I’m looking for a way to display images with dynamic text set at runtime.
For instance a main record has several subrecords related to it. When I select that main record (its details are on a TRzTabSheet), I would like to inform the user, that there are X sub records stored for that main record.
The count of the sub records per main record can be different. One has 5, one has none, one has 20 etc.
The easiest would be to just set the tab caption to something like “sub records: X”, but I would like to make it more eye catching by using tab images. I am aware of the possibilities you have described, but the problem is the varying number of sub records to display on the image. I would have to add one image for each possible number of sub records, which doesn’t make sense, because there is no limit.
So I was looking for a way to either “paint” the number as text onto an image that just serves as background, so to speak = combination of an image and a dynamic text on it. This didn’t work properly as described above, so I wanted to use DevExpress UI Adorner badges to display those images, but in order to position them correctly on the TRzTabSheets, I need appropriate position and size of each tab. The only way to access that info seems to be the TRzPageControl.OnPaintTabBackground event, but once I put some code there, to obtain the number of sub records to display and to position the badges, the painting seems to be interrupted and the tabs look “ugly” or “not finished”, although I only read the info of ARect without to change anything PageControl / TabSheet related.
If I just store the info of ARect in a private variable in the TRzPageControl.OnPaintTabBackground event, the painting is not affected, it seems, but the problem here is, that all my code to position the badges is executed before that event and the only way to get it to work is to execute a TTimer instead of calling my code directly, which executes my code with some delay.
That’s why I was wondering, if it’s possible to access the same data as in ARect in the TRzPageControl.OnPaintTabBackground outside of this event. Or alternatively if there is a better way to paint a text onto the image of a TabSheet.
- This reply was modified 3 years, 8 months ago by Patrick Marten.
-
AuthorPosts