Jump to content


Photo

fix for a bug in pagecontrol OnCloseClick


  • Please log in to reply
23 replies to this topic

#1 emailaya

emailaya

    Master Member

  • Members
  • PipPipPipPipPip
  • 984 posts

Posted 25 January 2007 - 10:36 PM

plz change in nxPageControl unit: MouseUp
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 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 25 January 2007 - 10:42 PM

Hello Emailaya,

Can you please tell me what happen. I am not surre that new code is better.

regards
boki@bergsoft.net | LinkedIn Profile
--
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 emailaya

emailaya

    Master Member

  • Members
  • PipPipPipPipPip
  • 984 posts

Posted 25 January 2007 - 11:03 PM

deletepage made the page blank
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 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 25 January 2007 - 11:06 PM

Hello,

I still no see a problem sad.gif Maybe it is already fixed.

In my version, when I click on X to close page, first tab is automatically selected.

regards
boki@bergsoft.net | LinkedIn Profile
--
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 emailaya

emailaya

    Master Member

  • Members
  • PipPipPipPipPip
  • 984 posts

Posted 25 January 2007 - 11:11 PM

not sure i understood
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 smile.gif

#6 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 26 January 2007 - 06:00 AM

Hello,

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
boki@bergsoft.net | LinkedIn Profile
--
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 emailaya

emailaya

    Master Member

  • Members
  • PipPipPipPipPip
  • 984 posts

Posted 26 January 2007 - 03:48 PM

so mayb u fixed sth
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 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 27 January 2007 - 04:10 AM

I hope that is all fine now.

You may for example decide to add this page to other NxPageControl.

regards
boki@bergsoft.net | LinkedIn Profile
--
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 emailaya

emailaya

    Master Member

  • Members
  • PipPipPipPipPip
  • 984 posts

Posted 02 February 2007 - 06:08 PM

hi

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 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 02 February 2007 - 06:39 PM

Hello,

I still don't understand sad.gif

Here is a RemovePage:

CODE
procedure TNxCustomNotebook.RemovePage(Page: TNxTabSheet);
begin
  FPageList.Delete(FPageList.IndexOf(Page));
  RemoveControl(Page);
  Invalidate;
end;


and DeletePage:

CODE
procedure TNxCustomNotebook.DeletePage(TabSheet: TNxTabSheet);
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
boki@bergsoft.net | LinkedIn Profile
--
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 emailaya

emailaya

    Master Member

  • Members
  • PipPipPipPipPip
  • 984 posts

Posted 02 February 2007 - 06:44 PM

mayb if you'll add a activepage := 0
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 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 02 February 2007 - 09:18 PM

Hello Emailaya,

For me all work fine. I can't find where is a problem.

I can't use your code without testing it.

regards
boki@bergsoft.net | LinkedIn Profile
--
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 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 02 February 2007 - 09:28 PM

Hello,

Please try next code:

CODE
procedure TForm1.Button1Click(Sender: TObject);
var
  tab: TNxTabSheet;
begin
  tab := TNxTabSheet.Create(NxPageControl1);
  tab.Caption := 'Page ' + IntToStr(NxPageControl1.PageCount);
  NxPageControl1.AddPage(tab);
  NxPageControl1.ActivePage := tab;
end;


regards
boki@bergsoft.net | LinkedIn Profile
--
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 emailaya

emailaya

    Master Member

  • Members
  • PipPipPipPipPip
  • 984 posts

Posted 03 February 2007 - 01:40 AM

its a bit late so i will check this 2morrow

i didnt understand the relation between the problem
and the code u wanted me to try smile.gif

i have the above code in my application
and it works fine
shouldnt it?

#15 emailaya

emailaya

    Master Member

  • Members
  • PipPipPipPipPip
  • 984 posts

Posted 13 February 2007 - 07:37 PM

what about this issue?
it seems that removepage should be used and not deletepage

#16 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 14 February 2007 - 01:31 AM

Hello,

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
boki@bergsoft.net | LinkedIn Profile
--
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 emailaya

emailaya

    Master Member

  • Members
  • PipPipPipPipPip
  • 984 posts

Posted 14 February 2007 - 11:55 AM

I show u a screenshot about what happens on my computer

#18 wvd_vegt

wvd_vegt

    Master Member

  • Honorable Members
  • PipPipPipPipPip
  • 710 posts
  • Gender:Male
  • Location:the Netherlands

Posted 14 February 2007 - 05:23 PM

Hi,

I only have a OnPageClose handler setting Accept to the value of a save/discard/cancel messagebox and a OnChange handler that starts with:

CODE
with TNxPageControl(Sender) do
    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.
G.W. van der Vegt

#19 emailaya

emailaya

    Master Member

  • Members
  • PipPipPipPipPip
  • 984 posts

Posted 14 February 2007 - 07:03 PM

if i understood u correctly
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 wvd_vegt

wvd_vegt

    Master Member

  • Honorable Members
  • PipPipPipPipPip
  • 710 posts
  • Gender:Male
  • Location:the Netherlands

Posted 15 February 2007 - 11:52 AM

QUOTE (emailaya @ Feb 14 2007, 07:03 PM) <{POST_SNAPBACK}>
if i understood u correctly
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:

CODE
  for i := Pred(NxPageControl1.PageCount) downto 0 do
    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).

CODE
      tab := TNxTabSheet.Create(Self);
      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
G.W. van der Vegt




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users