View Issue Details

IDProjectCategoryView StatusLast Update
0022080LazarusLCLpublic2020-06-01 21:10
ReporterVitaliyG Assigned ToPaul Ishenin  
PrioritynormalSeverityminorReproducibilityrandom
Status resolvedResolutionfixed 
Product Version0.9.30.2 
Summary0022080: Blinking of TPageControl when switching tabs
DescriptionWhen switching tabs with mouse in TPageControl it randomly blinks (with gray background color) for short time. This is most noticeable when tab contains black control inside, and when switching in design mode (but it also blinks in runtime).
Steps To ReproduceCreate TPageControl.
Create few tabs in it.
Put TShape in each tab with black fill color and aligned to client.

Switch tabs with mouse - it randomly blinks with gray color (expecting no blinking).
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetWin32/Win64
Attached Files

Relationships

related to 0021352 acknowledged Source Editor flashes every time a new tab is selected. 
related to 0037161 closedMartin Friebe Flicker when changing active TabSheet in TPageControl 

Activities

VitaliyG

2012-05-19 20:34

reporter   ~0059765

Here is fix for this bug.
Need to update following function to not bring to front and repaint tab window that is going to be hided.

lcl\interfaces\win32\win32callback.inc

  function ShowHideTabPage(NotebookHandle: HWnd; Showing: boolean): integer;
  const
    ShowFlags: array[Boolean] of DWord = (SWP_HIDEWINDOW or SWP_NOZORDER, SWP_SHOWWINDOW);
  var
    NoteBook: TCustomNotebook;
    PageIndex: Integer;
    PageHandle: HWND;
  begin
    Notebook := GetWin32WindowInfo(NotebookHandle)^.WinControl as TCustomNotebook;
    PageIndex := Windows.SendMessage(NotebookHandle, TCM_GETCURSEL, 0, 0);
    PageIndex := NotebookPageRealToLCLIndex(Notebook, PageIndex);
    if PageIndex = -1 then exit;
    PageHandle := Notebook.CustomPage(PageIndex).Handle;
+ if Showing then
+ begin
       Windows.SetWindowPos(PageHandle, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE or ShowFlags[Showing]);
       Windows.RedrawWindow(PageHandle, nil, 0, RDW_INVALIDATE or RDW_ALLCHILDREN or RDW_ERASE);
+ end;
    Result := PageIndex;
  end;


Also TCustomPage.WMPaint should be removed from lcl\include\custompage.inc
(if window receives paint message it should be always painted, window that does not need painting will not receive message).

VitaliyG

2012-09-17 20:40

reporter   ~0062454

This seems to be a better solution:
lcl\interfaces\win32\win32pagecontrol.inc

@@ -67,6 +67,9 @@
   PageHandle: HWND;
 begin
   TabControl := GetWin32WindowInfo(TabControlHandle)^.WinControl as TCustomTabControl;
+ if (TabControl.PageIndex <> -1) then
+ Windows.ShowWindow(TabControl.CustomPage(TabControl.PageIndex).Handle, SW_HIDE);
+
   PageIndex := Windows.SendMessage(TabControlHandle, TCM_GETCURSEL, 0, 0);
   PageIndex := TabControl.TabToPageIndex(PageIndex);
 
@@ -273,8 +276,6 @@
               Result := CallDefaultWindowProc(Window, Msg, WParam, LParam);
             end;
             DeliverMessage(AWinControl, LMNotify);
- if LMNotify.Result = 0 then
- ShowHideTabPage(HWndFrom, False);
             MsgResult := LMNotify.Result;

Zeljan Rikalo

2012-09-18 07:42

developer   ~0062462

@Paul, I've assigned this one to you ... if you can take a look into concept provided by Vitaly.

Paul Ishenin

2012-09-24 04:30

manager   ~0062590

I don't understand the concept. Moreover, I don't see any change. It blinks sometimes the same way as before. Moreover, I see blinking very seldom with trunk.

VitaliyG

2013-02-21 12:50

reporter   ~0065799

The concept is to hide old tab and show new in single message (atomic) instead of

1. hide old tab in one message(TCN_SELCHANGING)

2. (some paint message for page control window can be processed here, in the middle and this will cause blinking)

3. show new tab in second message(TCN_SELCHANGE)

Check my comment for related issue 0021352


TCN_SELCHANGING message should be used only to check if tab can be switched (all switching should be processed only in TCN_SELCHANGE message)

VitaliyG

2013-08-05 11:57

reporter   ~0069258

Here is some video of Double Commander:
Without fix: https://dl.dropboxusercontent.com/u/49647350/DCNoFix.avi
With fix: https://dl.dropboxusercontent.com/u/49647350/DCWithFix.avi

VitaliyG

2014-04-29 13:00

reporter   ~0074656

This is also can be easy reproduced in Lazarus IDE
Just turn Twilight color scheme and switch source file tabs with mouse (white flashes are visible)

Martin Friebe

2020-06-01 21:10

manager   ~0123169

resolved via 0021352

It still is 2 messages (keep compatibility).

This means, if you have "Application.ProcessMessages" in any event called between the hide and show, there will be a "white frame" flickering.

Please close if ok.

Issue History

Date Modified Username Field Change
2012-05-19 16:06 VitaliyG New Issue
2012-05-19 16:06 VitaliyG Widgetset => Win32/Win64
2012-05-19 16:19 Martin Friebe Relationship added related to 0021352
2012-05-19 20:34 VitaliyG Note Added: 0059765
2012-09-17 20:40 VitaliyG Note Added: 0062454
2012-09-18 07:41 Zeljan Rikalo Status new => assigned
2012-09-18 07:41 Zeljan Rikalo Assigned To => Paul Ishenin
2012-09-18 07:42 Zeljan Rikalo LazTarget => -
2012-09-18 07:42 Zeljan Rikalo Note Added: 0062462
2012-09-18 07:42 Zeljan Rikalo Status assigned => feedback
2012-09-24 04:30 Paul Ishenin Note Added: 0062590
2013-02-21 12:50 VitaliyG Note Added: 0065799
2013-02-21 12:50 VitaliyG Status feedback => assigned
2013-08-05 11:57 VitaliyG Note Added: 0069258
2014-04-29 13:00 VitaliyG Note Added: 0074656
2020-06-01 20:38 Martin Friebe Relationship added related to 0037161
2020-06-01 21:10 Martin Friebe Status assigned => resolved
2020-06-01 21:10 Martin Friebe Resolution open => fixed
2020-06-01 21:10 Martin Friebe Widgetset Win32/Win64 => Win32/Win64
2020-06-01 21:10 Martin Friebe Note Added: 0123169