[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:
Delphiprocedure 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
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
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:
if ASkinInfo.Bar.Image.Texture.Empty then raise Exception.Create('Error Message');