From: <iaa...@ao...> - 2008-11-17 22:02:11
|
Hello, I'm developing an app which will display a bitmap.? I want to be able to detect mouse clicks on the bitmap and get the mouse cursor location when clicks are detected. Displaying the bitmap is easy - there are demos that show that.? I have been trying to modify the demos to detect clicks and get the mouse cursor location, but nothing has worked yet.? Have been going thru doc/demos/etc, and will keep doing so, but if you happen to have experience with this topic, please send me any pointers you can. I have tried using GetCursorPos, but thus far seem to be getting undefined return values.? As for the mouse click, tried setting up -onClick option but this seems to be ignored. Thanks for your time! Regards, LP |
From: zak3 <zak...@gm...> - 2008-11-21 10:20:37
|
i have experemented using as a guide the message: http://www.mail-archive.com/per...@li.../msg03025.html here is a main form and a Label, when you click on the Label, the textfield control will show the coordinates of mouse cursor , it seems to me that those coordinated are relative to the screen, you may adapt the code to display the coordinates relative to the form or relative to the label, or a graphic control. use strict; use warnings; use Win32::GUI(); my $W = new Win32::GUI::Window( -name => "W", -title => "mouse click tracking", -left => 54, -top => 77, -width => 546, -height => 318, ); my $textfield = $W->AddTextfield( -text => "", -name => "Textfield_1", -left => 401, -top => 9, -width => 129, -height => 249, -multiline => 1, -vscroll => 1, ); $W->AddLabel( -text => "zz", -name => "Label_2", -left => 0, -top => 0, -width => 270, -height => 232, -foreground => 0, -background => 12615935, -notify => 1, -onMouseDown => sub { my($mx, $my) = Win32::GUI::GetCursorPos();$textfield -> Append( "$mx - $my \n");}, ); $W->Show(); Win32::GUI::Dialog(); exit(0); sub Window_Terminate { return -1; } iaagaiow wrote: > > Hello, > > I'm developing an app which will display a bitmap.? I want to be able to > detect mouse clicks on the bitmap and get the mouse cursor location when > clicks are detected. > > Displaying the bitmap is easy - there are demos that show that.? I have > been trying to modify the demos to detect clicks and get the mouse cursor > location, but nothing has worked yet.? Have been going thru doc/demos/etc, > and will keep doing so, but if you happen to have experience with this > topic, please send me any pointers you can. > > I have tried using GetCursorPos, but thus far seem to be getting undefined > return values.? As for the mouse click, tried setting up -onClick option > but this seems to be ignored. > > Thanks for your time! > > Regards, > > LP > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the > world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ > -- View this message in context: http://www.nabble.com/bitmap---getting-mouse-clicks-and-mouse-location-tp20549181p20618513.html Sent from the perl-win32-gui-users mailing list archive at Nabble.com. |
From: pcourterelle <pco...@te...> - 2008-11-21 21:08:53
|
To get the absolute X and Y coordinates, would you have to subtract the position of the child (label) from the position of the parent (main window)? pc -----Original Message----- From: zak3 [mailto:zak...@gm...] Sent: Friday, November 21, 2008 2:21 AM To: per...@li... Subject: Re: [perl-win32-gui-users] bitmap - getting mouse clicks and mouse location i have experemented using as a guide the message: http://www.mail-archive.com/per...@li.../msg03 025.html here is a main form and a Label, when you click on the Label, the textfield control will show the coordinates of mouse cursor , it seems to me that those coordinated are relative to the screen, you may adapt the code to display the coordinates relative to the form or relative to the label, or a graphic control. use strict; use warnings; use Win32::GUI(); my $W = new Win32::GUI::Window( -name => "W", -title => "mouse click tracking", -left => 54, -top => 77, -width => 546, -height => 318, ); my $textfield = $W->AddTextfield( -text => "", -name => "Textfield_1", -left => 401, -top => 9, -width => 129, -height => 249, -multiline => 1, -vscroll => 1, ); $W->AddLabel( -text => "zz", -name => "Label_2", -left => 0, -top => 0, -width => 270, -height => 232, -foreground => 0, -background => 12615935, -notify => 1, -onMouseDown => sub { my($mx, $my) = Win32::GUI::GetCursorPos();$textfield -> Append( "$mx - $my \n");}, ); $W->Show(); Win32::GUI::Dialog(); exit(0); sub Window_Terminate { return -1; } iaagaiow wrote: > > Hello, > > I'm developing an app which will display a bitmap.? I want to be able to > detect mouse clicks on the bitmap and get the mouse cursor location when > clicks are detected. > > Displaying the bitmap is easy - there are demos that show that.? I have > been trying to modify the demos to detect clicks and get the mouse cursor > location, but nothing has worked yet.? Have been going thru doc/demos/etc, > and will keep doing so, but if you happen to have experience with this > topic, please send me any pointers you can. > > I have tried using GetCursorPos, but thus far seem to be getting undefined > return values.? As for the mouse click, tried setting up -onClick option > but this seems to be ignored. > > Thanks for your time! > > Regards, > > LP > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the > world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ > -- View this message in context: http://www.nabble.com/bitmap---getting-mouse-clicks-and-mouse-location-tp205 49181p20618513.html Sent from the perl-win32-gui-users mailing list archive at Nabble.com. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Perl-Win32-GUI-Users mailing list Per...@li... https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users http://perl-win32-gui.sourceforge.net/ |
From: Jeremy W. <jez...@ho...> - 2008-11-22 12:07:37
|
Hi, Try the following: use strict; use warnings; use Win32::GUI (qw {WS_CAPTION WS_SIZEBOX WS_CHILD WS_CLIPCHILDREN WS_EX_CLIENTEDGE}); my $W = new Win32::GUI::Window( -name => "W", -title => "mouse click tracking", -left => 54, -top => 77, -width => 546, -height => 318, ); my $textfield = $W->AddTextfield( -text => "", -name => "Textfield_1", -left => 401, -top => 9, -width => 129, -height => 249, -multiline => 1, -vscroll => 1, ); my $childwindow = new Win32::GUI::Window ( -parent => $W, -name => 'bitmap window', -left => 4, -top => 4, -width => 270, -height => 232, -popstyle => WS_CAPTION | WS_SIZEBOX, -pushstyle => WS_CHILD | WS_CLIPCHILDREN, -pushexstyle => WS_EX_CLIENTEDGE, #-hscroll => 1, #-onScroll => \&Generic_Scroll, -onMouseMove => \&Generic_MouseMove, -onPaint => \&Generic_Paint, -onMouseDown => \&Generic_MouseDown, ); $childwindow->Show; sub Generic_MouseMove { my ($win,$xcor,$ycor)=@_; print "MouseMove $win,$xcor,$ycor\n"; } sub Generic_Paint { my $win=shift; print "Paint $win\n"; } sub Generic_MouseDown { my ($win,$xcor,$ycor)=@_; print "MouseDown $win,$xcor,$ycor\n"; $textfield -> Append( "$xcor - $ycor \n") } $W->Show(); Win32::GUI::Dialog(); exit(0); sub Window_Terminate { return -1; } > From: pco...@te... > To: per...@li... > Date: Fri, 21 Nov 2008 13:08:47 -0800 > Subject: Re: [perl-win32-gui-users] bitmap - getting mouse clicks and mouse location > > > To get the absolute X and Y coordinates, would you have to subtract the > position of the child (label) from the position of the parent (main window)? > > pc > > > -----Original Message----- > From: zak3 [mailto:zak...@gm...] > Sent: Friday, November 21, 2008 2:21 AM > To: per...@li... > Subject: Re: [perl-win32-gui-users] bitmap - getting mouse clicks and mouse > location > > > > i have experemented using as a guide the message: > http://www.mail-archive.com/per...@li.../msg03 > 025.html > > here is a main form and a Label, when you click on the Label, the textfield > control will show the coordinates of mouse cursor , it seems to me that > those coordinated are relative to the screen, you may adapt the code to > display the coordinates relative to the form or relative to the label, or a > graphic control. > > use strict; > use warnings; > use Win32::GUI(); > > my $W = new Win32::GUI::Window( > -name => "W", > -title => "mouse click tracking", > -left => 54, > -top => 77, > -width => 546, > -height => 318, > ); > my $textfield = $W->AddTextfield( > -text => "", > -name => "Textfield_1", > -left => 401, > -top => 9, > -width => 129, > -height => 249, > -multiline => 1, > -vscroll => 1, > ); > > $W->AddLabel( > -text => "zz", > -name => "Label_2", > -left => 0, > -top => 0, > -width => 270, > -height => 232, > -foreground => 0, > -background => 12615935, > -notify => 1, > -onMouseDown => sub { my($mx, $my) = > Win32::GUI::GetCursorPos();$textfield -> Append( "$mx - $my \n");}, > ); > > > > $W->Show(); > Win32::GUI::Dialog(); > > exit(0); > > sub Window_Terminate { > return -1; > } > > > > > iaagaiow wrote: > > > > Hello, > > > > I'm developing an app which will display a bitmap.? I want to be able to > > detect mouse clicks on the bitmap and get the mouse cursor location when > > clicks are detected. > > > > Displaying the bitmap is easy - there are demos that show that.? I have > > been trying to modify the demos to detect clicks and get the mouse cursor > > location, but nothing has worked yet.? Have been going thru doc/demos/etc, > > and will keep doing so, but if you happen to have experience with this > > topic, please send me any pointers you can. > > > > I have tried using GetCursorPos, but thus far seem to be getting undefined > > return values.? As for the mouse click, tried setting up -onClick option > > but this seems to be ignored. > > > > Thanks for your time! > > > > Regards, > > > > LP > > > > ------------------------------------------------------------------------- > > This SF.Net email is sponsored by the Moblin Your Move Developer's > > challenge > > Build the coolest Linux based applications with Moblin SDK & win great > > prizes > > Grand prize is a trip for two to an Open Source event anywhere in the > > world > > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > _______________________________________________ > > Perl-Win32-GUI-Users mailing list > > Per...@li... > > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > > http://perl-win32-gui.sourceforge.net/ > > > > -- > View this message in context: > http://www.nabble.com/bitmap---getting-mouse-clicks-and-mouse-location-tp205 > 49181p20618513.html > Sent from the perl-win32-gui-users mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ _________________________________________________________________ See the most popular videos on the web http://clk.atdmt.com/GBL/go/115454061/direct/01/ |