Looks like a Copy/Paste gone bad.
you have
my $c01_btn_back = $main->AddButton(
-name => "c01_btn_back", <-------- this name does not match.............
-text => "<< &Back",
-left => 326,
-top => 298,
-width => 60,
-height => 21,
);
$card->add("c02_btn_back", "card02"); <------- the first parameter here
that's all. It's cool for me to see that people are using this!!
Ian Taite wrote:
> Heres the error I'm getting on my first program that uses CardLayout:
>
> C:\Perl\eg\guiproject>perl -w dialogue2.pl
> Can't call method "Hide" on an undefined value at
> C:/Perl/site/lib/Win32/GUI/CardLayout.pm line 19.
>
> I hope I've not done something too silly. Any help from Win32-GUI experts
> greatfully received as always. Regards, Ian.
>
> Here's my code:
>
> # Code Starts Here ---------------------------------------------------
> use strict 'vars';
>
> use Win32::GUI;
> use Win32::GUI::CardLayout;
>
> # ----------------------- Create Main Window -------------------------
>
> my $main = Win32::GUI::DialogBox->new(
> -name => 'main',
> -text => 'Welcome',
> -width => 480,
> -height => 360,
> );
>
> my $card = new Win32::GUI::CardLayout($main, "card01");
>
> # -------------------- Create Controls for Card 1 --------------------
>
> my $c01_bmp_logo = new Win32::GUI::Bitmap("SideBar.bmp", 0);
>
> my $c01_lbl_logo = $main->AddLabel(
> -name => "c01_lbl_logo",
> -bitmap => 1,
> -left => 16,
> -top => 16,
> -height => 250,
> -sunken => 1,
> );
>
> $c01_lbl_logo->SetImage($c01_bmp_logo);
>
> $card->add("c01_lbl_logo", "card01");
>
> my $c01_lbl_welcome = $main->AddLabel(
> -name => "c01_lbl_welcome",
> -text => "Welcome to the Windows NT Add User
> Wizard.\n\n" .
> "Click the Next button to start the
> creation process, or\n\n" .
> "Click the Cancel button to close
> this window.",
> -wrap => 1,
> -left => 120,
> -top => 16,
> -width => 338,
> -height => 250,
> -sunken => 1,
> );
>
> $card->add("c01_lbl_welcome", "card01");
>
> my $c01_btn_next = $main->AddButton(
> -name => "c01_btn_next",
> -text => "&Next >>",
> -left => 398,
> -top => 298,
> -width => 60,
> -height => 21,
> );
>
> $card->add("c01_btn_next", "card01");
>
> my $c01_btn_cancel = $main->AddButton(
> -name => "c01_btn_cancel",
> -text => "&Cancel",
> -left => 326,
> -top => 298,
> -width => 60,
> -height => 21,
> );
>
> $card->add("c01_btn_cancel", "card01");
>
> my $c01_lbl_rule = $main->AddLabel(
> -name => "c01_lbl_rule",
> -bitmap => 0,
> -background => 0,
> -left => 16,
> -top => 282,
> -width => 442,
> -height => 4,
> -sunken => 1,
> );
>
> $card->add("c01_lbl_rule", "card01");
>
> # -------------------- Create Controls for Card 2 --------------------
>
> my $c02_bmp_logo = new Win32::GUI::Bitmap("SideBar.bmp", 0);
>
> my $c02_lbl_logo = $main->AddLabel(
> -name => "c02_lbl_logo",
> -bitmap => 1,
> -left => 16,
> -top => 16,
> -height => 250,
> -sunken => 0,
> );
>
> $c02_lbl_logo->SetImage($c02_bmp_logo);
>
> $card->add("c02_lbl_logo", "card02");
>
> my $c02_lbl_prompt = $main->AddLabel(
> -name => "c02_lbl_prompt",
> -text => "Welcome to the Windows NT Add User
> Wizard.\n\n",
> "Click the Next button to start the
> creation process, or\n\n" .
> "Click the Cancel button to close
> this window.",
> -wrap => 1,
> -left => 120,
> -top => 16,
> -width => 338,
> -height => 250,
> -sunken => 0,
> );
>
> $card->add("c02_lbl_prompt", "card02");
>
> my $c02_btn_next = $main->AddButton(
> -name => "c02_btn_next",
> -text => "&Next >>",
> -left => 398,
> -top => 298,
> -width => 60,
> -height => 21,
> );
>
> $card->add("c02_btn_next", "card02");
>
> my $c01_btn_back = $main->AddButton(
> -name => "c01_btn_back",
> -text => "<< &Back",
> -left => 326,
> -top => 298,
> -width => 60,
> -height => 21,
> );
>
> $card->add("c02_btn_back", "card02");
>
> my $c02_btn_cancel = $main->AddButton(
> -name => "c02_btn_cancel",
> -text => "&Cancel",
> -left => 250,
> -top => 298,
> -width => 60,
> -height => 21,
> );
>
> $card->add("c02_btn_cancel", "card02");
>
> my $c02_lbl_rule = $main->AddLabel(
> -name => "c02_lbl_rule",
> -bitmap => 0,
> -background => 0,
> -left => 16,
> -top => 282,
> -width => 442,
> -height => 4,
> -sunken => 1,
> );
>
> $card->add("c02_lbl_rule", "card02");
>
> # ----------- Resize / Reposition Controls and Main Window ----------
>
> # Centre the dialogue box on screen.
>
> my $desk = Win32::GUI::GetDesktopWindow();
> my $desktop_width = Win32::GUI::Width($desk);
> my $desktop_height = Win32::GUI::Height($desk);
>
> my $main_new_left = ($desktop_width - $main->Width())/2;
> my $main_new_top = ($desktop_height - $main->Height())/2;
> $main->Change(-left => $main_new_left, -top => $main_new_top);
>
> # -------------------- Display The Main Window ----------------------
>
> $main->Show();
>
> # ------- Enter The Message Loop And Wait For User Interaction -------
>
> Win32::GUI::Dialog();
>
> #print "This is the end of the program.\n";
>
> # ====================================================================
> # E V E N T H O O K S G O H E R E
> # ====================================================================
>
> sub main_Terminate {
>
> # This hook gets called when the user closes the main window.
> # a return value of minus one simply causes the message loop
> # to end.
>
> -1;
> };
>
> sub c01_btn_cancel_Click {
>
> &main_Terminate();
>
> };
>
> sub c01_btn_next_Click {
>
> $card->showCard("card02");
>
> };
>
> sub c02_btn_cancel_Click {
>
> &main_Terminate();
>
> };
>
> # This is the end of my first CardLayout program.