mvanrijnen 124 Posted November 17, 2022 (edited) Hi, Having a problem with an inherited control of TGroupBox/TCustomGroupBox  the line var GroupBox := Control as TCustomGroupBox; in following Vc;.StdCtrls method goes wrong (Invalid typecast);   The inherited control worked always in previois delphi versions, now are we gonna get a lot of problems like this? Other people stumbled up on this problem with inherited controsls? Better, someone knows how to quickly work around this problem? the code from vcl.stdctrl (D11.2):  [edit] hmz, in a clean project it works, going to dig some more   procedure TGroupBoxStyleHook.Paint(Canvas: TCanvas); var  R, CaptionRect: TRect;  Details: TThemedElementDetails;  SaveIndex: Integer;  LStyle: TCustomStyleServices; begin  LStyle := StyleServices;  if not LStyle.Available then Exit;  PaintBackground(Canvas);  CaptionRect := GetCaptionRect(Canvas);  var GroupBox := Control as TCustomGroupBox;  if GroupBox.ShowFrame then   R := GetBoxRect(Canvas);  if Control.Enabled then   Details := LStyle.GetElementDetails(tbGroupBoxNormal)  else   Details := LStyle.GetElementDetails(tbGroupBoxDisabled);  SaveIndex := SaveDC(Canvas.Handle);  try   ExcludeClipRect(Canvas.Handle, CaptionRect.Left, CaptionRect.Top,    CaptionRect.Right, CaptionRect.Bottom);   if GroupBox.ShowFrame then    LStyle.DrawElement(Canvas.Handle, Details, R);  finally   RestoreDC(Canvas.Handle, SaveIndex);  end;  DrawControlText(Canvas, Details, Text, CaptionRect,  Control.DrawTextBiDiModeFlags(DT_VCENTER or DT_CENTER)); end; Edited November 17, 2022 by mvanrijnen Share this post Link to post
mvanrijnen 124 Posted November 17, 2022 fixed .... Was a trick for the custom component to paint like a GroupBox, so the GroupBoxStyleHook was registred for it. Made an own stylehook, and now it works 🙂  Share this post Link to post