Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: Win32::GUI problem

by Albannach (Prior)
on Sep 24, 2015 at 03:33 UTC ( #1142863=note: print w/replies, xml ) Need Help??

in reply to Win32::GUI problem

You can catch mouse events from your window and then do whatever you want in the assigned subs:
use strict; use warnings; use Win32::GUI; my $draw = 0; my $mw = Win32::GUI::Window->new( -title => "Click anywhere to draw", -pos => [100,100], -size => [500,500], -onMouseDown => \&down, -onMouseUp => \&up, -onMouseMove => \&move, ); my $DC = $mw->GetDC; $mw->Show(); Win32::GUI::Dialog(); exit(0); sub down { my ($object, $x, $y) = @_; $draw = 1; $DC->TextOut(10,10,"start $x,$y"); return 1; } sub up { my ($object, $x, $y) = @_; $draw = 0; $DC->TextOut(400,10,"end $x,$y"); return 1; } sub move { my ($object, $x, $y) = @_; return unless $draw; $DC->SetPixel($x,$y,[192,192,192]); $DC->TextOut(200,10,"at $x,$y"); return 1; }

I'd like to be able to assign to an luser

Replies are listed 'Best First'.
Re^2: Win32::GUI problem
by Anonymous Monk on Sep 24, 2015 at 09:45 UTC

    Tx a lot.

Re^2: Win32::GUI problem
by Anonymous Monk on Sep 25, 2015 at 09:44 UTC

    Your code is not working.

      Can you elaborate on what you're seeing? I always test code before posting so I can tell you this works on my machine at least. To be clear, you should get a square white window, and when you left-mouse-down in the window it will report the coordinates in the top left. If you hold left-mouse-down and move the mouse it will draw pixels and report the current coordinates in the top centre, and when you release the left-mouse it will report the final coordinates in the top right.

      I'd like to be able to assign to an luser

        When i am seeing your program, it raises a prolem like: The Perl Interpreter needs to be closed down. maybe this situation has something to do with the fact I switched from Strawberry to ActiveState perl,because i had problems like that before when using the Win32 problem. Furthermore i dont have an internetconnection so i guess there is nothing to do about it.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1142863]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2021-01-16 11:55 GMT
Find Nodes?
    Voting Booth?