Selva,

You can use the ButtonCount() method to retrieve the number of buttons in the 
toolbar and the GetButtonText() method to retrieve the text of the specified 
button. Here is some sample code:

#!perl
use strict;
use warnings;

use Data::Dump qw(dump);
use Win32::GUI qw();
use Win32::GUI::Constants qw(TBSTATE_ENABLED BTNS_SHOWTEXT IDB_STD_SMALL_COLOR 
CW_USEDEFAULT);

my $win = Win32::GUI::Window->new(
    -name => 'win',
    -text => 'Toolbar Sample',
    -size => [320,240],
    -left => CW_USEDEFAULT,
);

$win->AddToolbar(
    -name => 'toolbar',
    -adjustable => 1,
    -flat => 1,
    -multiline => 1,
    -nodivider => 1,
);
my @buttons = (qw(Cut Copy Paste Undo Redo Delete New Open Save Preview 
    Properties Help Find Replace Print));
$win->toolbar->LoadImages(IDB_STD_SMALL_COLOR);
$win->toolbar->AddString($_) foreach @buttons;
$win->toolbar->AddButtons(
    scalar @buttons,
    map {($_,$_+1,TBSTATE_ENABLED,BTNS_SHOWTEXT,$_)} 0..$#buttons
);

$win->Show();

Win32::GUI::Dialog();

sub win_Resize {
    $win->toolbar->Width($win->Width());
    return 1;
}

sub toolbar_ButtonClick {
    my($index,$dropdown) = @_;
    printf "Button %02d of %02d text => %s\n", $index, 
        $win->toolbar->ButtonCount(), $win->toolbar->GetButtonText($index);
    return 1;
}
__END__

Hope this helps,

Kevin.

> Date: Tue, 4 May 2010 05:38:04 -0700
> From: ganapathy_se...@yahoo.com
> To: perl-win32-gui-users@lists.sourceforge.net
> Subject: [perl-win32-gui-users] Is it possible to work on toolbar controls    
> with win32::GUI
> 
> Hi,
> I exhaustively looked at win32::GUI and please clarify on the same.
> I just want to get the toolbar item- count and also the text of the items in 
> toolbar. I saw win32::GUI was creating an window and doing adding some 
> control for the same.
> Is there any way to test the toolbar controls for the existing toolbar by 
> passing the window handler. 
> 
> I also tried with win32::GUItest..but not succeeded.(by using sendmessage ) 
> Please any clue on this?
> 
> Thanks
> Selva D
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Perl-Win32-GUI-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> http://perl-win32-gui.sourceforge.net/
                                          
_________________________________________________________________
View photos of singles in your area! Looking for a hot date?
http://clk.atdmt.com/NMN/go/150855801/direct/01/
------------------------------------------------------------------------------

_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/

Reply via email to