Re: [perl-win32-gui-users] weird textfield issue

2001-05-10 Thread Marjolein Katsma
Chris,

Forgive me if I sound pedantic - but here's some advice from an old hand 
(slightly rheumatic by now - seriously!) at programming. If you want to find 
out the hard way (may do!) delete this *now*; don't read any further.
On the other hand...:

Do *not* hide that DOS (command-line) window until you've fully debugged, 
alpha-tested and beta-tested your program. Until it's ready for release, you 
*need* that command-line window.

Unless you want (or can afford to) to shell out for a debugger - but you don't 
*need* (to shell out for) a debugger until you've exhausted all other methods. 
(When I was starting to writing COBOL there *were* no 'debuggers'.  Debugging 
your code was inserting as many useful DISPLAY statements you could think of 
and then interpreting the text on the print-out you got back.) I have a 
debugger for Perl (Part of ActiveState's PDK, which costs $$$) but I rarely use 
it. I use the command-line window to display my "display" statements (plain old 
print in Perl) until I'm really stuck.

If you want to know what goes on in your script, keep that window, and put 
liberal [print] statements into your code to trace every step: you're robbing 
yourself of a valuable resource until your code is really working (and 
confirmed as really working by people using your code). They'll give you a 
trace of what's happening, and a means of finding problems - well before you'll 
even *need* a debugger (or this list, for that matter). Leave your print 
statements (and code variations!) but 'comment them out' while you're trying to 
figure out something. Once it works, put in a new comment that explains (to 
you, 6 months later!) why it works. When you can still understand that comment 
after a week, your're ready to deleted the other commented-out trial-and-error 
code. If not, go back and explain it to yourself again (if you can still 
remember why this worked in the first place and something else didn't!); in a 
comment.

And don't under-estimate the life-time of your code: trivial code intended for 
a week or so has a nasty habit of staying alive for 2 years or more...

Debuggers are a wonderful invention - and I use them. But you don't need them 
(need to *pay* for them!) until you've exhausted all possibilities of 
displaying traces and variable values of your program while it's executing. 
With Perl on Win - that's just what you need your command-line window for: 
without it (or a debugger): how do you know what's happening?

My Perl scripts (until ready for release) look really 'dirty' until they're 
working: they're full of comments of what I'm trying (commented code), and why, 
and why it doesn't work so what I'm trying next.
So try a few things, put in some print statements, and if your code doesn't 
work as you intended and you figured out why, put that into a comment as well. 
Ultimately you'll end up with working code, and comments explaining (to you!) 
why this works and something else you tried doesn't.

(OK, I didn't even try your code - I just noticed you disabled the very means 
of finding out why it didn't work in the first place. IGNORE if you're not 
interested!)

At 13:23 2001-05-09 -0500, Chris Etzel wrote:
>Hello,
>
>I am playing around with Win32::GUI trying to refresh my memory on Perl and
>Win32::GUI, and:
>
>I have written a test program that basically brings up a toolbar with a
>button to open a launcher window that I can type a command in and launch
>directly. Well, all works fine exept I can't see the text field. I even
>tried to copy and paste from my working example directly to the new code,
>but still no text field. Before I go insane, can someone look at this code
>and tell me if I messed up somewhere? Thanks!
>
>Chris
>
>--code below--
>
>use Win32::GUI;
>($DOS) = Win32::GUI::GetPerlWindow();
> Win32::GUI::Hide($DOS);
>
>my $Toolbar=Win32::GUI::Window->new(
> -name=>'Toolbar',
> -size=>[600,75],
> -title=>"PEaRL ToolBar",
> );
>my $launcher=$Toolbar->AddButton(
> -name=>'launcher',
> -pos=>[10,10],
> -text=>"Launcher",
> );
>$Toolbar->launcher->Show();
>
> sub launcher_Click{
>   my $Launcher=Win32::GUI::Window->new(
>  -name=>'CommandLauncher',
>  -size=>[300,75],
>  -title=>"Launcher",
>  );
>   $Launcher->Show();
>
>   my $runline=$Launcher->AddTextField(
>   -name=>'CommandBox',   #Here is
>where It should show the text field-but doesn't
>   -background=>[255,255,255],
>   -pos=>[10,10],
>  -size=>[150,22],
>   -prompt=>'Enter Command:',
>  );
>
>   my $runButton-$Launcher->AddButton(
>-name=>'runbutton',
>-pos=>[160,10],
>-text=>'Run',
>-size=>[30,22],
>);
>   $Launcher->runbutton->Show();
>sub runButton_Click{
> exec($textfield->Text);
>}
>
>   }
>
>
>
>
>$Toolbar->Show();
>Win32::GUI::Dialog();
>
>
>
>
>

Re: [perl-win32-gui-users] weird textfield issue

2001-05-10 Thread Chris Etzel
I found it. I had AddTextField instead of AddTextfield. Correct caps are not
my strong point apparently, but I imagine learning them would prevent
further headaches!
Thanks for the debugging tips. They came in handy when trying to find the
problem.



- Original Message -
From: "Marjolein Katsma" <[EMAIL PROTECTED]>
To: ;

Sent: Thursday, May 10, 2001 4:16 AM
Subject: Re: [perl-win32-gui-users] weird textfield issue


> Chris,
>
> Forgive me if I sound pedantic - but here's some advice from an old hand
(slightly rheumatic by now - seriously!) at programming. If you want to find
out the hard way (may do!) delete this *now*; don't read any further.
> On the other hand...:
>
> Do *not* hide that DOS (command-line) window until you've fully debugged,
alpha-tested and beta-tested your program. Until it's ready for release, you
*need* that command-line window.
>
> Unless you want (or can afford to) to shell out for a debugger - but you
don't *need* (to shell out for) a debugger until you've exhausted all other
methods.
> (When I was starting to writing COBOL there *were* no 'debuggers'.
Debugging your code was inserting as many useful DISPLAY statements you
could think of and then interpreting the text on the print-out you got
back.) I have a debugger for Perl (Part of ActiveState's PDK, which costs
$$$) but I rarely use it. I use the command-line window to display my
"display" statements (plain old print in Perl) until I'm really stuck.
>
> If you want to know what goes on in your script, keep that window, and put
liberal [print] statements into your code to trace every step: you're
robbing yourself of a valuable resource until your code is really working
(and confirmed as really working by people using your code). They'll give
you a trace of what's happening, and a means of finding problems - well
before you'll even *need* a debugger (or this list, for that matter). Leave
your print statements (and code variations!) but 'comment them out' while
you're trying to figure out something. Once it works, put in a new comment
that explains (to you, 6 months later!) why it works. When you can still
understand that comment after a week, your're ready to deleted the other
commented-out trial-and-error code. If not, go back and explain it to
yourself again (if you can still remember why this worked in the first place
and something else didn't!); in a comment.
>
> And don't under-estimate the life-time of your code: trivial code intended
for a week or so has a nasty habit of staying alive for 2 years or more...
>
> Debuggers are a wonderful invention - and I use them. But you don't need
them (need to *pay* for them!) until you've exhausted all possibilities of
displaying traces and variable values of your program while it's executing.
With Perl on Win - that's just what you need your command-line window for:
without it (or a debugger): how do you know what's happening?
>
> My Perl scripts (until ready for release) look really 'dirty' until
they're working: they're full of comments of what I'm trying (commented
code), and why, and why it doesn't work so what I'm trying next.
> So try a few things, put in some print statements, and if your code
doesn't work as you intended and you figured out why, put that into a
comment as well. Ultimately you'll end up with working code, and comments
explaining (to you!) why this works and something else you tried doesn't.
>
> (OK, I didn't even try your code - I just noticed you disabled the very
means of finding out why it didn't work in the first place. IGNORE if you're
not interested!)
>
> At 13:23 2001-05-09 -0500, Chris Etzel wrote:
> >Hello,
> >
> >I am playing around with Win32::GUI trying to refresh my memory on Perl
and
> >Win32::GUI, and:
> >
> >I have written a test program that basically brings up a toolbar with a
> >button to open a launcher window that I can type a command in and launch
> >directly. Well, all works fine exept I can't see the text field. I even
> >tried to copy and paste from my working example directly to the new code,
> >but still no text field. Before I go insane, can someone look at this
code
> >and tell me if I messed up somewhere? Thanks!
> >
> >Chris
> >
> >--code below--
> >
> >use Win32::GUI;
> >($DOS) = Win32::GUI::GetPerlWindow();
> > Win32::GUI::Hide($DOS);
> >
> >my $Toolbar=Win32::GUI::Window->new(
> > -name=>'Toolbar',
> > -size=>[600,75],
> > -title=>"PEaRL ToolBar",
> > );
> >my $launcher=$Toolbar->AddButton(
> > -name=>'launcher',
> > -pos=>[10,10],
> > -text=>"Launcher",
> > );
> >$Toolbar->launcher->Show();
> >
> > sub launcher_Click{
> >   my $Launcher=Win32::GUI::Window->new(
> >  -name=>'CommandLauncher',
> >  -size=>[300,75],
> >  -title=>"Launcher",
> >  );
> >   $Launcher->Show();
> >
> >   my $runline=$Launcher->AddTextField(
> >   -name=>'CommandBox',   #Here
is
> >where It should show the text field-b

Re: [perl-win32-gui-users] Drag-n-drop (was: Show In Taskbar)

2001-05-10 Thread Johan Lindstrom

Wohoo! I got it to work! :)

It took some XS hacking though. Nothing fancy, mostly copy-paste and common 
sense.


I added the WM_DROPFILES message to the WindowMsgLoop so that it throws an 
event DropFiles() with the drop handle in question.


And once in Perl it was piece a cake to call the shell32.dll functions 
DragQueryFile and DragFinish to actually get the files. Cool. This is fun!



Some code:

GUI.xs, line 1839:
--
case WM_DROPFILES:
if(GetObjectName(NOTXSCALL hwnd, Name)) {
/*
 * (@)EVENT:DropFiles(DROP_HANDLE)
 * Sent when the window receives dropped files.
 * (@)APPLIES_TO:Window, DialogBox
 */
strcat(Name, "_DropFiles");
PerlResult = DoEvent_Long(NOTXSCALL Name, UINT(wParam));
}   
break;
--

http://www.bahnhof.se/~johanl/perl/Win32GUI/
- AdHoc.pm
Perl subs for dealing with the shell32.dll calls handling the drop 
operation (among other things).


- dragdrop.pl
Working demo program (if you rebuild the XS code). The actual drag-drop 
code is this simple in a Perl application:


--
Win32::GUI::AdHoc::windowDragAcceptFiles($winMain, 1);

sub winMain_DropFiles {
my ($handleDrop) = @_;

	print join("\n", Win32::GUI::AdHoc::windowGetDroppedFiles($handleDrop)) . 
"\n\n";


return(1);
}
--

I guess a more complete solution would include drag-drop to e.g. a RichEdit 
or Textfield control etc. but I'm not sure what the implications are.


I'm not sure how to continue with this. For my personal use, I'm probably 
gonna create a Win32::GUI::DragDrop module or something (using my XS mod), 
but maybe this belongs in the next release of Win32::GUI after a code 
review (after all, I relly don't _know_ these things). Aldo?



/J
--
Johan Lindström, Sourcerer, Boss Casinos Ltd, Antigua
[EMAIL PROTECTED]




Re: [perl-win32-gui-users] weird textfield issue

2001-05-10 Thread Marjolein Katsma
Chris,

At 20:38 2001-05-09 -0500, Chris Etzel wrote:
>I found it.

Great!

> I had AddTextField instead of AddTextfield. Correct caps are not
>my strong point apparently, but I imagine learning them would prevent
>further headaches!

You know, I do that *all* the time ;-)
It's just part of learning how to use this great package.

>Thanks for the debugging tips. They came in handy when trying to find the
>problem.

That's just the general stuff that will basically apply to any programming 
language. There are some Perl-specific tricks. Have you tried 'use strict;' 
yet? 



Cheers,

Marjolein Katsma
HomeSite Help - http://hshelp.com/ - Extensions, Tips and Tools




[perl-win32-gui-users] DragDrop.pm and new Oasis release

2001-05-10 Thread Johan Lindstrom

There is now a Win32::GUI::DragDrop module available at

http://www.bahnhof.se/~johanl/perl/Win32GUI/

There is a complete example/demo program in the POD if you would like to 
take the trouble to rebuild your Win32::GUI module.



There is also a new version of Perl Oasis which, of course, contains 
drag-n-drop support (and if you use the binary you won't need to rebuild 
Win32::GUI).


Another nice feature is a useful toolbar floating on top of UltraEdit when 
you edit your code. Read all about it here:


http://www.bahnhof.se/~johanl/perl/Oasis/


/J
--
Johan Lindström, Sourcerer, Boss Casinos Ltd, Antigua
[EMAIL PROTECTED]




[perl-win32-gui-users] Win32::GUI::Icon

2001-05-10 Thread Jeremy Aiyadurai
hello all, 


thankyou for your help so far

is this Win32::GUI::Icon functional, or is there something wrong with my file.


new Win32::GUI::Icon("favicon.ico");

thanks

Jeremy .A








favicon.ico
Description: Binary data



[perl-win32-gui-users] Re: DragDrop.pm and new Oasis release

2001-05-10 Thread Hirosi Taguti
> There is now a Win32::GUI::DragDrop module available at
> 
> http://www.bahnhof.se/~johanl/perl/Win32GUI/
> 
> There is a complete example/demo program in the POD if you would like to 
> take the trouble to rebuild your Win32::GUI module.

I've just tried.

The demo program in the POD printed,
"Initial state   : accepts drops: 0",
and memory vioration occured, says,
pgm 0x01d61c6a accessed 0x, cann't become as read...
(this is really in Japanese)

I'm using ActivePerl Build 626 in Win2K pro.
I inserted "case WM_DROPFILES" after  GUI.xs, line 1839: as instructed,
nmake,
nmake install.
re-boot machine,
execute the demo program.

Any help?

--
Hirosi Taguti
[EMAIL PROTECTED]



Re: [perl-win32-gui-users] Win32::GUI::Icon

2001-05-10 Thread Marjolein Katsma
Jeremy,

What you have there is correct - but how are you using it?

When I use an icon for a window (system) icon, it works fine, but I have been 
unable to make one work on a button (but a Bitmap works in that case).

For a system icon the normal size restrictions apply: 16x16 for as it appears 
in the title bar and a start bar button; add a 32x32 image into the same file 
if you make a free-standing exe so Windows can display a large icon for it as 
well.

# -- set window icon --
my $I = new Win32::GUI::Icon("hsh.ico");#hsh.ico contains both 16x16 
and 32x32 images
$W->SetIcon($I);#W is the previously defined 
Window


At 21:25 2001-05-10 -0700, Jeremy Aiyadurai wrote:
>hello all, 
>
>
>thankyou for your help so far
>
>is this Win32::GUI::Icon functional, or is there something wrong with my file.
>
>
>new Win32::GUI::Icon("favicon.ico");
>
>thanks
>
>Jeremy .A


Cheers,

Marjolein Katsma
HomeSite Help - http://hshelp.com/ - Extensions, Tips and Tools