|
From: Kind, U. (AGIS) <uwe...@al...> - 2006-10-28 23:36:17
|
Hi Teddy,
try the following:
------------------------------------------------------------------------
----
#!perl -w
use Win32::GUI ( 'WM_COMMAND' );
my $mw =3D new Win32::GUI::Window
( -name =3D> 'mw',
-left =3D> 100,
-top =3D> 100,
-width =3D> 300,
-height =3D> 100,
-title =3D> 'CBTest',
);
=20
my $cb=3D $mw -> AddCombobox
( -name =3D> 'cb',
-left =3D> 10,
-top =3D> 20,
-width =3D> $mw -> ScaleWidth () - 20,
-height =3D> 200,
-disablenoscroll =3D> 200,
-dropdown =3D> 1,
-vscroll =3D> 1,
);
my $cb_event =3D sub
{
my $self =3D shift ();
if ( $_ [ 0 ] =3D=3D 0x40003E9 )
{
my $text =3D $self -> Text ();
my $match =3D $self -> FindString ( $text );
=20
if ( $match >=3D 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 !=3D 3)
Perl_croak(aTHX_ "Usage:
Win32::GUI::Combobox::SetEditSel(handle, start, end)");
{
HWND handle;
WPARAM start =3D (WPARAM)SvIV(ST(1));
WPARAM end =3D (WPARAM)SvIV(ST(2));
LPARAM sel =3D end * 0x10000 + start; /* added */
LRESULT RETVAL;
dXSTARG;
if(SvROK(ST(0))) {
SV** out=3Dhv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
if(out !=3D NULL)
handle =3D INT2PTR(HWND,SvIV(*out));
else
handle =3D NULL;
} else
handle =3D INT2PTR(HWND,SvIV(ST(0)));
#line 561 "Combobox.xs"
/ * RETVAL =3D SendMessage(handle, CB_SETEDITSEL, start, (LPARAM)
end); */
RETVAL =3D 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
|