PDA

View Full Version : adding tabs/ page controll



Awkwardsaw
05-30-2009, 03:59 AM
hmm, i can seem to figure out how to add tabs / page controll.

im making a rs client(its all done for the most part, just would like to add in tabs for extra stuff)

a tut/ good explination is welcome :)

i'll release a different version of the client later, atm is strictly for the clan i'm in.

+rep for who ever first lets me understand it

thanks :)

Cazax
05-30-2009, 05:36 AM
PageControl is in the Win32 tab(if you are using Delphi 7). To add tabs dynamically you can try google or search some tutorials in the advanced section :)

ShowerThoughts
05-30-2009, 05:39 AM
Vs2008 is this to easy.;)
But yes Vs2008 != Delphi IDE. (RAD)

Awkwardsaw
05-30-2009, 08:39 AM
PageControl is in the Win32 tab(if you are using Delphi 7). To add tabs dynamically you can try google or search some tutorials in the advanced section :)

iv been lurking google for about an hour :( i did find some neat stuff, but no enchilada when it comes to page controll

Cazax
05-30-2009, 09:13 AM
Two tab tutorials from SRL:
http://www.villavu.com/forum/showthread.php?t=13618
http://www.villavu.com/forum/showthread.php?t=27976
If you still don't understand I may teach you then :p

Awkwardsaw
05-30-2009, 09:54 AM
oo. i didnt know scar and delphi had the "exact" same format, i'll play around with them

Shuttleu
05-30-2009, 09:56 AM
well scar is written in Delphi/pascal
they are not the "exact" same format (?) but they are close

~shut

NiCbaZ
05-30-2009, 11:10 AM
You right click on the page control and choose "Add page"

Awkwardsaw
05-30-2009, 11:30 AM
hmm wow. now my form isnt doing anything at all. (i must be this much of a noob.. haha)

like it compiles, but nothing more. as in rs wont load, and the calculator thing doesnt work

i might as well just pm you cazax, i'll be asking a lot of questions haha

edit: i just deleted the code and did it again, it started working again =o

still need to pm you on the tabs though

editedit: ok, i got that done. time to figure out how to put stuff on the tabs.. =D which aparently, you cant put browsers on tabs... =\

NiCbaZ
05-30-2009, 02:07 PM
You can :)

Awkwardsaw
05-30-2009, 10:04 PM
do you mind enlightening me?:)

Cazax
05-31-2009, 12:36 AM
Memo1 := TMemo.Create(Self);
Memo1.Parent := TabPage[Page];//TabPage = TTabSheet(array)
etc
That's the way you add components to a tab.

Awkwardsaw
05-31-2009, 12:55 AM
what i mean is,

[Error] CoSRSClient.pas(77): Cannot assign to a read-only property

and this is the line

webbrowser1.Parent := TabPages[1];

other than that, i got every thing on the tab that i want

Cazax
05-31-2009, 12:56 AM
Did you create the component using the IDE? Create it during runtime to select its parent.

Awkwardsaw
05-31-2009, 01:16 AM
wait what?

explain the process :)

Cazax
05-31-2009, 09:15 AM
public var WB : TWebBrowser;
Procedure CreateWebBrowser;
Begin
WB := TWebBrowser.Create(Self);
WB.Parent := TabPage[Page];
End;
...
//then you can use it to browse
//remember to free the pages and its components when closing the form(use that event)
WB.Free;
TabPage[Page].Free;

:)

Awkwardsaw
05-31-2009, 09:42 AM
i love you cazax. haha.

lemme open up delphi and i'll try it out

edit: nope, still the same error.
[Error] CoSRSClient.pas(85): Cannot assign to a read-only property:

WB.Parent := TabSheet1;

Cazax
05-31-2009, 10:12 AM
Post the source? Then I could fix it. And shouldn't it be TabSheet[1]? Unless you are not using an array...

Awkwardsaw
05-31-2009, 10:41 AM
no, its not an array, when i made it using the ide(or w/e) it made the names, so i was just to lazy to change them =p


unit CoSRSClient;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw, ComCtrls, ExtCtrls;

type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
num1edit: TEdit;
num2edit: TEdit;
answeredit: TEdit;
Label2: TLabel;
Label3: TLabel;
Label1: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
MonthCalendar1: TMonthCalendar;
NotePad: TMemo;
Button6: TButton;
button7: TButton;
Button5: TButton;
Image1: TImage;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
procedure CreateRSBrowser;
procedure Button5Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);

private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
num1, num2, answer: integer;
answer1: extended;
fileName : String;
fileData : TStringList;
openDialog : TOpenDialog;
RWB : TWebBrowser;
//TabPages : array [1..3] of TTabSheet;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
TabSheet1.Caption := 'RuneScape';
TabSheet2.Caption := 'Forums';
TabSheet3.Caption := 'IRC';
{TabSheet1.PageControl := PageControl1;
Tabsheet2.PageControl := PageControl1;
Tabsheet3.PageControl := PageControl1;}
//webbrowser1.Parent := TabSheet1;
CreateRSBrowser;
Form1.Caption := 'CoS''s Runescape Client - Made by Akwardsaw';
webbrowser1.Navigate('www.runescape.com');
num1edit.text := '';
num2edit.text := '';
answeredit.Text := '';
Notepad.Text := 'NotePad';
Notepad.ScrollBars := ssVertical;
Notepad.Font.Name := 'Courier New';

end;

Procedure CreateRSBrowser;
Begin
RWB := TWebBrowser.Create(Form1);
RWB.Parent := TabSheet1;
End;

procedure TForm1.Button5Click(Sender: TObject);
begin
num1edit.text := '';
num2edit.text := '';
answeredit.text := '';
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
num1 := strtoint(num1edit.text);
num2 := strtoint(num2edit.text);
answer := num1 + num2;
answeredit.text := inttostr(answer);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
num1 := strtoint(num1edit.text);
num2 := strtoint(num2edit.text);
answer := num1 - num2;
answeredit.text := inttostr(answer);
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
num1 := strtoint(num1edit.text);
num2 := strtoint(num2edit.text);
answer := num1 * num2;
answeredit.text := inttostr(answer);
end;

procedure TForm1.Button4Click(Sender: TObject);
var answer : extended;
begin
num1 := strtoint(num1edit.text);
num2 := strtoint(num2edit.text);
answer := num1 / num2;
answeredit.text := floattostr(answer);
end;

procedure TForm1.Button7Click(Sender: TObject);
begin
notepad.text := 'NotePad';
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
WB.Free;
TabPage[Page].Free;
end;

end.

Cazax
05-31-2009, 10:47 AM
You are assigning two times the parent of the webbrowser:
TabSheet1.Caption := 'RuneScape';
TabSheet2.Caption := 'Forums';
TabSheet3.Caption := 'IRC';
{TabSheet1.PageControl := PageControl1;
Tabsheet2.PageControl := PageControl1;
Tabsheet3.PageControl := PageControl1;}
//webbrowser1.Parent := TabSheet1;
CreateRSBrowser;

to:
TabSheet1.Caption := 'RuneScape';
TabSheet2.Caption := 'Forums';
TabSheet3.Caption := 'IRC';
TabSheet1.PageControl := PageControl1;
Tabsheet2.PageControl := PageControl1;
Tabsheet3.PageControl := PageControl1;
CreateRSBrowser;

You can also use instead of code tags :)

Awkwardsaw
06-02-2009, 06:54 AM
Oo. i found out about form docking using page control (very neat)

i found a really good video tut on youtube, and i tried it out exactly, but i got the error

"undeclared variable: form2" or what ever, so when i call it as a variable, i keep getting the same error.

yes, i know this is off topic to the original thread, but i dont really want to make another thread =\

edit: getting the sourse now. i had to swich computers real fast

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
PageControl1: TPageControl;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
Tform2.create(application).show;
end;

end.

and the second "unit":
unit Unit2;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw, StdCtrls;

type
TForm2 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.FormCreate(Sender: TObject);
begin
color := random($fffffff);
end;

procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
action := cafree;
end;

end.