THTMLViewer TPageControl.OnChange Bug Work Around
lazarus / 21-General
----------------------------------------------------------------------
RedOctober · 2022-08-27 14:49
Platform: Windows Server 2016, Lazarus 2.0.10, FPC: 3.2.0
Component: THtmlViewer 11.8
I am continuing to use this component because it is light weight, and
it does a good job of quickly displaying HTML pages. It does have
some nasty "issues", but I've worked around them, and so my project
can continue. This is for anyone else still using this component.
Bug:
When placing this component on the right-most tab of a 9 tab
TPageControl, the component will sometimes prevent the OnChange event
from firing if it's .LoadFromString() event was called multiple
times. If it was called an odd number of times, the OnChange works
correctly on all tabs 100% of the time. If it was called an even
number of times, it causes the bug to manifest 100% of the time. This
is even if the .Align bug work around has been implemented.
Note that when the bug manifests, the OnChange continues to fire for
all other tabs. It just will not fire on the tab that contains the
THtmlViewer component.
Here is the fix: Go into the .OnChanging event of the TPageControl,
and place the following code:
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 if
pgcStrms.ActivePage = tabClass then // <--- NEVER CHANGE THIS!
htmQtHTML.Clear; // <--- NEVER CHANGE THIS! The HTML
viewer component messes with the pgcStrm.OnChange event
The work around for the ".Align" bug caused by this component can be
found here: (See last Reply post)
https://forum.lazarus.freepascal.org/index.php?topic=52919.0
Hopefully this will be of help to someone having this problem.