From: <ah...@us...> - 2009-05-03 08:50:46
|
Revision: 12301 http://jvcl.svn.sourceforge.net/jvcl/?rev=12301&view=rev Author: ahuser Date: 2009-05-03 08:50:39 +0000 (Sun, 03 May 2009) Log Message: ----------- Mantis #4398: TJvCpationButton does not work correctly in Windows Vista Modified Paths: -------------- trunk/jvcl/run/JvCaptionButton.pas Modified: trunk/jvcl/run/JvCaptionButton.pas =================================================================== --- trunk/jvcl/run/JvCaptionButton.pas 2009-04-29 17:13:53 UTC (rev 12300) +++ trunk/jvcl/run/JvCaptionButton.pas 2009-05-03 08:50:39 UTC (rev 12301) @@ -144,7 +144,6 @@ FSaveRgn: HRGN; FShowHint: Boolean; FParentShowHint: Boolean; - {tool tip specific} FToolTipHandle: THandle; {tool tip specific end} @@ -152,6 +151,7 @@ {$IFDEF JVCLThemesEnabled} FCaptionActive: Boolean; FForceDrawSimple: Boolean; + FForceRedraw: Boolean; function GetIsThemed: Boolean; procedure SetForceDrawSimple(const Value: Boolean); {$ENDIF JVCLThemesEnabled} @@ -430,6 +430,12 @@ //=== Local procedures ======================================================= +function IsVistaOrNewer: Boolean; +begin + Result := (Win32Platform = VER_PLATFORM_WIN32_NT) and + (Win32MajorVersion >= 6); +end; + function GlobalXPData: TGlobalXPData; begin if not Assigned(GGlobalXPData) then @@ -1216,6 +1222,11 @@ GlobalXPData.AddClient; {$ENDIF JVCLThemesEnabled} + {$IFDEF JVCLThemesEnabled} + if IsVistaOrNewer and IsThemed then // Windows Vista + FForceRedraw := True; + {$ENDIF JVCLThemesEnabled} + Hook; end; @@ -1399,7 +1410,21 @@ { 3. Calc FDefaultButtonWidth } {$IFDEF JVCLThemesEnabled} if IsThemed then - FDefaultButtonWidth := FDefaultButtonHeight + begin + if IsVistaOrNewer then + begin + // 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; + end + else + FDefaultButtonWidth := FDefaultButtonHeight; + end else {$ENDIF JVCLThemesEnabled} if FHasSmallCaption then @@ -2041,8 +2066,15 @@ GetWindowRect(Wnd, WindowRect); OffsetRect(LButtonRect, WindowRect.Left, WindowRect.Top); { Check if button rect is in the to be updated region.. } - if RectInRegion(FSaveRgn, LButtonRect) then + if RectInRegion(FSaveRgn, LButtonRect) + {$IFDEF JVCLThemesEnabled} + or FForceRedraw + {$ENDIF JVCLThemesEnabled} + then begin + {$IFDEF JVCLThemesEnabled} + FForceRedraw := False; + {$ENDIF JVCLThemesEnabled} { ..If so remove the button rectangle from the region (otherwise the caption background would be drawn over the button, which causes flicker) } with LButtonRect do This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |