How to prevent image lag when moving panels around ?? lazarus / 39-Graphics ---------------------------------------------------------------------- Josh · 2017-09-11 22:01 Hi just been experimenting with re_sizing and moving panels around the screen, but if I move them at any speed I get a screen update lag isssue. I have used setbounds when updating any panels position/size to minimize updates. I have doublebuffered on for form and panels Placing Application.processmessages; after updating the panels positions helps; but does not eliminate. Removing the background TImage drastically helps; but does not eliminate also Is there some other technique that can help? ---------------------------------------------------------------------- Akira1364 · 2017-09-12 02:24 There's not really any way to completely eliminate the "trailing effect". The window simply can't redraw itself fast enough. Just one of those things that comes with GDI software rendering. ---------------------------------------------------------------------- taazz · 2017-09-12 07:19 that looks to me like miscalculated region/rect update, I usually see that effect when my painting procedure is a bit smaller than the invalidated rectangle or the window is bussy and does not refresh it self at all forcing windows to draw the cached image instead. If your application is processing heavy try to move the processing to a thread or call the form's update method once a while and see if that helps. ---------------------------------------------------------------------- Josh · 2017-09-12 09:18 Hi Thanks for the feedback, I think you have confirmed that the issue is not something that can be easily solved, if at all. I experimented adding a timer, that called form update only when a panel is moving/resizing at an interval of 20; this had some improvement. I may have to go back to forms; but main issue I had with form was that I want to keep the child forms within the screen bounds of the main form, if they exceed then to increase the main forms dimensions to suit. Its just an experiment to create a basic 'scaleable desktop environment' within a main form. So some re-thinking required...... ---------------------------------------------------------------------- taazz · 2017-09-12 12:43 Quote from: josh on September 12, 2017, 11:18:53 amHi Thanks for the feedback, I think you have confirmed that the issue is not something that can be easily solved, if at all. It is expected yes, mostly because of the way that windows handles refreshing. The form creates a region that needs to refresh that excludes the rectangles of the child TWinControls (panels, tedits, scrollbox, etc) expecting that those control will receive their own refresh message and draw them self after the current paint operation is finished. As you said you are moving a panel but I'm thinking that you do not call invalidate after each move of the panel. This should force the form to recalculate the region to paint after each move and probably introduce flickering in the process ---------------------------------------------------------------------- Josh · 2017-09-12 15:47 Hi Tazz, I have tried invalidate,update, application.processmessages when ever the panel ordinates have changed or its dimension have changed, and always get a screen update lag. I have never played with GL, so wondering if a GL component exists where it would take standard lcl components and work, as I think that GL would solve the issue, but suspect I will end up with other issues in the process. So I am doing some research into what I can expect if I go and try that approach. At the moment it is not for anything in particular, but have a few days free and thought I would spend the time expanding my knowledge on some ideas and areas that I have not used before.... Thanks again for your input. As I thin if I try the GL route I will have many more questions to fire at the community. ---------------------------------------------------------------------- taazz · 2017-09-12 16:16 Quote from: josh on September 12, 2017, 05:47:34 pmHi Tazz, I have tried invalidate,update, application.processmessages when ever the panel ordinates have changed or its dimension have changed, and always get a screen update lag. bammer I was hopping that would help. I'll try to create a small sample application that demonstrates the problem and see if I get something out of it. Quote from: josh on September 12, 2017, 05:47:34 pmI have never played with GL, so wondering if a GL component exists where it would take standard lcl components and work, as I think that GL would solve the issue, but suspect I will end up with other issues in the process. So I am doing some research into what I can expect if I go and try that approach. At the moment it is not for anything in particular, but have a few days free and thought I would spend the time expanding my knowledge on some ideas and areas that I have not used before.... Thanks again for your input. As I thin if I try the GL route I will have many more questions to fire at the community. GL you mean opengl? Isn't this a bit like using a cannon to swat a fly? In any case there are a number of opengl libraries out there that you can use. Lately I'm playing around with GLScene my self which seems to have some standard controls that can be used inside the opengl I haven't used them yet as I'm more focused on the geometry of things at the moment. ---------------------------------------------------------------------- engkin · 2017-09-12 16:40 I failed in replicating the problem on my old computer!! Here is the code I used: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls; type   { TForm1 }   TForm1 = class(TForm)    Image1: TImage;    Panel1: TPanel;    procedure Image1Click(Sender: TObject);    procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton;      Shift: TShiftState; X, Y: Integer);    procedure Panel1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer      );    procedure Panel1MouseUp(Sender: TObject; Button: TMouseButton;      Shift: TShiftState; X, Y: Integer);  private    sx, sy: Integer;  public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;  Shift: TShiftState; X, Y: Integer);var  panel: TPanel absolute Sender;begin  if Sender is TPanel then  begin    panel.Tag := 1;    sx := x;    sy := y;  end;end; procedure TForm1.Image1Click(Sender: TObject);begin end; procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,  Y: Integer);var  dx, dy: Integer;  panel: TPanel absolute Sender;begin  if Sender is TPanel then  begin    if panel.Tag = 1 then    begin    dx := x-sx;      dy := y-sy;      panel.Left := panel.Left + dx;      panel.Top := panel.Top + dy;    end;  end;end; procedure TForm1.Panel1MouseUp(Sender: TObject; Button: TMouseButton;  Shift: TShiftState; X, Y: Integer);var  panel: TPanel absolute Sender;begin  if Sender is TPanel then    panel.Tag := 0;end; end. I think the image you are using is too big, maybe? I assumed you are using Windows? What bit depths do you have in your desktop settings? Can you provide a small example that we can test? I most likely would do the background painting myself, not using TImage. In addition to that I would bypass the WM_ERASEBKGND message, it is not needed since the image covers everything. Edit: Hold a second, the image you provided has a bad area that is bigger than the panel you are moving. Is that another panel? if so, then it is that panel that is not getting painted, not the form. ---------------------------------------------------------------------- Josh · 2017-09-12 18:19 Hi engkin I have a form with 2 primary panels Top Panel ( where menus etc to go) Main Panel ( where all other panels and background timage is placed). This was only a test, I was going to have the form be a borderless form, and the top panel to simulate these controls, the main panel can be streched to increase the overall size of the form, and the panels with in the mainpanel can be stretched and moved about, when they are moved beyound the bounds of main panel, the main panel is increased but not the form which then creates the scroll bars to navigate around the new area. I'll create a sample project, I will need to remove some graphics and components I have added on for testing.. ---------------------------------------------------------------------- BeanzMaster · 2017-09-12 21:03 Hi Just try to set panel's properties, BevelInner and BevelOuter to bvNone. Normally, the "Lag" you see is now off. A Bug with contours drawing ? Cheers