Jump to content


Photo

Problem with NxPageControl.OnChanging


  • Please log in to reply
11 replies to this topic

#1 Tulip913

Tulip913
  • Members
  • 13 posts

Posted 04 July 2007 - 05:34 PM

I have a Problem with the OnChanging-event of NxPageControl.

Let's say I have a NxPageControl called "PageControl" on
my main form called "fmMain" and it contains 3 pages.

The content of these pages is defined in separate forms and
assigned in fmMain.OnCreate like this

MyTabForm1 := TfmMyTabForm1.Create(PageControl.Pages[0]);
MyTabForm1.Parent := PageControl.Pages[0];

If I now want to deny a page-change in the OnChanging-event
(i.e. AllowChange := False) the current page still is the
active page but the whole content of that page disappears.

I wrote a work-around using the OnChange-event where
I set back the ActivePageIndex. But this causes some flickering on the form.

I also tried the common Delphi TPageControl - everything is fine there.

Any suggestions ??

#2 emailaya

emailaya

    Master Member

  • Members
  • PipPipPipPipPip
  • 984 posts

Posted 05 July 2007 - 11:23 AM

i have a similar problem when closing a form (clicking on X)
when the tabsheet contains a form inside of it

when clicking on X, OnClosePage event is triggered and the
content disappeared (all blank) but the tab still appears in the top of the pagecontrol
i need to manually! click on another tab to make it selected
and then the "deleted tab" disappears and the content is of the new selected tab
in PageClose event i changed the code to
if accept then
begin
removepage....;
if fpagecount > 0 then factivepageindex := 0;
end;

and only then it works
according to some tests i did, it seems that when a form is
placed inside the tab, some painting commands are not triggered

there is a very old post about this issue exactly
http://www.bergsoft....?showtopic=1313

#3 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 11 July 2007 - 11:46 PM

Hello Tulip913,

Can you please send me one small demo project and I will fix it shortly. I didn't have success to reconstruct a problem.

Thank you.

Best 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.

#4 Tulip913

Tulip913
  • Members
  • 13 posts

Posted 13 July 2007 - 08:23 AM

Sure, I will send you some source tomorrow.
Unfortunately I'm too busy today and I'm not able to return to my delphi computer today.
I found out that the child tab-form also reappears if I set the visible-property to true
in the OnChange-event. Maybe this is a first clue for you.

#5 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 13 July 2007 - 12:14 PM

Hello Tulip,

I am waiting for source tomorow. I am still not sure where is a problem sad.gif

Best 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.

#6 emailaya

emailaya

    Master Member

  • Members
  • PipPipPipPipPip
  • 984 posts

Posted 13 July 2007 - 04:57 PM

i hope the source code from tulip will be enough to solve this issue
plz update this post if needed
thanks

#7 Tulip913

Tulip913
  • Members
  • 13 posts

Posted 14 July 2007 - 11:57 AM

Hey guys,
I finally made it to upload the promised sample (written and tested with D6).
For a convient lock/release of a tab I included a popup menu.

Attached Files



#8 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 14 July 2007 - 01:45 PM

Hello Tulip,

Please open NxPageControl.pas file (in Sources\Next Collection sub-folder).

Then completely replace next procedure:

CODE
procedure TNxCustomNotebook.SetActivePage(const Value: TNxTabSheet);
var
  AOldIndex, ANewIndex: Integer;
  AllowChange: Boolean;
begin
  if csDestroying in ComponentState then Exit;
  if (Value = FActivePage) then Exit;

  { prevent change inside event }
  if not(csLoading in ComponentState)
    then DoChanging(Value.PageIndex, AllowChange); { event }
  if not AllowChange or (Value.PageControl <> Self) then Exit;

  if Assigned(FActivePage) then
  begin
    FActivePage.Hide;
    FActivePage.DoHide; { event }
    AOldIndex := FActivePage.PageIndex;
  end else AOldIndex := -1;
  if Assigned(Value) then
  begin
    AllowChange := True;
    FActivePage := Value;
    if FActivePage.PageVisible then
    begin
      FActivePage.Show;
      FActivePage.DoShow; { event }
      FActivePage.BringToFront;
    end;
    FActivePageIndex := FPageList.IndexOf(Value);
    ANewIndex := FActivePage.PageIndex;
    if InRange(ANewIndex, 0, Pred(FPageList.Count)) then
    begin
      ActivePageChanged;
      RefreshPage(FActivePage.PageIndex);
    end;
  end else
  begin
    FActivePage := nil;
  end;
  if AOldIndex >= 0 then RefreshPage(AOldIndex);
  if not(csLoading in ComponentState) then DoChange; { event }
end;


I hope that now works fine.

Best 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 14 July 2007 - 01:58 PM

i will wait for next release
and i hope it will solve also my problem

thanks

#10 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 14 July 2007 - 02:08 PM

Hello Emailaya,

Simply completely replace this procedure. No need to do any re-compile after that.

Best 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 Tulip913

Tulip913
  • Members
  • 13 posts

Posted 14 July 2007 - 04:26 PM

That's it, thank you !! biggrin.gif
Especially for such a quick response, awesome !

#12 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 15 July 2007 - 04:58 PM

Hello Tulip,

One urgent note, please move line

CODE
AllowChange := True;


immidiatelly after begin inside this procedure.

Best 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.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users