Steve Loughran wrote:
A crazy thought, but... is it possible to draw a bitmap into the status bar of a window? I want to have some kind of graphical "status" indicator (alongside the text in the status bar).... any ideas? Or should I just drop this idea and get on with something else instead? :)

What's crazy about that.  Did you try the StatusBar's SetIcon() method?

If you want more than one icon in any statusbar part, then the easiest thing would be to create labels, and position them in front of the statubar.

Regards,
Rob.

#!perl -w
use strict;
use warnings;

use Win32::GUI qw(IDI_DEFAULTICON IMAGE_ICON);

my $mw = Win32::GUI::Window->new(
        -title => 'Status Icons',
        -size  => [400,300],
        -onResize => \&resize,
);

$mw->AddStatusBar(
        -name => 'SB',
        -sizegrip => 0,
);


my ($hborder, $vborder, $pborder) = $mw->SB->GetBorders();

# Calculate the size of the icon to fit in the
# Status bar
my $size = $mw->SB->Height() - ($vborder * 2);
print "$size $hborder $vborder $pborder\n";

# Load the icon - we use the Bitmap class, as it allows us
# to re-size the image on creation, but as it to give us
# an icon.  Happily we can pass the created object to most
# API call that require an ICON object
my $icon = Win32::GUI::Bitmap->new(IDI_DEFAULTICON, IMAGE_ICON, $size, $size);

$mw->SB->SetIcon(0, $icon);
$mw->SB->SetText(0, "Some Helpful Comment");

$mw->Show();
Win32::GUI::Dialog();
$mw->Hide();
exit(0);

sub resize {
        my $self = shift;

    # With default styles the statusbar always repositions
    # itself correctly at the bottom of the window, whenever
    # it's size is changed, so rather than calculate the
    # correct position/size we just change it's size and let
    # it do the calculation
        $self->SB->Resize(0,0);
        return 0;
}



Reply via email to