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