浏览代码

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

Martijn Laan 2 周之前
父节点
当前提交
115a136be0
共有 1 个文件被更改,包括 6 次插入3 次删除
  1. 6 3
      Components/BidiCtrls.pas

+ 6 - 3
Components/BidiCtrls.pas

@@ -60,9 +60,12 @@ begin
   var OldHeight := Height;
   var IdealSize: TSize;
   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;
 
 { TNewLinkLabel }