RB 21.03, custom preview and toolbar button images
Hi,
we recently upgrader Report Builder from 20.04 to 21.03. While testing some code I found out a weird bug. We use custom preview for quite some years now built as per rbWiki suggestions. On this custom preview which is part of our major project we added a button to prepare a special form of email and the button has dedicated image not changed since the creation of the preview form. The bitmap is stored in a dedicated resource file. The problem is that from RB 21.03 the image is something different, something that is "stock" from RB.
In unit named TppAdxPreview we have the following code that served well for years:
Best regards,
Goran
we recently upgrader Report Builder from 20.04 to 21.03. While testing some code I found out a weird bug. We use custom preview for quite some years now built as per rbWiki suggestions. On this custom preview which is part of our major project we added a button to prepare a special form of email and the button has dedicated image not changed since the creation of the preview form. The bitmap is stored in a dedicated resource file. The problem is that from RB 21.03 the image is something different, something that is "stock" from RB.
In unit named TppAdxPreview we have the following code that served well for years:
procedure TppAdxPreview.CreateToolbarItems; var idx1, idx2 : Integer; cMaskColor : TColor; bmp : TBitmap; Stream: TResourceStream; begin inherited; //Save position of Email button idx1 := Toolbar.Items.IndexOf(EmailButton); Toolbar.BeginUpdate; try FCodedEmailButton := Toolbar.AddButton(); //FCodedEmailButton.ImageIndex := ToolImageList.AddTool('PPCODEDEMAIL'); //instead of line above, here is the code that does "the same" and works: bmp := TBitmap.Create; try Stream := TResourceStream.Create(hInstance, 'PPCODEDEMAIL', RT_RCDATA); try bmp.LoadFromStream(Stream); cMaskColor := Bmp.Canvas.Pixels[0, Bmp.Height-1]; FCodedEmailButton.ImageIndex := ToolImageList.AddMasked(Bmp, cMaskColor); finally Stream.Free; end; finally bmp.Free; end; //till here... FCodedEmailButton.OnClick := ehToolbutton_Click; FCodedEmailButton.Tag := 100; FCodedEmailButton.Hint := 'Pošlji kodiran e-mail'; finally Toolbar.EndUpdate; end; //Move newly created button adjacent to the original email button idx2 := Toolbar.Items.IndexOf(FCodedEmailButton); Toolbar.Items.Move(idx2, idx1+1); end;How can I get the correct bitmap back?
Best regards,
Goran
Goran Brumen
Audax d.o.o.
Audax d.o.o.
Comments
Call AddTool('CodedEmail', Bmp) or AddToolWithMask('CodedEmail', Bmp, Msk). I think the first version will work for you.
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
I tried many variants and yes, the first one is close to what I need but the transparency does. It is relatively okay with silver skin since what should be transparent is in silver but is visible.
The second call is better but that means I have to prepare the mask BMP. If I use the second variant, I guess the BMP should be in 256 shades of gray? Black is transparent, white is opaque?
Best regards,
Goran
Audax d.o.o.
don't bother, I solved the problem. The mask bitmap did not work, at least not as black&white image. So I convereted the bitmap image to transparent PNG and now I use slightly different code. Maybe it will help somebody. I hope somebody find this useful.
Best regards,
Goran
Audax d.o.o.