He conseguido solucionarlo casi todo y ha quedado asi:
Código PHP:
//Funcion que controla el evento de desplazamiento del raton sobre los items del combobox de los mapas
void __fastcall TForm1::AppIdle(TObject *Sender, bool &done)
{
TPoint pt;
HWND HWL;
RECT rcItem;
GetCursorPos( &pt );
HWL = WindowFromPoint( pt );
if ( HWL != 0 )
{
char buff[128];
GetClassName( HWL, buff, sizeof( buff ) );
if ( StrIComp( buff, "ComboLBox" ) == 0)
{
int inx;
if ( FInCBox)
{
::ScreenToClient( HWL, &pt );
inx = LOWORD( SendMessage( HWL, LB_ITEMFROMPOINT, 0,
(LPARAM)MAKELONG(pt.x, pt.y)));
if ( inx >= 0 ){
//Aqui muestro la imagen
if(FInCBoxMaps && lastIndex != inx){
MostrarImagenMapa(inx);
lastIndex=inx;
}
//memset(textoHint,'\0',sizeof(textoHint));
//Obtengo la cadena del item
SendMessage( HWL, LB_GETTEXT, inx, int(&textoHint));
//Obtengo su posicion en la lista
SendMessage( HWL, LB_GETITEMRECT, inx, (LPARAM)&rcItem);
}
}
//Muestro el hint siempre y cuando sea diferente al que ya se esta mostrando
if(pt.x >= rcItem.left && pt.x <= rcItem.right && pt.y >= rcItem.top && pt.y <= rcItem.bottom)
{
//Vuelvo a mostrarlo siempre que sea uno diferente al anterior
if(StrIComp( textoHint, hint->Caption.c_str()) != 0)
{
//Necesario para saber la posicion relativa para mostrar el hint
::ClientToScreen(HWL, &pt);
//int largo=SendMessage( HWL, LB_GETTEXTLEN,inx,0);
rcItem.left=pt.x;
rcItem.top=pt.y;
rcItem.right=pt.x + 300; //Necesito el ancho justo de lo que ocupa el texto porque esto no funciona asi
rcItem.bottom=pt.y + 15; //Necesito el alto justo de lo que ocupa el texto
hint->Caption=textoHint;
hint->Color=clInfoBk;
hint->ActivateHint(rcItem,textoHint);
}
}
}else{
if(hint != NULL){
hint->ReleaseHandle();
hint->Caption="";
}
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ComboBoxMapasDropDown(TObject *Sender)
{
hint= new THintWindow(ComboBoxMapas->Handle);
FInCBoxMaps = true;
FInCBox = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ComboBoxMapasCloseUp(TObject *Sender)
{
if(hint != NULL){
delete hint;
hint=NULL;
}
ComboBoxMapas->Hint = ComboBoxMapas->Items->Strings[ComboBoxMapas->ItemIndex];
FInCBoxMaps = false;
FInCBox = false;
MostrarImagenMapa(ComboBoxMapas->ItemIndex);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ComboBoxsDropDown(TObject *Sender)
{
hint= new THintWindow(ComboBoxMapas->Handle);
FInCBox = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ComboBoxsCloseUp(TObject *Sender)
{
TComboBox *CB = static_cast<TComboBox*>(Sender);
CB->Hint = CB->Items->Strings[CB->ItemIndex];
if(hint != NULL){
delete hint;
hint=NULL;
}
FInCBox = false;
}
//---------------------------------------------------------------------------
Lo que me falta es asignar el tamaño correcto al Hint para que se vea del largo del texto pero no se como hacerlo y ya llevo dos dias con esto.