fix for a bug in pagecontrol OnCloseClick
#1
Posted 25 January 2007 - 10:36 PM
from line:
if Accept then DeletePage(ActivePage);
to:
if Accept then
begin
RemovePage(ActivePage);
if PageCount > 0 then
ActivePageIndex := 0;
end;
otherwise, bad things happen
#2
Posted 25 January 2007 - 10:42 PM
Can you please tell me what happen. I am not surre that new code is better.
regards
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#3
Posted 25 January 2007 - 11:03 PM
but the tab was still active
only when i chose the tab to the left of it
the tab disappeared
if i just changed deletepage to removepage
then the tab+page were gone (which is good)
but then, no tab was active so the page was blank
until the user manually choses a tab
#4
Posted 25 January 2007 - 11:06 PM
I still no see a problem
In my version, when I click on X to close page, first tab is automatically selected.
regards
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#5
Posted 25 January 2007 - 11:11 PM
active tab was the second problem
it seems that deletpage only deletes the page
but the component is still there
only removepage seems to do the whole job
i wonder why there are 2 similar methods
#6
Posted 26 January 2007 - 06:00 AM
DeletePage actually delete complete page. RemovePage delete it from list of pages.
You may see in DeletePage method that there is FreeAndNill call too.
regards
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#7
Posted 26 January 2007 - 03:48 PM
bcoz deletepage seems to just make the page blank
but it was still there
only when i called removepage
the page was gone and another page became active
why would i need to delete a page without removing it from the page list?
#8
Posted 27 January 2007 - 04:10 AM
You may for example decide to add this page to other NxPageControl.
regards
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#9
Posted 02 February 2007 - 06:08 PM
when clicking on close
it still does deletepage and not removepage
attached the result
if i manually click any of the other remaining tabs
the the 3rd tab in the image, disappears
when changing it to what i have written in my original post
everything works fine
Attached Files
#10
Posted 02 February 2007 - 06:39 PM
I still don't understand
Here is a RemovePage:
begin
FPageList.Delete(FPageList.IndexOf(Page));
RemoveControl(Page);
Invalidate;
end;
and DeletePage:
begin
FPageList.Delete(FPageList.IndexOf(TabSheet));
RemoveControl(TabSheet);
TabSheet.RemoveFreeNotification(Self);
FreeAndNil(TabSheet);
end;
and there is a line (FreeAndNil) and this line simply free this Tab.
If you may attach here this demo, with step-by-step this may help.
regards
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#11
Posted 02 February 2007 - 06:44 PM
deletepage will work too
bcoz if i click manually of a different tab
the deleted tab disappears
why do u need a demo?
simply add a page in runtime
and click on X
i didnt understand why dont u want to change to my code which works?
(im on bds2006)
#12
Posted 02 February 2007 - 09:18 PM
For me all work fine. I can't find where is a problem.
I can't use your code without testing it.
regards
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#13
Posted 02 February 2007 - 09:28 PM
Please try next code:
var
tab: TNxTabSheet;
begin
tab := TNxTabSheet.Create(NxPageControl1);
tab.Caption := 'Page ' + IntToStr(NxPageControl1.PageCount);
NxPageControl1.AddPage(tab);
NxPageControl1.ActivePage := tab;
end;
regards
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#14
Posted 03 February 2007 - 01:40 AM
i didnt understand the relation between the problem
and the code u wanted me to try
i have the above code in my application
and it works fine
shouldnt it?
#15
Posted 13 February 2007 - 07:37 PM
it seems that removepage should be used and not deletepage
#16
Posted 14 February 2007 - 01:31 AM
I am sorry, I still don't know where is a problem and why I need to change this. I hope that someone else may report this problem.
regards
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#17
Posted 14 February 2007 - 11:55 AM
#18
Posted 14 February 2007 - 05:23 PM
I only have a OnPageClose handler setting Accept to the value of a save/discard/cancel messagebox and a OnChange handler that starts with:
if Assigned(ActivePage) then
begin
if Visible then
MakeVisible(ActivePageIndex);
Thats all, i have no ghost pages etc and i'm pretty sure they're gone after clicking the topright cross. The last line scrolls the active tab into view.
#19
Posted 14 February 2007 - 07:03 PM
u had the above code, in your OnPageClose event
so when u click the X, YOUR code cancels the ghost page as u described
if you remove the above code from the event,
do u get the same symptom as i? (see screenshot in original post)
#20
Posted 15 February 2007 - 11:52 AM
u had the above code, in your OnPageClose event
so when u click the X, YOUR code cancels the ghost page as u described
if you remove the above code from the event,
do u get the same symptom as i? (see screenshot in original post)
Still works fine (i added an exit as first line of the OnPageClose event).
Btw I succesfully close all pages without ghosts with:
begin
NxPageControl1.ActivePage := NxPageControl1.Pages[i];
NxPageControl1.OnPageClose(NxPageControl1, NxPageControl1.ActivePage.PageIndex, accept); <--basically contains a messagebox.
if accept then
NxPageControl1.DeletePage(NxPageControl1.Pages[i])
else
Exit;
end;
For completeness, i create them like (Self is the main form).
tab.Margin := 4;
NxPageControl1.AddPage(tab, True);
NxPageControl1.ActivePage := Tab;
tab.Caption := 'test';
and the PageControl has options:
[pgAlwaysShowTabsRect,pgBoldActiveTab,pgCloseButton,pgScrollButtons,pgTopBorder]
The first is important as otherwise the area where the tabs resize is reclaimed by the pages. With it it leaves a small dark band where the tabs will be painted
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












