|
From: Kieren D. <Kie...@ha...> - 2008-12-15 14:26:53
|
Hi Glenn and Rob
Thank you - you've both very helpful, and I now have a combobox which
responds
appropriately to user input.
I do still have one question, though. Is there a list somewhere of the
events a type of control responds to by default? The MSDN library lists
events which can be trapped with hook, but I don't know what the lists
of events in the Win32::GUI manual are derived from.
Kieron
> -----Original Message-----
> From: Glenn W Munroe [mailto:gwm...@gm...]
> Sent: 12 December 2008 12:44
> To: 'Perl Rob'; Kieren Dunbar
> Cc: per...@li...
> Subject: RE: [perl-win32-gui-users] Perl-Win32-GUI-Users
> Digest, Vol 30,Issue 2
>
> Kieron,
>
> I'm not sure that this is exactly what you're looking for,
> but it may point
> you in the right direction. It doesn't trigger on a change
> via the drop-down
> list, but it does capture keystrokes:
>
> -start-
>
> #! perl -w
> use Win32::GUI qw(CBN_EDITCHANGE WM_COMMAND);
> use strict;
>
>
> my $x = Win32'GUI'Window->new('-size', [100, 100], '-pos', [0,0],
> '-visible', 1);
> my $y = $x->AddCombobox('-pos', [10, 10], '-size', [50, 200],
> '-dropdown',
> 1);
> $y->Add(1, 2); $y->Select(0);
>
> $y->Hook(CBN_EDITCHANGE,
> sub {
> my ($hObject, $wParam, $lParam, $iType, $iMsgCode) = @_;
> return 1 unless $iType == WM_COMMAND;
>
> print "Change: ".$y->Text."\n";
> 1;
> }
> );
>
> Win32'GUI'Dialog;
>
> -end-
>
> Cheers,
> Glenn
> -----Original Message-----
> From: Perl Rob [mailto:pe...@co...]
> Sent: 12 December 2008 01:06
> To: Kie...@ha...
> Cc: per...@li...
> Subject: Re: [perl-win32-gui-users] Perl-Win32-GUI-Users Digest, Vol
> 30,Issue 2
>
> Hi Kieron,
>
> To find out what has been selected, use the GetCurSel()
> method to get the
> index number of the currently selected item, then use the
> GetString() method
> to get the text of the item at that index:
>
> my $change = sub()
> {
> my $num = $y->GetCurSel;
> my $text = $y->GetString($num);
> print "You just selected $text\n";
> };
>
> As for your first question, I don't think a combobox listens
> for keyboard
> events by default (they're certainly not mentioned in the
> "Events" section
> of the API). I tried using the Hook() method with the
> WM_KEYUP event but
> that didn't work. Perhaps someone else knows.
>
> Regards,
> Rob
>
>
> ------------------------------
>
> Message: 4
> Date: Tue, 9 Dec 2008 16:30:37 -0000
> From: "Kieren Dunbar" <Kie...@ha...>
> Subject: [perl-win32-gui-users] Combobox problems
> To: <per...@li...>
> Message-ID: <53D...@hh...>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi All
>
> I have tried to use a combobox to do something, but I have had two
> problems.
> 1. I don't know what events are triggered if I type into the text box.
> It doesn't trigger obvious possibilities such as KeyUp, so I
> don't know
> what to look for.
> 2. If I trigger the Change trigger, box->Text contains the previous
> selection rather than the current one. How can I find
> out what the user has selected this time?
>
> I experienced this problem with ActiveState Perl 5.8.8 and Win32::GUI
> version 1.0.6. The source I used is as below. Could someone please
> suggest what I should do?
>
> Thank you.
>
> Kieron
>
> -start-
>
> my $x = Win32'GUI'Window->new('-size', [100, 100], '-pos', [0,0],
> '-visible', 1);
> my $y = $x->AddCombobox('-pos', [10, 10], '-size', [50, 200],
> '-dropdown', 1);
> $y->Add(1, 2);
> $y->Select(0);
>
> my $change = sub() {print $y->Text."\n"};
> $y->Change('-onChange', $change);
> $y->Change('-onKeyUp', $change);
>
> Win32'GUI'Dialog;
>
> -end-
>
>
>
> --------------------------------------------------------------
> --------------
> --
> SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las
> Vegas, Nevada.
> The future of the web can't happen without you. Join us at
> MIX09 to help
> pave the way to the Next Web now. Learn more and register at
> http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009
> .visitmix.com/
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Per...@li...
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> http://perl-win32-gui.sourceforge.net/
>
>
|