* * *

Author Topic: Trying to get the number of pages in the pagecontrol?  (Read 1347 times)

A

  • Guest
Trying to get the number of pages in the pagecontrol?
« on: January 11, 2018, 11:06:43 pm »
Hello,

I am trying to dynamically create pages in a page control.

I have managed to do that, however I need to caption them 'Untitled' plus the number:

Untitled | Untitled1 | Untitled2 | etc.

Which function should I use to get the number of pages in the pagecontrol to allow be to do this?

Thanks for the help!

madref

  • Sr. Member
  • ****
  • Posts: 471
  • ..... A day not Laughed is a day not Lived !!
    • Nursing With Humour
Re: Trying to get the number of pages in the pagecontrol?
« Reply #1 on: January 11, 2018, 11:10:35 pm »
Try something like this while creating the pages
Code: Pascal  [Select]
  1. PageControl.TabSheet1.Caption := 'Untitled';
You treat a disease, you win, you lose.
You treat a person and I guarantee you win, no matter the outcome.

Lazarus 1.8.4 / FPC 3.0.4
Lazarus Trunk / FPC Trunk
Mac OS X High Sierra

Blaazen

  • Hero Member
  • *****
  • Posts: 2570
  • POKE 54296,15
    • Eye-Candy Controls
Re: Trying to get the number of pages in the pagecontrol?
« Reply #2 on: January 11, 2018, 11:11:15 pm »
PageControl1.Tabs.Count; gives count.
Lazarus 1.9.0 r58554 FPC 3.1.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.11.1, Plasma 5.13.2
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.11

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

A

  • Guest
Re: Trying to get the number of pages in the pagecontrol?
« Reply #3 on: January 11, 2018, 11:18:45 pm »
Thanks for your help, that's what I've already got:

Code: Pascal  [Select]
  1.   TabSheet := TTabSheet.Create(PageControl1);
  2.   TabSheet.PageControl := PageControl1;
  3.   TabSheet.Caption := 'Untitled';
  4.   { At the end of that last line, I want to put (pseudo):
  5.   If 'Untitled' Exists, TabSheet.Caption := 'Untitled' +Number of Pages -1
  6.   Else TabSheet.Caption := 'Untitled' +Number of pages }

I want to dynamically create tabs with captions reflecting  how many tabs there currently are already - think most common tabbed text editors. So, for example:

Named Tab | Untitled | Untitled1 | etc.

I hope you understand what I mean.

A

  • Guest
Re: Trying to get the number of pages in the pagecontrol?
« Reply #4 on: January 11, 2018, 11:19:09 pm »
PageControl1.Tabs.Count; gives count.
Thanks! I'll give it a go! :)

A

  • Guest
Re: Trying to get the number of pages in the pagecontrol?
« Reply #5 on: January 11, 2018, 11:29:57 pm »
simpletexteditor.pas(148,22) Error: identifier idents no member "Tabs"

What happened?
Did I mention that I'm using a pagecontrol?

taazz

  • Hero Member
  • *****
  • Posts: 5149
Re: Trying to get the number of pages in the pagecontrol?
« Reply #6 on: January 11, 2018, 11:48:58 pm »
assuming that you do not delete pages, you can use pagecontrol1.pagecount.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Bart

  • Hero Member
  • *****
  • Posts: 3014
    • Bart en Mariska's Webstek
Re: Trying to get the number of pages in the pagecontrol?
« Reply #7 on: January 11, 2018, 11:58:51 pm »
LazEdit does something like that, using a TPageControl.
The relevant code probably is in the editorpagecontrol unit.

Bart

Blaazen

  • Hero Member
  • *****
  • Posts: 2570
  • POKE 54296,15
    • Eye-Candy Controls
Re: Trying to get the number of pages in the pagecontrol?
« Reply #8 on: January 12, 2018, 12:31:19 am »
I'm sorry. Tabs is protected. PageCount is correct.
Lazarus 1.9.0 r58554 FPC 3.1.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.11.1, Plasma 5.13.2
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.11

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus