Re: [perl-win32-gui-users] tutorials use strict? use warnings? globals? sender and eventargs? $self?

2008-03-03 Thread Robert May
On 21/02/2008, David Christensen [EMAIL PROTECTED] wrote:
 perl-win32-gui-users:

  I'm a Win32::GUI newbie who went through the tutorials the other night:

 http://perl-win32-gui.sourceforge.net/cgi-bin/docs.cgi?doc=tutorial

  and was shocked to see:

  1.  No use strict nor use warnings.

If you look at the tutorial demo code distributed with Win32::GUI (run
win32-gui-demos from a cmd prompt) you'll see that it is all strict
and warnings safe.  There is a line to be drawn somewhere with respect
to clarity of the documentation and 'correctness'.  We'll never satify
everyone with the style used, and so I have tried to err on the side
of keeping the task at hand clear.  This is not supposed to be a
tutorial in good perl coding style, but a tutorial showing the
Win32::GUI concepts.  Patches are always welcome if you think you can
make things clearer.

  2.  The scripts used global variables to pass around references to the
  windows, controls, etc..

Again, this is one possible style.  Possibly not a good one, but it
makes it very clear what is being done.   I didn't write the
tutorials, but have inherited their maintainance based on the lack of
anyone else willing to do it.  Again, patches welcome.

  3.  There were no sender or eventargs arguments.

Before this email I wasn't even aware what these things were.
Remember this is Perl, not some MS language, so you shouldn't expect
the idioms to be the same.  There is more than enough support within
Win32::GUI to provide an interface like this if you'd like to invest
the time in creating all the necessary objects, but there will be a
speed and memory hit from doing so (although it's probably not very
significant).  I think, more importantly, the procedural interface
with the parameters decoded is more familiar to perl programmers.

  (Not even a $self arg?)  RTFM, I don't see them either.

You probably want to read about the differences between the OEM and
NEM event models (although there's not much in the docs, the samples
provide quite a lot of material, as does searching the list archives).

  Am I missing something?  I was looking for an OO GUI toolkit in Perl.  I
  intend to build an application that will feature pop-up forms for
  editing objects persisted in a database.  My idea is to create a class
  and a table for each object type.  The class includes a method to create
  and display a window for editing that type of object.  When the user
  needs to create/ edit an object, I create an object, stuff it/ get it
  stuffed with data, and/or create/ display the editor window.  The user
  may have many such windows open at the same time, including multiple
  windows from the same class.  When the user interacts with the windows
  and controls, the event handlers need to be able to find the right
  object.  Microsoft's sender argument solves this need nicely.
  Microsoft's eventargs argument solves other needs nicely.  Does
  Win32::GUI have equivalents?

Yes, it does.  If the other replies have not helped you find the right
direction, then please post back and we'll see what we can do to help
you - there's nothing very hard if you're familiar with perl (and, in
some cases, the Win32 API).

Regards,
Rob.


  TIA,

  David


  -
  This SF.net email is sponsored by: Microsoft
  Defy all challenges. Microsoft(R) Visual Studio 2008.
  http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
  ___
  Perl-Win32-GUI-Users mailing list
  Perl-Win32-GUI-Users@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
  http://perl-win32-gui.sourceforge.net/



-- 
Please update your address book with my new email address:
[EMAIL PROTECTED]

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/


Re: [perl-win32-gui-users] tutorials use strict? use warnings? globals? sender and eventargs? $self?

2008-02-22 Thread jez_white


 To do this have a look at the UserData method. It allows you to
 associate data to a window. When you use NEM events the first parm is
 the object that the event fired on. Say for example you have a button
 on a form, and you have many instances of that form your even handler
 would look like:
 My $self=shift; #the button object
 My $parent = $self-parent; #the parent window
 My $object = $parent-UserData; #the instance data for the window

I guessed at a solution like that, but didn't see $self in the
documentation for Button_Click():

http://perl-win32-gui.sourceforge.net/cgi-bin/docs.cgi?doc=button

Where is this documented?


It should be documented in the NEM section. Win32::GUI supports two event 
modles OEM (old event model) and NEM (new event model). OEM is like visual 
basic, with the control name and the event name. So if a button was called 
hello and the button was clicked, the sub hello_Click would be called. OEM is 
only sutible for simple scripts

With NEM you pass the reference of the sub that you want to run in response to 
an event (this makes NEM faster). To some exent a NEM event is like a method 
being called on that control and as such, the first parm being passed is the 
control.

Does that help? Again no win32::GUI on this box.

Cheers,

jez
---
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/
_



-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/


Re: [perl-win32-gui-users] tutorials use strict? use warnings? globals? sender and eventargs? $self?

2008-02-22 Thread David Christensen
jez_white wrote:
 Win32::GUI supports two event modles OEM (old event model) and NEM
 (new event model). OEM is like visual basic, with the control name
 and the event name.  So if a button was called hello and the button
 was clicked, the sub hello_Click would be called. OEM is only sutible
 for simple scripts

But, apparently, does not provide VB-like sender and eventargs arguments
to the event handler (?).


 With NEM you pass the reference of the sub that you want to run in
 response to an event (this makes NEM faster).
 To some exent a NEM event is like a method being called on that
 control and as such, the first parm being passed is the control.
 It should be documented in the NEM section.
 Does that help? Again no win32::GUI on this box.

Okay, thanks for the pointer.  I was not aware of OEM and NEM:

http://perl-win32-gui.sourceforge.net/cgi-bin/docs.cgi?doc=reference-opt
ions


Thank you,

David


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/


Re: [perl-win32-gui-users] tutorials use strict? use warnings? globals? sender and eventargs? $self?

2008-02-21 Thread jez_white
Hi,

Aquick reply. The tutorials are bad as they are really old. Have a look at 
the examples supplied as they are better formed.

Yes you can wrap event handlers within an object so that each window knows its 
own state. This allows you to create and destroy  many windows of the same 
object type dyamically. 

To do this have a look at the UserData method. It allows you to associate data 
to a window. When you use NEM events the first parm is the object that the 
event fired on. Say for example you have a button on a form, and you have many 
instances of that form your even handler would look like:

My $self=shift; #the button object
My $parent = $self-parent; #the parent window
My $object = $parent-UserData; #the instance data for the window

If you search the mailing list you should come across examples. 

I don't have perl installed on this box - but this reply should have enough 
content to get you started.

Cheers,

jez

--Original Message-
From: David Christensen [EMAIL PROTECTED]
To: perl-win32-gui-users@lists.sourceforge.net 
perl-win32-gui-users@lists.sourceforge.net
Sent: 21/02/08 05:30
Subject: [perl-win32-gui-users] tutorials use strict? use warnings? globals? 
sender and eventargs? $self?

perl-win32-gui-users:

I'm a Win32::GUI newbie who went through the tutorials the other night:

http://perl-win32-gui.sourceforge.net/cgi-bin/docs.cgi?doc=tutorial

and was shocked to see:

1.  No use strict nor use warnings.

2.  The scripts used global variables to pass around references to the
windows, controls, etc..

3.  There were no sender or eventargs arguments.  (Not even a $self
arg?)  RTFM, I don't see them either.


Am I missing something?  I was looking for an OO GUI toolkit in Perl.  I
intend to build an application that will feature pop-up forms for
editing objects persisted in a database.  My idea is to create a class
and a table for each object type.  The class includes a method to create
and display a window for editing that type of object.  When the user
needs to create/ edit an object, I create an object, stuff it/ get it
stuffed with data, and/or create/ display the editor window.  The user
may have many such windows open at the same time, including multiple
windows from the same class.  When the user interacts with the windows
and controls, the event handlers need to be able to find the right
object.  Microsoft's sender argument solves this need nicely.
Microsoft's eventargs argument solves other needs nicely.  Does
Win32::GUI have equivalents?


TIA,

David


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/




-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/


Re: [perl-win32-gui-users] tutorials use strict? use warnings? globals? sender and eventargs? $self?

2008-02-21 Thread David Christensen
Glenn Linderman wrote:
 #3. I've read bunches of Windows API documentation, and have never
 found anything called sender, eventargs, or self.  You must be
 reading stuff at some higher level of abstraction.

http://search.cpan.org/~robertmay/Win32-GUI-1.06/docs/GUI/UserGuide/Read
me.pod

Win32::GUI is a Win32-platform native graphical user interface toolkit
for perl. Basically, it's an XS implementation of most of the functions
found in user32.dll and gdi32.dll, with an object oriented perl
interface and an event-based dialog model that mimic the functionality
of visual basic.

I was expecting something like Visual Basic (although I prefer C#):

http://msdn2.microsoft.com/en-us/library/system.windows.forms.control.cl
ick(VS.71).aspx


jez_whit wrote:
 To do this have a look at the UserData method. It allows you to
 associate data to a window. When you use NEM events the first parm is
 the object that the event fired on. Say for example you have a button
 on a form, and you have many instances of that form your even handler
 would look like:
 My $self=shift; #the button object
 My $parent = $self-parent; #the parent window
 My $object = $parent-UserData; #the instance data for the window

I guessed at a solution like that, but didn't see $self in the
documentation for Button_Click():

http://perl-win32-gui.sourceforge.net/cgi-bin/docs.cgi?doc=button

Where is this documented?


David


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/