<p>It looks a bug. It should be n in onchanging but n-1 in onchange. But it would be good to confirm in Delphi.</p>
<div class="gmail_quote">On Sep 17, 2011 6:00 PM, "Bart" <<a href="mailto:bartjunk64@gmail.com">bartjunk64@gmail.com</a>> wrote:<br type="attribution">> Hi,<br>> <br>> The value of PageCount inside TPageControl.DoChange (and therefore in<br>
> the OnChange event) seems wrong (to me), when you remove a page from<br>> the control.<br>> <br>> When I have n pages and then remove 1, in DoChange the value of<br>> PageCount still is n, when I would expect it to be n-1 at that moment.<br>
> (Tested with Laz r32144).<br>> <br>> I stumbled upon this, after hours of digging in entirely the wrong<br>> place <g>, because in my overriden DoChange I called a method that<br>> would check for PageCount > 0 and if so it would access a page.<br>
> When I removed the last page, PageCount would still be 1, when in fact<br>> no more pages existed at that time, so any access to<br>> Pages[ActivePageIndex] would crash the program.<br>> <br>> Is this really a bug, or is it by design?<br>
> <br>> --<br>> _______________________________________________<br>> Lazarus mailing list<br>> <a href="mailto:Lazarus@lists.lazarus.freepascal.org">Lazarus@lists.lazarus.freepascal.org</a><br>> <a href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus">http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus</a><br>
</div>