View Issue Details

IDProjectCategoryView StatusLast Update
0004816JEDI VCL00 JVCL Componentspublic2009-07-08 14:03
ReporterjkelleyAssigned Toobones 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.34 
Target VersionFixed in Version3.38 
Summary0004816: JvCaptionButton draws incorrectly with minimized bsToolWindow
DescriptionJvCaptionButton sets its FHasSmallCaption field to true if BorderStyle is bsToolWindow or bsSizeToolWin, but minimized windows with this style are regular size, causing the buttons to be drawn and placed incorrectly.
TagsNo tags attached.

Activities

jkelley

2009-06-08 21:44

reporter   ~0015634

Update: It looks like this is only the case if themes are turned off; with themes on, minimized tool windows still use small buttons.

obones

2009-06-16 11:37

administrator   ~0015681

Please try with the latest release. If it is still there, please provide the zipped sources of a sample application showing this

jkelley

2009-06-16 18:22

reporter   ~0015690

I tested against r12301 (the most recent change to JvCaptionButton.pas that doesn't include external dependencies) and against JVCL 3.36, and the problem is still there.

My Delphi install is apparently broken right now. Could you use a C++Builder sample application?

If so, I'll upload one. If not, here are instructions for recreating the problem:
1) Create a new "MDI Application" project.
2) Change ChildWin's FormStyle to fsNormal.
3) Change ChildWin's BorderStyle to bsSizeToolWin.
4) Add a TJvCaptionButton to ChildWin. Set the button's Standard property to something like tsbMin so that you can see what its icon looks like.
5) Make sure that Windows is using the classic look (pre-XP, no themes).
6) Run the app, go under File and pick New to create a new child window, then right-click on the child window's toolbar and choose minimize.

2009-06-16 19:17

 

JvCaptionBug.zip (405,114 bytes)

jkelley

2009-06-16 19:17

reporter   ~0015692

Delphi 2009 sample project attached.

2009-06-26 03:08

 

JvCaptionBug.patch (2,611 bytes)
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;
JvCaptionBug.patch (2,611 bytes)

jkelley

2009-06-26 03:09

reporter   ~0015723

The attached patch seems to fix it. I also undid part of the change in r12301; removing that adjustment was necessary to make JvCaptionButton display properly on my Vista Aero Glass machine, so I'm not sure why the adjustment was added or under what circumstances it's needed.

obones

2009-07-08 14:03

administrator   ~0015779

This is now fixed in SVN

Issue History

Date Modified Username Field Change
2009-06-08 21:15 jkelley New Issue
2009-06-08 21:44 jkelley Note Added: 0015634
2009-06-16 11:37 obones Note Added: 0015681
2009-06-16 11:37 obones Status new => feedback
2009-06-16 18:22 jkelley Note Added: 0015690
2009-06-16 19:17 jkelley File Added: JvCaptionBug.zip
2009-06-16 19:17 jkelley Note Added: 0015692
2009-06-26 03:08 jkelley File Added: JvCaptionBug.patch
2009-06-26 03:09 jkelley Note Added: 0015723
2009-07-03 17:29 obones Status feedback => acknowledged
2009-07-08 14:03 obones Note Added: 0015779
2009-07-08 14:03 obones Status acknowledged => resolved
2009-07-08 14:03 obones Fixed in Version => Daily / SVN
2009-07-08 14:03 obones Resolution open => fixed
2009-07-08 14:03 obones Assigned To => obones