SRL Archive - Help

Form problem


Shuttleu

2010-07-22 08:45:56

right now i have a strange problem
if i do this
    TabPages[i] := TTabSheet.Create(frmDesign);
TabPages[i].Caption := 'Tab ' + Inttostr(i); // The Caption of the title
Tabpages[i].PageControl := PageControl; // We Must Identify are Page Control
then the form works perfectly
but if i do this
    TabPages[i] := TTabSheet.Create(frmDesign);
with TabPages[i] do
begin
Caption := 'Tab ' + Inttostr(i); // The Caption of the title
PageControl := PageControl; // We Must Identify are Page Control
end;
it gives me the following error
[Runtime Error] : Exception: Control '' has no parent window in line 152 in script C:\Users\Thomas\Desktop\MSI Form.scar

its a strange error and i have no idea what is causing it

~shut

Nava2

2010-07-22 09:20:54

Is pagecontrol the correct name of the TPageControl? Also, is the parent of the TPageControl frmDesign?

All I can think of.. :/

Wizzup?

2010-07-22 10:16:58

From: Shuttleu
right now i have a strange problem
if i do this
    TabPages[i] := TTabSheet.Create(frmDesign);
TabPages[i].Caption := 'Tab ' + Inttostr(i); // The Caption of the title
Tabpages[i].PageControl := PageControl; // We Must Identify are Page Control
then the form works perfectly
but if i do this
    TabPages[i] := TTabSheet.Create(frmDesign);
with TabPages[i] do
begin
Caption := 'Tab ' + Inttostr(i); // The Caption of the title
PageControl := PageControl; // We Must Identify are Page Control
end;
it gives me the following error

its a strange error and i have no idea what is causing it

~shut


First example does: A.B := C;
Second example does: A.B := A.B;

Shuttleu

2010-07-22 10:37:13

From: Wizzup?
First example does: A.B := C;
Second example does: A.B := A.B;


errr… sorry? :confused:

~shut

ZephyrsFury

2010-07-22 11:16:31

From: Shuttleu
errr… sorry? :confused:

~shut


Notice how in the second example you have PageControl := PageControl which basically means you're setting TabPages.PageControl to itself and therefore to nil since the intepreter can't distinguish between TabPages.PageControl and the var PageControl. The error arises because its trying to load a Tab that has no parent.

Solution: Rename the variable PageControl to something else.

Shuttleu

2010-07-22 11:53:06

From: ZephyrsFury
Notice how in the second example you have PageControl := PageControl which basically means you're setting TabPages.PageControl to itself and therefore to nil since the intepreter can't distinguish between TabPages.PageControl and the var PageControl. The error arises because its trying to load a Tab that has no parent.

Solution: Rename the variable PageControl to something else.


ahhh… i see

ima do it now

~shut

EDIT: it works now, thanks
this is what i have
    TabPages[i]:= TTabSheet.Create(frmDesign);
with TabPages[i] do
begin
Caption := 'Player ' + Inttostr(i);
PageControl := VarPageControl;
end;

Pure

2010-07-22 20:27:08

nice job

Shuttleu

2010-07-22 20:28:42

From: Pure
nice job


you havent posted since 2007 and you post here… why…? :confused:

~shut

Wizzup?

2010-07-22 20:28:57

We should drop the 10 posts Junior Member thing…

Shuttleu

2010-07-22 20:30:08

From: Wizzup?
We should drop the 10 posts Junior Member thing…
i agree, it creates too much spam, for example, 3 posts above this one

~shut

Nava2

2010-07-22 21:06:19

From: Shuttleu
i agree, it creates too much spam, for example, 3 posts above this one

~shut


Your post was also spam.

Also, the limit is already removed. Jr member is 10 posts and 3 months activity. There is also no need to become a Jr member unless you want to be involved in the community; since all the scripts are now public.

Blumblebee

2010-07-22 21:07:41

I'm pretty sure we already dropped it…

Back on topic I'm having a bit of issues with Tabs. Because I'm Lazy I'm going to attempt to hijack this thread.

So Curious, when I'm deleting tabs, how do I delete the currently active tab? I've tried

I := tab[tab_count].tabIndex;
tab.free;

but that doesn't work. And,

tab[tab_count].free

just deletes the first tab instead of the last, or the one selected. By the way tab_Count is how many tabs there presently is.

Nava2

2010-07-22 21:11:35

Swap the tab to delete with the last one. Free the last one, then shorten the array.

I think thats how I used to do it..

Blumblebee

2010-07-22 21:16:30

From: Nava2
Swap the tab to delete with the last one. Free the last one, then shorten the array.

I think thats how I used to do it..


okay cool. Thanks :)

Edit: How do you get the current Tab Index?

Nava2

2010-07-22 22:01:09

So much solutions in so little time!

Ron

2010-07-23 02:20:27

In Delphi you can use "Self" to refer to the subject in the with command.


TabPages[i] := TTabSheet.Create(frmDesign);
with TabPages[i] do
begin
Caption := 'Tab ' + Inttostr(i); // The Caption of the title
Self.PageControl := PageControl; // We Must Identify are Page Control
end;

~Ron

Dan Cardin

2010-07-23 07:52:15

for current tab index, is it not just pagecontrol.activepageindex or something of that sort? And do you even need to free it? In making the array one shorter, doesnt that do the same thing?

EDIT: oh wait, if you're using a TTabControl, then tabcontrol.tabindex will do so.

Nava2

2010-07-23 08:49:24

He already got this sorted out haha.

Dan you are correct.