Bug Report B18452
Visible to All Users

Loading a glyph from an ImageList, image isn't displayed in dxBarButton

created 18 years ago

Hello,

I have got a plugin system for one of my applications, using loadpackage. However, I am finding that when I add a button to the main menu from each plugin, the image I am loading - ImageList1.getbitmap(0, bsbarButton.Glyph) - is not appearing on the button. Screenshot attached - the four white buttons are all loaded by the plugin system.

The code I am using to create the button is below. Am I doing something wrong? If not, I can create an example application to show what is happening.

Thanks for your help?

Regards
Angus Miller

Delphi
procedure TOrderProcessPlugIn.SetMenu(BarManager: TdxBarManager); var AItemLink: TdxBarItemLink; bsbarButton: TdxBarButton; begin BarManager.bars[1].lockupdate := True; bsbarButton:= TdxBarButton.Create(BarManager); bsBarButton.Caption := 'Process Orders'; bsbarButton.Enabled := True; ImageList1.getbitmap(0, bsbarButton.Glyph); AItemLink := BarManager.Bars[1].ItemLinks.Add; AItemLink.Item := bsbarButton; bsBarButton.visible := ivalways; OrderProcess.btOrderProcess:= bsBarButton; OrderProcess.btOrderProcess.OnClick:= OrderProcess.OrderProcessFormClick; BarManager.bars[1].lockupdate := False; end;

Steps to Reproduce:
Run the attached sample and click the TEST button.
Actual Results:
White squares.
Expected Results:
Correct glyphs.

Comments (2)
Serge (DevExpress Support) 18 years ago
    Serge (DevExpress Support) 18 years ago

      Hi Angus,
      The problem seems is caused by the nature of an ImageList. Basically, taking glyphs from an ImageList in such a manner isn't quite correct and may lead to different problems (like the described one). This is because an ImageList stores additional information, not only an image. In particular, the image's mask is stored. The GetBitmap method doesn't retrieve the mask and as a result, the image may be displayed wrong. For example, the elements matching the background color won't be displayed.
      To solve the problem in our test sample, you should use the following code:

      Delphi
      type TBitmapAccess = class(TBitmap); <<<<< ADD procedure TForm1.BitBtn1Click(Sender: TObject); begin // WRONG dxBarButton2.Glyph.PixelFormat := pf24bit; <<<<< ADD dxBarButton2.Glyph.Canvas.Brush.Color := clFuchsia; <<<<< ADD dxBarButton2.Glyph.Canvas.FillRect(Rect(0, 0, 16, 16)); <<<<< ADD ImageList1.GetBitmap(0, dxBarButton2.Glyph); TBitmapAccess(dxBarButton2.Glyph).Changed(nil); <<<<< ADD // OK ImageList1.GetBitmap(0, BitBtn1.Glyph); end;

      If this approach doesn't work in your project, please send us this sample. We will try to find a solution for your particular situation.
      Thanks,
      Serge

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.