Index: JvCaptionButton.pas
===================================================================
--- JvCaptionButton.pas	(revision 2323)
+++ JvCaptionButton.pas	(working copy)
@@ -147,6 +147,7 @@
     {tool tip specific}
     FToolTipHandle: THandle;
     {tool tip specific end}
+    FCurrentWindowState: TWindowState;
 
     {$IFDEF JVCLThemesEnabled}
     FCaptionActive: Boolean;
@@ -1218,6 +1219,8 @@
   FImageChangeLink.OnChange := ImageListChange;
   FParentShowHint := True;
 
+  FCurrentWindowState := TCustomForm(AOwner).WindowState;
+
   {$IFDEF JVCLThemesEnabled}
   GlobalXPData.AddClient;
   {$ENDIF JVCLThemesEnabled}
@@ -1369,6 +1372,7 @@
   Style: DWORD;
   ExStyle: DWORD;
   FrameSize: TSize;
+  Placement: WindowPlacement;
 begin
   if Wnd = 0 then
     Exit;
@@ -1380,13 +1384,17 @@
   if not FHasCaption then
     Exit;
 
+  Placement.length := SizeOf(WindowPlacement);
+  GetWindowPlacement(Wnd, @Placement);
   ExStyle := GetWindowLong(Wnd, GWL_EXSTYLE);
   FHasSmallCaption := ExStyle and WS_EX_TOOLWINDOW = WS_EX_TOOLWINDOW;
+  if (not IsThemed) and (Placement.showCmd = SW_SHOWMINIMIZED) then
+    FHasSmallCaption := False;
   {$IFDEF JVCLThemesEnabled}
   FCaptionActive := (GetActiveWindow = Wnd) and IsForegroundTask;
   {$ENDIF JVCLThemesEnabled}
 
-  if Style and WS_THICKFRAME = WS_THICKFRAME then
+  if (Style and WS_THICKFRAME = WS_THICKFRAME) and (Placement.showCmd <> SW_SHOWMINIMIZED) then
   begin
     FrameSize.cx := GetSystemMetrics(SM_CXSIZEFRAME);
     FrameSize.cy := GetSystemMetrics(SM_CYSIZEFRAME);
@@ -1416,11 +1424,10 @@
       // This is not exactly correct but WM_GETTITLEBARINFOEX returns the coordinates
       // for the "Glass" style. But because we paint into the NC area, out window uses
       // the "Basic" style.
-      FDefaultButtonWidth := GetSystemMetrics(SM_CXSIZE) - 4;
-
-      // Adjust position
-      FDefaultButtonTop := FDefaultButtonTop - 2;
-      FDefaultButtonHeight := FCaptionHeight - 3;
+      if FHasSmallCaption then
+        FDefaultButtonWidth := GetSystemMetrics(SM_CXSMSIZE) - 4
+      else
+        FDefaultButtonWidth := GetSystemMetrics(SM_CXSIZE) - 4;
     end
     else
       FDefaultButtonWidth := FDefaultButtonHeight;
@@ -2730,6 +2737,15 @@
       end;
     WM_NOTIFY:
       Result := HandleNotify(TWMNotify(Msg));
+    WM_SIZE:
+      begin
+        if FCurrentWindowState <> ParentForm.WindowState then
+        begin
+          FNeedRecalculate := True;
+          FCurrentWindowState := ParentForm.WindowState;
+        end;
+        Result := False;
+      end;
   else
     Result := False;
   end;
