TControlBar is buggy, how to unlock paint update? lazarus / 31-LCL ---------------------------------------------------------------------- jamie · 2024-09-27 02:49 Due to all the past complaints of Flicker, Flicker and so on, I believe it was taken too far to alleviate the issue, an issue that most likely was overstated! If I drag and drop two TButtons into a TControlBar, the control bars do not paint unless you resize the form or the controlbar itself. no amount of Invalidate, Repaint, Update etc will force it to paint, basically the update is locked because the size hasn't changed.  The following is an example of a simple text program that you can create.  2 TButtons, with Auto Drag set to true and the rest of the code you can see here. 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, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    Button2: TButton;    ControlBar1: TControlBar;    procedure ControlBar1DragDrop(Sender, Source: TObject; X, Y: Integer);  private   public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.ControlBar1DragDrop(Sender, Source: TObject; X, Y: Integer);begin  (Source as TWinCOntrol).Parent := nil;  COntrolBar1.InsertControl(Source as TWinCOntrol,COntrolBar1.ControlCount);  COntrolBar1.StickControls;//This appears not to work!  Controlbar1.Width := Controlbar1.Width+1; //Must do the following to paint it   ControlBar1.Width := Controlbar1.Width-1; //this is an old BUG for a few controls.  {The Code presented unlocks the update so it will paint}  {This is not restricted to the COntrolBar, it happens elsewhere too}  {Using update, Repaint, Invalidate etc has no effect}end; end.    SO my question is, where is the flag I can turn off to force it to update without me doing what you see above? ---------------------------------------------------------------------- jamie · 2024-09-28 16:04 I believe I found the issue that is causing this particular problem! It appears that the bands only get painted when a WMSIZE message is coming, and the Paint handler is only updating the border from what I can see and maybe the background.    Adding or removing child controls should be doing something to trigger a WMSIZE message or a direct call to the WMSIZE internally.  Since the InsertControl is overriden in this control, could be a place to post a WM_SIZE message. ? ---------------------------------------------------------------------- wp · 2024-09-28 16:54 With the following code the issue does not occur for me (Win-11, Laz/main + fpc 3.2.2). Are you sure that InsertControl does everything what SetParent does? 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 procedure TForm1.ControlBar1DragDrop(Sender,Source: TObject; X,Y: Integer);begin  (Source as TWinControl).Parent := Controlbar1;end; ---------------------------------------------------------------------- jamie · 2024-09-28 18:18 The insertCOntrol is overrided in the ControlBar and the code used in the libs indicate that. Maybe setting the parent directly fixes it however, the fact remain those bars do not get addressed unless a WM_SIZE messge is recieved.  Also, the InsertControl takes care of creating the Bands when inserted via the over ridden method of InsertControl That is problem #1 which can be circumvented in code. Problem 2:  It does not align controls consistently. in Design time if you add a few Tbuttons to the ControlBar, they look good, but when you excute the code, some of the buttons are staggered below and some out of sight! ---------------------------------------------------------------------- wp · 2024-09-28 21:51 Quote from: jamie on September 28, 2024, 08:18:33 pm Also, the InsertControl takes care of creating the Bands when inserted via the over ridden method of InsertControl Setting a break-point in the TControlbar's InsertControl shows that it is called even when assigning the Parent directly like I showed. Quote from: jamie on September 28, 2024, 08:18:33 pm It does not align controls consistently. in Design time if you add a few Tbuttons to the ControlBar, they look good, but when you excute the code, some of the buttons are staggered below and some out of sight! This happens with both your and my methods. And  I checked Delphi: it has the same issue. The point is that the Left position of the dragged button is retained when the parent is the controlbar. When I add 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   (Source as TWinControl).Left := 0;  (Source as TWinControl).Top := 0;to the OnDropDown handler the first dropped button then is at the top/left position in the controlbar; the second dropped button, however, is not positioned behind the first one, but below it (Left = 0). In Delphi, on the other hand, the second button is aligned correctly behind the first one. But changing the parent AFTER repositioning the buttons fixes the issue also for Lazarus. 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 procedure TForm1.ControlBar1DragDrop(Sender,Source: TObject; X,Y: Integer);begin  (Source as TWinControl).Top := 0;  (Source as TWinControl).Left := 0;  (Source as TWinControl).Parent := (Sender as TWinControl);end; ---------------------------------------------------------------------- jamie · 2024-09-28 23:53 Problem with using the Debugger and break points is that when you do that, the window gets a resize message due to you using the debugger, you can't rely on that. The use of the debugger in this way for GUI problems can be miss leading.  Getting back to the InsertControl, there is an index that allows you to insert the control in front of others if you desire, I believe that is one of the points of using that method.   I can do what I've done in the past and that is fixing the code on my end but every time a new release comes around, those fixes normally aren't in It so I have to do this all over again.  My attempts of submitting patch files haven't been very successful lately since the system changed over to Git or whatever it is now.   It looks like I may need to create my own tool menu control, this also has to be in line with Delphi to a degree or something I can use preprocessor statements to control the selection of code between the two. P.S.  I found if I set the TOP of each control at startup, they then move and keep in order! These are the ones placed there at design time.  This is really strange.  I may be able to work around with that.