Is there a simple way to add a method to an object?  Basically, what I
want to do is this:

$window->CenterOnScreen();

where $window is my Win32::GUI::Window object, and CenterOnScreen() is a
sub I created in another package( or in main for that matter)

so that the method call above would invoke 

sub CenterOnScreen{

my $window = shift;  # gets the object which called the method??

my $desk = $window->GetDesktopWindow();
my(undef, undef, $d_width, $d_height)= Win32::GUI::GetWindowRect($desk);
my ($win_width)= $window->ScaleWidth();
my ($win_height) = $window->ScaleHeight();
my $delta_w = ($d_width  /2) - ($win_width/ 2);
my $delta_h = ($d_height / 2) - ($win_height / 2);
$window->Move($delta_w, $delta_h);
}

So, how do I call this method created in my own package with an object
created in another package. I know I could easily do 
CenterOnScreen($window);

but I want to stay in OO mode as much as possible AND I will want to
create several utility methods such as this for my GUI projects.

Any help is appreciated in advance.

Joe Frazier, Jr
Technical Support Engineer
PeopleClick
919-645-2916
[EMAIL PROTECTED]
 

PS:  Thanks to all for making such a great visual tool for us Win32
programmers.  I use this often to create simple GUI's which our "Tools"
team does seem to find time to produce.  Also, when is the next version
coming out?



Reply via email to