View Issue Details

IDProjectCategoryView StatusLast Update
0025111Lazarus CCRPackagespublic2015-05-26 19:02
Reporter21347 Assigned ToDmitry Boyarintsev  
PrioritynormalSeverityminorReproducibilityN/A
Status resolvedResolutionfixed 
PlatformanyOSWindows 
Summary0025111: TRichMemo, patch for theme aware drawing of it's border
DescriptionIn Windows XP and upper, the border of the control is not drawn correctly (i.e. is drawn in pre-WinXP style) when themes are enabled.

It's quite easy to fix this, though, see attached patch (against current SVN version).
Tagspatch
WidgetsetWin32/Win64
Attached Files

Activities

21347

2013-09-29 13:31

reporter  

themes.txt (1,631 bytes)   
Index: win32/win32richmemo.pas
===================================================================
--- win32/win32richmemo.pas	(Revision 2798)
+++ win32/win32richmemo.pas	(Arbeitskopie)
@@ -30,9 +30,11 @@
   Classes, SysUtils, 
   // LCL headers
   LCLType, LCLIntf, LCLProc, WSLCLClasses,
-  Graphics, Controls, StdCtrls, 
+  Graphics, Controls, StdCtrls,
+  //Themes:
+  Themes,
   // Win32WidgetSet
-  Win32WSControls, Win32Int, 
+  Win32Proc, Win32WSControls, Win32Int, Win32Themes,
   // RichMemo headers
   WSRichMemo, Win32RichMemoProc;
 
@@ -89,12 +91,27 @@
 
 function RichEditProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam;
    LParam: Windows.LParam): LResult; stdcall;
+var
+  WindowInfo : PWin32WindowInfo;
 begin 
   if Msg = WM_PAINT then begin
     //todo: LCL WM_PAINT handling prevents richedit from drawing correctly
     Result := CallDefaultWindowProc(Window, Msg, WParam, LParam)
     //Result := WindowProc(Window, Msg, WParam, LParam)
-  end else
+  end
+  else if Msg = WM_NCPAINT then begin
+    //When theming is enabled, and the component should have a border around it,
+    //let the theme manager handle it
+    WindowInfo := GetWin32WindowInfo(Window);
+    if Assigned(WindowInfo) and
+        TWin32ThemeServices(ThemeServices).ThemesEnabled and
+        (GetWindowLong(Window, GWL_EXSTYLE) and WS_EX_CLIENTEDGE <> 0) then begin
+      TWin32ThemeServices(ThemeServices).PaintBorder(WindowInfo^.WinControl, True);
+      Result := 0;
+    end
+    else Result := WindowProc(Window, Msg, WParam, LParam);
+  end
+  else
     Result := WindowProc(Window, Msg, WParam, LParam);
 end;  
 
themes.txt (1,631 bytes)   

Dmitry Boyarintsev

2013-11-10 04:32

developer   ~0071236

hmm... that's possible, but i'm assuming XP could draw the proper border by itself (without explicit drawing). (any information on that?)
Using the workaround like that might break the future compatibility.

Dmitry Boyarintsev

2015-05-26 19:02

developer   ~0084019

Thanks for the patch, it has been applied with some modifications in r4153. Please test and close if ok.

Issue History

Date Modified Username Field Change
2013-09-29 13:31 21347 New Issue
2013-09-29 13:31 21347 File Added: themes.txt
2013-11-10 04:32 Dmitry Boyarintsev Note Added: 0071236
2013-11-10 04:32 Dmitry Boyarintsev Assigned To => Dmitry Boyarintsev
2013-11-10 04:32 Dmitry Boyarintsev Status new => feedback
2014-10-11 14:35 wp Tag Attached: patch
2015-05-26 19:02 Dmitry Boyarintsev Note Added: 0084019
2015-05-26 19:02 Dmitry Boyarintsev Status feedback => resolved
2015-05-26 19:02 Dmitry Boyarintsev Resolution open => fixed