Forum > CustomDrawn

Code cleanup at nested procedure SendPaintMessage

(1/2) > >>

lagprogramming:
lcl/interfaces/customdrawn/wincallback.inc has nested procedure SendPaintMessage(ControlDC: HDC);
The procedure has useless variable declarations and assignments to PaintRegion and needParentPaint.

Patch for improvement is:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---diff --git a/lcl/interfaces/customdrawn/wincallback.inc b/lcl/interfaces/customdrawn/wincallback.incindex 4305f0a8cc..716dc08ab9 100644--- a/lcl/interfaces/customdrawn/wincallback.inc+++ b/lcl/interfaces/customdrawn/wincallback.inc@@ -157,14 +157,12 @@ Var   var     DC: HDC;     lBitmap, lMask: HBITMAP;-    PaintRegion: HRGN;     PS : TPaintStruct;     PaintMsg: TLMPaint;     WindowOrg: Windows.POINT;     WindowWidth, WindowHeight: Integer;     DCIndex: integer;     parLeft, parTop: integer;-    needParentPaint: boolean;     BufferWasSaved: Boolean;     lRawImage: TRawImage;   begin@@ -174,9 +172,6 @@ Var     DebugLn(Format('[SendPaintMessage]: Control:%s:%s', [lWinControl.Name, lWinControl.ClassName]));     {$ENDIF} -    // create a paint message-    needParentPaint := False;-     LCLIntf.GetWindowSize(HWND(WindowInfo), WindowWidth, WindowHeight);      // Start the double buffering by checking if we need to increase the buffer@@ -228,7 +223,6 @@ Var         DC := Windows.BeginPaint(Window, @PS);       end else begin         DC := ControlDC;-        PaintRegion := 0;       end;        // Draw the form

AlexTP:
On bugtracker,
https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40237

Josh:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure SendPaintMessage(ControlDC: HDC);  var    DC: HDC;    lBitmap, lMask: HBITMAP;    PaintRegion: HRGN; xx defined but not used    PS : TPaintStruct; ?? not defined but used    PaintMsg: TLMPaint; xxx not defined not used    WindowOrg: Windows.POINT; xx not defined not used    WindowWidth, WindowHeight: Integer;    DCIndex: integer; xx not defined not used    parLeft, parTop: integer; xx    needParentPaint: boolean; xx defined not used    BufferWasSaved: Boolean; xx not defined not used    lRawImage: TRawImage;  begin

lagprogramming:
Indeed.
I wonder why those message filters have been applied to customdrawn. There are simply too many lines that don't do anything except for making the code harder to understand.
I'm also looking forward at
https://forum.lazarus.freepascal.org/index.php/topic,63222.msg478541.html#msg478541

AlexTP:
@lagprogramming
See reply from developers on bugtracker

--- Quote ---Unfortunately, Felipe who had started the CustomDrawn widgetset, has left the team, and the code is unmaintained currently. Of course, this can change when somebody else get motivated to take this under his wings. We should not do anything to complicate such a future work.
Attempting to address the many hints and warnings emitted for the customdrawn interface today it became clear the this widgetset is probably much less than half-finished. There are sections copied from other widgetsets, or empty procedures to be filled with life later. All this can be understand as reminders of what has to be done when the widgetset is to be completed.
Therefore, I strongly pledge to not touch these trivial optimizations as proposed here.
Code cleanup should be performed when something is finished, but not along the way.
--- End quote ---

Navigation

[0] Message Index

[#] Next page

Go to full version