1
0
Эх сурвалжийг харах

Parent form might be temporarily null if the control is part of frame

Source commit: 804159c3f50706394f2e5fe6dd7d5218febb72d3
Martin Prikryl 4 сар өмнө
parent
commit
4d351c5583

+ 10 - 3
source/windows/VCLCommon.cpp

@@ -241,9 +241,16 @@ bool IsWindowColorControl(TControl * Control)
 //---------------------------------------------------------------------------
 bool UseDarkModeForControl(TControl * Control)
 {
-  return
-    WinConfiguration->UseDarkTheme() && // optimization
-    GetFormCustomizationComponent(GetParentForm(Control))->DarkMode;
+  bool Result = WinConfiguration->UseDarkTheme();
+  if (Result)
+  {
+    TCustomForm * ParentForm = GetParentForm(Control);
+    Result =
+      // Might be null temporarily if the control is part of frame
+      (ParentForm != NULL) &&
+      GetFormCustomizationComponent(ParentForm)->DarkMode;
+  }
+  return Result;
 }
 //---------------------------------------------------------------------------
 void __fastcall EnableControl(TControl * Control, bool Enable)