Przeglądaj źródła

Unlike LM_GETIDEALSIZE, BCM_GETIDEALSIZE can fail, so add missing check for that. Also clear IdealSize.cy.

Martijn Laan 2 tygodni temu
rodzic
commit
115a136be0
1 zmienionych plików z 6 dodań i 3 usunięć
  1. 6 3
      Components/BidiCtrls.pas

+ 6 - 3
Components/BidiCtrls.pas

@@ -60,9 +60,12 @@ begin
   var OldHeight := Height;
   var OldHeight := Height;
   var IdealSize: TSize;
   var IdealSize: TSize;
   IdealSize.cx := Width;
   IdealSize.cx := Width;
-  SendMessage(Handle, BCM_GETIDEALSIZE, Width, LPARAM(@IdealSize));
-  Height := IdealSize.cy;
-  Result := Height - OldHeight;
+  IdealSize.cy := 0; { Not needed according to docs and tests, but clearing anyway }
+  if SendMessage(Handle, BCM_GETIDEALSIZE, Width, LPARAM(@IdealSize)) <> 0 then begin
+    Height := IdealSize.cy;
+    Result := Height - OldHeight;
+  end else
+    Result := 0;
 end;
 end;
 
 
 { TNewLinkLabel }
 { TNewLinkLabel }