Log in

View Full Version : Form problem



Shuttleu
07-22-2010, 12:45 PM
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
07-22-2010, 01:20 PM
Is pagecontrol the correct name of the TPageControl? Also, is the parent of the TPageControl frmDesign?

All I can think of.. :/

Wizzup?
07-22-2010, 02:16 PM
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
07-22-2010, 02:37 PM
First example does: A.B := C;
Second example does: A.B := A.B;

errr... sorry? :confused:

~shut

ZephyrsFury
07-22-2010, 03:16 PM
errr... sorry? :confused:

~shut

Notice how in the second example you have PageControl := PageControl which basically means you're setting TabPages[i].PageControl to itself and therefore to nil since the intepreter can't distinguish between TabPages[i].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
07-22-2010, 03:53 PM
Notice how in the second example you have PageControl := PageControl which basically means you're setting TabPages[i].PageControl to itself and therefore to nil since the intepreter can't distinguish between TabPages[i].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
07-23-2010, 12:27 AM
nice job

Shuttleu
07-23-2010, 12:28 AM
nice job

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

~shut

Wizzup?
07-23-2010, 12:28 AM
We should drop the 10 posts Junior Member thing...

Shuttleu
07-23-2010, 12:30 AM
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
07-23-2010, 01:06 AM
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
07-23-2010, 01:07 AM
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[I].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
07-23-2010, 01:11 AM
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
07-23-2010, 01:16 AM
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
07-23-2010, 02:01 AM
So much solutions in so little time!

Ron
07-23-2010, 06:20 AM
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
07-23-2010, 11:52 AM
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
07-23-2010, 12:49 PM
He already got this sorted out haha.

Dan you are correct.