Ticket T365081
Visible to All Users

"Invalid operation in GDI+ (Code: 2)" error occurs on changing bitmap

created 9 years ago

[DevExpress Support Team: CLONED FROM T326793: Skin Editor - "Invalid operation in GDI+ (Code: 2)" error occurs on saving a project that contains a number of skins]
Hi,
I have updated DevExpress to 2015.2.4 and if the user changes in runtime style to any of Office2016 themes, I get this message after the painting of whole application is changed, before he/she even leaves the application. Here is the code that is executed after the change in Combo box:

Delphi
procedure TdmCommon.SetColours; var ASkinInfo: TdxSkinInfo; ABitmap: TBitmap; i : Integer; AColors : TRGBColors; begin if RootLookAndFeel.Painter.GetPainterData(ASkinInfo) then begin ABitmap := ASkinInfo.Bar.Image.Texture.GetAsBitmap; try GetBitmapBits(ABitmap, AColors, True); i := 0; glAppColors.Gradient1 := RGB(AColors[i].rgbRed, AColors[i].rgbGreen, AColors[i].rgbBlue); i := length(AColors) - 1; glAppColors.Gradient2 := RGB(AColors[i].rgbRed, AColors[i].rgbGreen, AColors[i].rgbBlue); finally ABitmap.Free; end; end; with frmMain.rbMain.ColorScheme do begin glAppColors.Background := GetPartColor(rfspRibbonForm); glAppColors.Borders := GetPartColor(rspTabNormal); glAppColors.DelimiterLIne := GetPartColor(rspRibbonBottomEdge); end; end;

Am I doing something wrong here?

Best regards,
Goran

Comments (3)
DevExpress Support Team 9 years ago

    Goran,

    I do not have instances mentioned in your code, so I cannot trace it on my side. Would you please provide us with a small sample project demonstrating this error message?

      Hi Paulo,

      You mean those glAppColors? That are some global variables on some global unit used elsewhere in the software that are used on forms so some elements there can be painted. Basically each modal form has it's predecessor TModalForm, inherited from TForm and TModalForm has a special gradient panel at the bottom with a TShape as a line above and two TcxButtons on it for Okay and Cancel. These components (ex buttons) should be painted on FormShow, that's all.

      With skins pre 2015.2.x components the GDI+ error does not occur, with Metropolis and Office2016 schemes the error pop's up. Let me know if You still need a sample or my explanation was enough?

      Best regards,
      Goran

      DevExpress Support Team 9 years ago

        Thank you for your clarification. This information is sufficient to find the cause of this error, so I do not think that these colors are essential. Metropolis and Office2016~ skins do not have the ASkinInfo.Bar.Image texture, so it cannot be used in your algorithm. You can use the following code to validate the Bar.Image property:

        Delphi
        if ASkinInfo.Bar.Image.Texture.Empty then   raise Exception.Create('Error Message');

        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.