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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.