|
From: Octavian R. <ora...@gm...> - 2006-10-29 07:59:07
|
Thank you very much for this code.
I will try to test it, although I am not sure that I know how to apply that
patch.
Teddy
----- Original Message -----
From: "Kind, Uwe (AGIS)" <uwe...@al...>
To: <per...@li...>
Sent: Sunday, October 29, 2006 1:35 AM
Subject: Re: [perl-win32-gui-users] Combobox
> Hi Teddy,
>
> try the following:
>
> ------------------------------------------------------------------------
> ----
> #!perl -w
>
> use Win32::GUI ( 'WM_COMMAND' );
>
> my $mw = new Win32::GUI::Window
> ( -name => 'mw',
> -left => 100,
> -top => 100,
> -width => 300,
> -height => 100,
> -title => 'CBTest',
> );
>
> my $cb= $mw -> AddCombobox
> ( -name => 'cb',
> -left => 10,
> -top => 20,
> -width => $mw -> ScaleWidth () - 20,
> -height => 200,
>
> -disablenoscroll => 200,
> -dropdown => 1,
> -vscroll => 1,
> );
>
> my $cb_event = sub
> {
> my $self = shift ();
>
> if ( $_ [ 0 ] == 0x40003E9 )
> {
> my $text = $self -> Text ();
> my $match = $self -> FindString ( $text );
>
> if ( $match >= 0 )
> {
> $self -> Text ( $self -> GetString ( $match ) );
> $self -> SetEditSel ( length ( $text ), -1 );
> }
> }
> return ( 1 );
> };
>
> $cb -> Hook ( WM_COMMAND, $cb_event );
> $cb -> SetFocus ();
>
> for ( 65 .. 90 )
> {
> $cb -> AddString ( chr ( $_ ) . ' Test' );
> }
>
> $mw -> Show ();
> Win32::GUI::Dialog ();
> ------------------------------------------------------------------------
> ----
>
> It won't work from the scratch because of an bug in SetEditSel, so
> Combobox
> has to be patched first:
>
> ------------------------------------------------------------------------
> ----
>
> XS(XS_Win32__GUI__Combobox_SetEditSel)
> {
> dXSARGS;
> if (items != 3)
> Perl_croak(aTHX_ "Usage:
> Win32::GUI::Combobox::SetEditSel(handle, start, end)");
> {
> HWND handle;
> WPARAM start = (WPARAM)SvIV(ST(1));
> WPARAM end = (WPARAM)SvIV(ST(2));
> LPARAM sel = end * 0x10000 + start; /* added */
>
> LRESULT RETVAL;
> dXSTARG;
>
> if(SvROK(ST(0))) {
> SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
> if(out != NULL)
> handle = INT2PTR(HWND,SvIV(*out));
> else
> handle = NULL;
> } else
> handle = INT2PTR(HWND,SvIV(ST(0)));
> #line 561 "Combobox.xs"
> / * RETVAL = SendMessage(handle, CB_SETEDITSEL, start, (LPARAM)
> end); */
> RETVAL = SendMessage(handle, CB_SETEDITSEL, 0, sel); /* changed */
> #line 984 "Combobox.c"
> XSprePUSH; PUSHi((IV)RETVAL);
> }
> XSRETURN(1);
> }
>
> ------------------------------------------------------------------------
> ----
>
> Furthermore You should handle Del and Backspace or it won't possible to
> enter a string like 'A Te' because it's always expanded to 'A Test'.
>
> Regards, Uwe
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job
easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Per...@li...
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> http://perl-win32-gui.sourceforge.net/
|