BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TPageControl - Freeing a page ---> Awful flickering
Goto page 1, 2  Next
 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using
View previous topic :: View next topic  
Author Message
Alan Garny
Guest





PostPosted: Mon Jul 28, 2003 10:36 pm    Post subject: TPageControl - Freeing a page ---> Awful flickering Reply with quote



Hi,

I have a TPageControl component (used as part of an editor) in which I
create different tab sheets (one for each file I open/create). Within each
tab sheet, I have my editor. All works fine, except when I want to close...
Basically, I have something like that:

....

(PageControl.ActivePage.Controls[0] As TSyntaxEdit).Free;

PageControl.ActivePage.Free;

PageControl.ActivePageIndex := <whatever>;

....

My problem is with the freeing of the active page... this indeed reset the
active page index to zero... which means that if the new active page index
ois not zero, then we end up with some awful flickering...

Any idea as how to avoid that very annoying behaviour?

Cheers, Alan.


Back to top
Ignacio Vazquez
Guest





PostPosted: Tue Jul 29, 2003 2:39 am    Post subject: Re: TPageControl - Freeing a page ---> Awful flickering Reply with quote



"Alan Garny" <agml (AT) hellix (DOT) com> wrote

Quote:
Any idea as how to avoid that very annoying behaviour?

Try changing to the new page, then freeing the old one.

Cheers,
Ignacio




Back to top
Alan Garny
Guest





PostPosted: Tue Jul 29, 2003 7:57 am    Post subject: Re: TPageControl - Freeing a page ---> Awful flickering Reply with quote



"Ignacio Vazquez" <ivazquezATorioncommunications.com> wrote

Quote:
"Alan Garny" <agml (AT) hellix (DOT) com> wrote in message
news:3f25a57e$1 (AT) newsgroups (DOT) borland.com...
Any idea as how to avoid that very annoying behaviour?

Try changing to the new page, then freeing the old one.

I have tried that, but it doesn't do it. The freeing of the page itself
automatically resets the ActivePageIndex to zero, so I will end up with the
first page activated, which is not necessarily the one I want to be in the
end. I would hate having to change the VCL just to avoid this...

Cheers, Alan.




Back to top
Deck
Guest





PostPosted: Wed Jul 30, 2003 6:18 am    Post subject: Re: TPageControl - Freeing a page ---> Awful flickering Reply with quote

i've had that flickering problem before. in my
case i'm just hiding some pages based on certain
conditions. i suspect it redraws itself everytime
you add/delete/hide/show pages. so what i did
was set

pagecontorl.visible:=false
try
...do your thingy
finally
pagecontorl.visible:=true ;
end;

solves my problem. i guess redraw doesn't need to
be fired as it knows its not visible. try it and let us
know.

cheers





"Alan Garny" <agml (AT) hellix (DOT) com> wrote

Quote:
"Ignacio Vazquez" <ivazquezATorioncommunications.com> wrote in message
news:3f25df5d$1 (AT) newsgroups (DOT) borland.com...
"Alan Garny" <agml (AT) hellix (DOT) com> wrote in message
news:3f25a57e$1 (AT) newsgroups (DOT) borland.com...
Any idea as how to avoid that very annoying behaviour?

Try changing to the new page, then freeing the old one.

I have tried that, but it doesn't do it. The freeing of the page itself
automatically resets the ActivePageIndex to zero, so I will end up with
the
first page activated, which is not necessarily the one I want to be in the
end. I would hate having to change the VCL just to avoid this...

Cheers, Alan.





Back to top
Chris Luck
Guest





PostPosted: Wed Jul 30, 2003 6:55 pm    Post subject: Re: TPageControl - Freeing a page ---> Awful flickering Reply with quote

"Alan Garny" <agml (AT) hellix (DOT) com> wrote


Quote:
I have a TPageControl component (used as part of an editor) in which I
create different tab sheets (one for each file I open/create). Within each
tab sheet, I have my editor. All works fine, except when I want to close...
Basically, I have something like that:

<snip>

Quote:
My problem is with the freeing of the active page... this indeed reset the
active page index to zero... which means that if the new active page index
ois not zero, then we end up with some awful flickering...

Any idea as how to avoid that very annoying behaviour?


In form create - PageControl1.DoubleBuffered := true;


In your TabFree proc -
PageControl1.Perform(WM_SETREDRAW, 0, 0);
try
// let's go freeing...
finally
PageControl1.Perform(WM_SETREDRAW,1, 0);
end;


Use either or both, whatever works best for you.


--
Regards,
Chris Luck.



Back to top
Deck
Guest





PostPosted: Wed Jul 30, 2003 9:18 pm    Post subject: Re: TPageControl - Freeing a page ---> Awful flickering Reply with quote

Quote:

Maybe I have missed something here, but how can making the page control
invisible and then visible avoid the flickering issue? If anything, this
is
going to make the flickering even worse... Am puzzled...

Cheers, Alan.



did you try it?




Back to top
Alan Garny
Guest





PostPosted: Wed Jul 30, 2003 11:22 pm    Post subject: Re: TPageControl - Freeing a page ---> Awful flickering Reply with quote

"Chris Luck" <chris (AT) bvhg (DOT) freeXYZserve.co.uk> wrote

Quote:
"Alan Garny" <agml (AT) hellix (DOT) com> wrote in message
news:3f25a57e$1 (AT) newsgroups (DOT) borland.com...

I have a TPageControl component (used as part of an editor) in which I
create different tab sheets (one for each file I open/create). Within
each
tab sheet, I have my editor. All works fine, except when I want to
close...
Basically, I have something like that:

snip

My problem is with the freeing of the active page... this indeed reset
the
active page index to zero... which means that if the new active page
index
ois not zero, then we end up with some awful flickering...

Any idea as how to avoid that very annoying behaviour?


In form create - PageControl1.DoubleBuffered := true;


In your TabFree proc -
PageControl1.Perform(WM_SETREDRAW, 0, 0);
try
// let's go freeing...
finally
PageControl1.Perform(WM_SETREDRAW,1, 0);
end;


Use either or both, whatever works best for you.

I was very hopeful when I saw your suggestions, but:

1) I had already set DoubleBuffered to true. I guess I must have had some
other flickering issues in the past, which kind of forced me to set
DoubleBuffered to true.

2) Using WM_SETREDRAW on the page control doesn't make any difference
whatsoever. To use on the form that holds the control, however, it does...
but only to some extent. In other words, I don't get the flickering anymore,
but I don't see the contents of any page either. I am not sure I am happy
with this trade off... <g>

This said, I have the feeling that WM_SETREDRAW is the way forward. I guess
I just have to try to understand what's exactly going here... Maybe I should
have a look at the source code for TPageControl...

Cheers, Alan.




Back to top
Chris Luck
Guest





PostPosted: Wed Jul 30, 2003 11:30 pm    Post subject: Re: TPageControl - Freeing a page ---> Awful flickering Reply with quote

"Alan Garny" <agml (AT) hellix (DOT) com> wrote

Quote:
2) Using WM_SETREDRAW on the page control doesn't make any difference
whatsoever.

Curious.

Quote:
To use on the form that holds the control, however, it does...
but only to some extent. In other words, I don't get the flickering anymore,
but I don't see the contents of any page either. I am not sure I am happy
with this trade off...

finally
PageControl1.Perform(WM_SETREDRAW,1, 0);
Invalidate.
end;


--
Regards,
Chris Luck.




Back to top
Alan Garny
Guest





PostPosted: Thu Jul 31, 2003 6:45 am    Post subject: Re: TPageControl - Freeing a page ---> Awful flickering Reply with quote

"Chris Luck" <chris (AT) bvhg (DOT) freeXYZserve.co.uk> wrote

Quote:
"Alan Garny" <agml (AT) hellix (DOT) com> wrote in message
news:3f285352$1 (AT) newsgroups (DOT) borland.com...
2) Using WM_SETREDRAW on the page control doesn't make any difference
whatsoever.

Curious.

To use on the form that holds the control, however, it does...
but only to some extent. In other words, I don't get the flickering
anymore,
but I don't see the contents of any page either. I am not sure I am
happy
with this trade off...
finally
PageControl1.Perform(WM_SETREDRAW,1, 0);
Invalidate.
end;

I had tried something similar (Repaint and Refresh instead of Invalidate),
but didn't work either. Basically, at the moment, I have something like:

MainForm.Perform(WM_SETREDRAW, 0, 0);

PageControl.ActivePage.Free;

PageControl.ActivePageIndex := NewPageIndex;

MainForm.Perform(WM_SETREDRAW, 1, 0);

PageControl.Invalidate;

I must confess that this is driving me nuts... :(

Cheers, Alan.




Back to top
Chris Luck
Guest





PostPosted: Thu Jul 31, 2003 10:53 am    Post subject: Re: TPageControl - Freeing a page ---> Awful flickering Reply with quote

"Alan Garny" <agml (AT) hellix (DOT) com> wrote


Quote:
I had tried something similar (Repaint and Refresh instead of Invalidate),
but didn't work either. Basically, at the moment, I have something like:

MainForm.Perform(WM_SETREDRAW, 0, 0);

PageControl.ActivePage.Free;

PageControl.ActivePageIndex := NewPageIndex;

MainForm.Perform(WM_SETREDRAW, 1, 0);

PageControl.Invalidate;

I must confess that this is driving me nuts... Sad


What I had meant with my last post was MainForm.Invalidate or just Invalidate
as it is the Form that you are locking. If that doesn't do it then there must
be something else going on here - but at this distance it's difficult to see.

The initial fact of the pages flickering so much that it is intrusive seems a
bit odd in itself. It may be that the contents of the Tabsheets are
themselves taking a long time to draw and causing an exaggerated flicker, can
you set the contents (of Tabsheet[0] for instance) visible := false before
freeing? Do you get the same effect in a simple test app. with minimal
Tabsheet contents?


--
Regards,
Chris Luck.




Back to top
Alan Garny
Guest





PostPosted: Thu Jul 31, 2003 2:24 pm    Post subject: Re: TPageControl - Freeing a page ---> Awful flickering Reply with quote

"Chris Luck" <chris (AT) bvhg (DOT) freeXYZserve.co.uk> wrote

Quote:
"Alan Garny" <agml (AT) hellix (DOT) com> wrote in message
news:3f28baf7$1 (AT) newsgroups (DOT) borland.com...

I had tried something similar (Repaint and Refresh instead of
Invalidate),
but didn't work either. Basically, at the moment, I have something like:

MainForm.Perform(WM_SETREDRAW, 0, 0);

PageControl.ActivePage.Free;

PageControl.ActivePageIndex := NewPageIndex;

MainForm.Perform(WM_SETREDRAW, 1, 0);

PageControl.Invalidate;

I must confess that this is driving me nuts... :(


What I had meant with my last post was MainForm.Invalidate or just
Invalidate
as it is the Form that you are locking. If that doesn't do it then there
must
be something else going on here - but at this distance it's difficult to
see.

The initial fact of the pages flickering so much that it is intrusive
seems a
bit odd in itself. It may be that the contents of the Tabsheets are
themselves taking a long time to draw and causing an exaggerated flicker,
can
you set the contents (of Tabsheet[0] for instance) visible := false before
freeing? Do you get the same effect in a simple test app. with minimal
Tabsheet contents?

Ok, I have just created a very simple application that shows the problem I
am experiencing... See b.p.attachments. Note that I have double buffered
everything, just in case... yet not difference... If you have any idea,
please let me know...

Cheers, Alan.




Back to top
Chris Luck
Guest





PostPosted: Fri Aug 01, 2003 10:50 am    Post subject: Re: TPageControl - Freeing a page ---> Awful flickering Reply with quote

"Alan Garny" <agml (AT) hellix (DOT) com> wrote

Quote:
I'll give it a closer look (when the world stops intruding) and come back.

Right, having chased the world away long enough to explore, I have come to the
same conclusion as Ignacio had done earlier: switch to the next tab first then
free the unwanted page. But looking at your response to Ignacio leaves me
wondering if there are version issues showing here. Anyway, I'm a bit puzzled
by your statement - "The freeing of the page itself automatically resets the
ActivePageIndex to zero".

I'm using BCB4 (and D2 btw) which don't have ActivePageIndex. If the
ActivePageIndex doesn't work for you do you have the option of using the old
codeing style using ActivePage.PageIndex? I dispensed with explicitly freeing
the Memo as you gave the Tabsheet as the Memo's owner.

procedure TForm1.Button2Click(Sender: TObject);
var
I: Integer;
begin
if (PageControl1.PageCount > 0) then
begin
I := PageControl1.ActivePage.PageIndex;
if I > 0 then
begin
PageControl1.ActivePage := PageControl1.Pages[I - 1];
PageControl1.Pages[I].Free;
end
else
begin
if (PageControl1.PageCount > 1) then
PageControl1.ActivePage := PageControl1.Pages[I + 1];
PageControl1.Pages[I].Free;
if (PageControl1.PageCount > 0) then
PageControl1.ActivePage := PageControl1.Pages[I];
end;
end;
end;


Tested here without DoubleBuffering gives an expected level of flicker over
that part of the Memo that contains text, but none of the screen-wide
flashing. I haven't come to any useful conclusion as to why it flickers so
much when you do free the active page .

--
Regards,
Chris Luck.



Back to top
Alan Garny
Guest





PostPosted: Fri Aug 01, 2003 1:08 pm    Post subject: Re: TPageControl - Freeing a page ---> Awful flickering Reply with quote

"Chris Luck" <chris (AT) bvhg (DOT) freeXYZserve.co.uk> wrote

Quote:
"Alan Garny" <agml (AT) hellix (DOT) com> wrote in message
news:3f293ac0$1 (AT) newsgroups (DOT) borland.com...
I'll give it a closer look (when the world stops intruding) and come
back.

Right, having chased the world away long enough to explore, I have come to
the
same conclusion as Ignacio had done earlier: switch to the next tab first
then
free the unwanted page. But looking at your response to Ignacio leaves me
wondering if there are version issues showing here. Anyway, I'm a bit
puzzled
by your statement - "The freeing of the page itself automatically resets
the
ActivePageIndex to zero".

I'm using BCB4 (and D2 btw) which don't have ActivePageIndex. If the
ActivePageIndex doesn't work for you do you have the option of using the
old
codeing style using ActivePage.PageIndex? I dispensed with explicitly
freeing
the Memo as you gave the Tabsheet as the Memo's owner.

procedure TForm1.Button2Click(Sender: TObject);
var
I: Integer;
begin
if (PageControl1.PageCount > 0) then
begin
I := PageControl1.ActivePage.PageIndex;
if I > 0 then
begin
PageControl1.ActivePage := PageControl1.Pages[I - 1];
PageControl1.Pages[I].Free;
end
else
begin
if (PageControl1.PageCount > 1) then
PageControl1.ActivePage := PageControl1.Pages[I + 1];
PageControl1.Pages[I].Free;
if (PageControl1.PageCount > 0) then
PageControl1.ActivePage := PageControl1.Pages[I];
end;
end;
end;


Tested here without DoubleBuffering gives an expected level of flicker
over
that part of the Memo that contains text, but none of the screen-wide
flashing. I haven't come to any useful conclusion as to why it flickers
so
much when you do free the active page .

Ok, I just had a look at the VCL source code and... maybe that's what I
should have done before even posting my original message...

Basically the issue is that the freeing of a page is done via a procedure
called RemovePage. The first thing that procedure does is to find out which
is the next page to activate and rather than looking for the PREVIOUS page
or the NEXT page if we are freeing the first page (as does the Delphi IDE,
for instance), it ALWAYS looks for the NEXT page...

This means that when I said that freeing a page resets ActivePageIndex to
zero (i.e. the first page), I was partially wrong. It's just that I had
always done my tests by freeing the last page... but if one frees a "middle"
page, then the new active page will be the next one, as expected from the
source code...

Anyway, the problem remains... For some reasons I really don't understand,
TPageControl decides to select the NEXT page when one removes a page, while
IMHO it should select the PREVIOUS one... and if we remove the first page,
then just select the new first page. At least, that's how the Delphi IDE
behaves and that's also the behaviour that I find "normal" and that I would
like to have in my application...

So, in the end, I decided to make a local copy of ComCtrls.pas in my
project's directory and modified the RemovePage procedure so that it does
what I think it should be doing... Originally, we had:

NextSheet := FindNextPage(Page, True, not (csDesigning in
ComponentState));

and now, I have:

NextSheet := FindNextPage(Page, Page.PageIndex = 0, not (csDesigning in
ComponentState));

Now, the issue that I am facing is the distribution of my program... indeed,
I also intend to distribute the source code... and I wonder whether I am
allowed to distribute "my" version of ComCtrls.pas... I would think not, but
in that case, what could be done?

Cheers, Alan.



Back to top
Alan Garny
Guest





PostPosted: Sun Aug 03, 2003 1:33 am    Post subject: Re: TPageControl - Freeing a page ---> Awful flickering Reply with quote

"Chris Luck" <chris (AT) bvhg (DOT) freeXYZserve.co.uk> wrote

Quote:
"Alan Garny" <agml (AT) hellix (DOT) com> wrote in message
news:3f2a6666$1 (AT) newsgroups (DOT) borland.com...

Now, the issue that I am facing is the distribution of my program...
indeed,
I also intend to distribute the source code... and I wonder whether I am
allowed to distribute "my" version of ComCtrls.pas... I would think not,
but
in that case, what could be done?

No, changing a line or two of Borlands code won't allow you to pass it off
as
your code! If Buffering the Tabsheet contents doesn't do it them I'm
stumped
too.

I have no intention to claim Borland's code to be mine. No, I have actually
left everything as it is. I have just commented out the line that I
personally believe to be wrong and replaced it with mine and put a comment
about what I have done and why I have done it. Nothing more nothing less.
No, my concern is to know whether I can distribute that source code from
Borland, keeping in mind that my project is open source and as such will be
released with source code. So, I wouldn't want to have to tell any
interested user to modify Borland's source code themselves, when I have done
it...

Anyway, I have the feeling that it might not be legal... So I will have a
look at your other suggestion, since it looks interesting and may avoid me
having to modify Borland's source code...

Cheers, Alan.




Back to top
Ignacio Vazquez
Guest





PostPosted: Sun Aug 03, 2003 1:38 am    Post subject: Re: TPageControl - Freeing a page ---> Awful flickering Reply with quote

"Alan Garny" <agml (AT) hellix (DOT) com> wrote

Quote:
...and I wonder whether I am
allowed to distribute "my" version of ComCtrls.pas... I would think not,
but
in that case, what could be done?

One thing you can/should do is post your problem as well as the solution
you've discovered to Quality Central as a Design Problem.

http://qc.borland.com/

Cheers,
Ignacio




Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.