Not a problem!

Give your label the -notify => 1 option. Now when you click it, it'll
generate a WM_LBUTTONDOWN message.

Make a new global variable called $MBUTTON:
our $MBUTTON = 0;

Give your label an -onMouseDown event, and in the event handler, you
want to:

sub mousedown {
        $label->SetCapture(); # capture all the mouse events
        # get the mouse cursor pos in our window:
        my($ox, $oy) =
$Wmain->ScreenToClient(Win32::GUI::GetCursorPos());
        $MBUTTON = 1;
        while($MBUTTON) {
                # get the screen cursor pos
                my($mx,$my) = Win32::GUI::GetCursorPos();
                # position the window under the mouse at the correct
place:
                $Wmain->Move($mx - $ox, $my - $oy);
                # check for mouseup.
                Win32::GUI::DoEvents;
        }
        $label->ReleaseCapture;
}

sub mousemove {
}

give your label an onMouseUp event, handler:

sub mouseup {
        $MBUTTON = 0;
}

now, when the mouse goes down on the label, $MBUTTON is set to 1, the
label is set to capture all mouse events, and a while loop starts that
allows the window to be dragged around. When the mouse is released,
$MBUTTON is set to 0, and the while loop ends. Mouse is released, and
you have a coffee.

Steve


> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of
> Chris
> Sent: 19 January 2004 10:57
> To: perl-win32-gui-users@lists.sourceforge.net
> Subject: [perl-win32-gui-users] moving windows
> 
> 
> Okay, I have a window, but I'm not sure how to make it so I 
> can move it.
> 
>       $Wmain = Win32::GUI::Window->new(
>                   -name   => 'winamp',
>                   -top => ($screen_heigth - 116)/2,
>                   -left => ($screen_width - 275)/2,
>                   -maxsize => [275,116],
>                   -minsize => [275,116],
>                   -width  => 275,
>                   -height => 116,
>                   -style => WS_POPUP,
>                   -text   => "Winamp Remote",
>       );
> 
> With that style, I no longer have the ugly windows title bar. 
> However the
> entire window is created out of labels, and I'm not sure how 
> to make it so I
> can click and drag a label to move the window around, cause 
> that would allow
> me to handle movements. I already inserted my own custom 
> menubar buttons, so
> if someone could help me, please do
> 
> Thanks Chris
> 
> 
> 
> 
> -------------------------------------------------------
> The SF.Net email is sponsored by EclipseCon 2004
> Premiere Conference on Open Tools Development and Integration
> See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
> http://www.eclipsecon.org/osdn
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Perl-Win32-GUI-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> 

Reply via email to