FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Bug harbour_3.2_32bits_MSVC2013_20142906
Posts: 694
Joined: Fri Oct 07, 2005 06:58 AM
Bug harbour_3.2_32bits_MSVC2013_20142906
Posted: Tue Jul 01, 2014 11:39 AM
Antonio,

He descargado la versión de Harbour para MVSC2013 que incluyes en el siguiente enlace:
http://forums.fivetechsupport.com/viewtopic.php?f=16&t=28773#p161609

Tengo definido el MenuInfo para que muestre en el menu principal las ventanas MDI que tengo abiertas.
Ahora no se lee el título de la ventana(s) que hay abierta(s), aparecen caracteres raros.



Ocurre tanto con la versión que incluyes, como si yo genero harbour a través de git,
Un saludo

Fernando González Diez

ALSIS Sistemas Informáticos
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug harbour_3.2_32bits_MSVC2013_20142906
Posted: Tue Jul 01, 2014 03:24 PM

Fernando,

Podrías probarlo con Borland también para ver si ocurre lo mismo ? gracias :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 694
Joined: Fri Oct 07, 2005 06:58 AM
Re: Bug harbour_3.2_32bits_MSVC2013_20142906
Posted: Tue Jul 01, 2014 04:23 PM
Antonio,

Con Borland582 funciona bien.
Sólo pasa con MSVC2013

he podido comprobar que es al añadir el valor 2007 o 2010 al menu.
Por ejemplo se puede reproducir con: "Samples\testmdi.prg"

Code (fw): Select all Collapse
...
function BuildMenu()

   local oMenu

   MENU oMenu 2007
...

Sólo con añadir 2007 o 2010 al menú pinta caracteres raros linkando con VC2013
Sin ese valor funciona bien
Un saludo

Fernando González Diez

ALSIS Sistemas Informáticos
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug harbour_3.2_32bits_MSVC2013_20142906
Posted: Tue Jul 01, 2014 06:27 PM

Fernando,

ok, visto el error tambien aqui.

Estoy buscando la causa...

gracias :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug harbour_3.2_32bits_MSVC2013_20142906
Posted: Tue Jul 01, 2014 06:40 PM

Fernando,

El problema viene de la línea 1181 de window.prg, en concreto de la llamada a MISText( pItemStruct ) que no está devolviendo el valor correcto.

Ahora estoy intentando descubrir porque pasa eso.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug harbour_3.2_32bits_MSVC2013_20142906
Posted: Tue Jul 01, 2014 06:42 PM
La prueba está en que si cambio estas líneas:

Code (fw): Select all Collapse
               MenuDraw2007( pItemStruct,;
                             If( IsSeparator( pItemStruct ), "", MISText( pItemStruct ) ),;
                             0,, ::hWnd )


por:

Code (fw): Select all Collapse
               MenuDraw2007( pItemStruct,;
                             If( IsSeparator( pItemStruct ), "", "xyz" ),;
                             0,, ::hWnd )


entonces muestra "xyz"

sigo buscando...
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug harbour_3.2_32bits_MSVC2013_20142906
Posted: Tue Jul 01, 2014 06:45 PM
Este es el código de MISText()

Code (fw): Select all Collapse
HB_FUNC( MISTEXT ) // pItemStruct --> cPrompt
{
   #ifdef _WIN64
      LPDRAWITEMSTRUCT lpdis = ( LPDRAWITEMSTRUCT ) hb_parnll( 1 ); 
   #else
      LPDRAWITEMSTRUCT lpdis = ( LPDRAWITEMSTRUCT ) hb_parnl( 1 );  
   #endif
      
   MENUITEMINFO mi;
   BYTE buffer[ 100 ];

   mi.cbSize = sizeof( MENUITEMINFO );
   mi.fMask = MIIM_STRING;
   mi.dwTypeData = ( LPSTR ) buffer; 
   GetMenuItemInfo( ( HMENU ) lpdis->hwndItem, lpdis->itemID, FALSE, &mi );   
   
   hb_retc( ( char * ) buffer );
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug harbour_3.2_32bits_MSVC2013_20142906
Posted: Tue Jul 01, 2014 06:56 PM
GetMenuItemInfo() devuelve un valor lógico, verdadero si todo ha ido bien.

Lo primero que se me ha ocurrido es que la estructura MENUITEMINFO mi; no este "limpia", asi que he añadido estas líneas:

Code (fw): Select all Collapse
HB_FUNC( MISTEXT ) // pItemStruct --> cPrompt
{
     #ifdef _WIN64
      LPDRAWITEMSTRUCT lpdis = ( LPDRAWITEMSTRUCT ) hb_parnll( 1 ); 
   #else
      LPDRAWITEMSTRUCT lpdis = ( LPDRAWITEMSTRUCT ) hb_parnl( 1 );  
   #endif
      
   MENUITEMINFO mi;
   BYTE buffer[ 100 ];

   memset( &mi, 0, sizeof( mi ) );
   
   mi.cbSize = sizeof( MENUITEMINFO );
   mi.fMask = MIIM_STRING;
   mi.dwTypeData = ( LPSTR ) buffer; 
   if( ! GetMenuItemInfo( ( HMENU ) lpdis->hwndItem, lpdis->itemID, FALSE, &mi ) )
      strcpy( buffer, "here" );    
   
   hb_retc( ( char * ) buffer );
}


Pero aún asi sigue fallando y el caso es que no se añade "here" al texto del menuitem, luego GetMenuItemInfo() está devolviendo verdadero.

Y si devuelve verdadero, por qué lo que copia en buffer esta mal ?

sigo...
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug harbour_3.2_32bits_MSVC2013_20142906
Posted: Tue Jul 01, 2014 06:58 PM

Se me ocurre que tal vez este copiando una cadena "wide" y no "ansi"...

sigo... :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug harbour_3.2_32bits_MSVC2013_20142906
Posted: Tue Jul 01, 2014 07:07 PM
Pues no, no es una cadena "wide" porque este código tambien falla:

Code (fw): Select all Collapse
static LPSTR WideToAnsi( LPWSTR cWide )
{
   WORD wLen;
   LPSTR cString = NULL;

   wLen = WideCharToMultiByte( CP_ACP, 0, cWide, -1, cString, 0, NULL, NULL );

   cString = ( LPSTR ) hb_xgrab( wLen );
   WideCharToMultiByte( CP_ACP, 0, cWide, -1, cString, wLen, NULL, NULL );

   return cString;
}
   
HB_FUNC( MISTEXT ) // pItemStruct --> cPrompt
{
     #ifdef _WIN64
      LPDRAWITEMSTRUCT lpdis = ( LPDRAWITEMSTRUCT ) hb_parnll( 1 ); 
   #else
      LPDRAWITEMSTRUCT lpdis = ( LPDRAWITEMSTRUCT ) hb_parnl( 1 );  
   #endif
   LPSTR pText;
      
   MENUITEMINFO mi;
   BYTE buffer[ 100 ];

   memset( &mi, 0, sizeof( mi ) );
   
   mi.cbSize = sizeof( MENUITEMINFO );
   mi.fMask = MIIM_STRING;
   mi.dwTypeData = ( LPSTR ) buffer; 
   GetMenuItemInfo( ( HMENU ) lpdis->hwndItem, lpdis->itemID, FALSE, &mi );
   
   pText = WideToAnsi( buffer );
   hb_retc( pText );
   hb_xfree( pText );
}


que puede ser ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug harbour_3.2_32bits_MSVC2013_20142906
Posted: Tue Jul 01, 2014 07:14 PM
Pruebo a concatenarle algo al final para ver que hay en buffer, y muestra un solo caracter "raro" + "here":

Code (fw): Select all Collapse
HB_FUNC( MISTEXT ) // pItemStruct --> cPrompt
{
     #ifdef _WIN64
      LPDRAWITEMSTRUCT lpdis = ( LPDRAWITEMSTRUCT ) hb_parnll( 1 ); 
   #else
      LPDRAWITEMSTRUCT lpdis = ( LPDRAWITEMSTRUCT ) hb_parnl( 1 );  
   #endif
   LPSTR pText;
      
   MENUITEMINFO mi;
   BYTE buffer[ 100 ];

   memset( &mi, 0, sizeof( mi ) );
   
   mi.cbSize = sizeof( MENUITEMINFO );
   mi.fMask = MIIM_STRING;
   mi.dwTypeData = ( LPSTR ) buffer; 
   GetMenuItemInfo( ( HMENU ) lpdis->hwndItem, lpdis->itemID, FALSE, &mi );
   
   strcat( buffer, "here" );
   
   hb_retc( buffer );
}


No puedo creer que GetMenuItemInfo() falle, porque además devuelve verdadero...
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug harbour_3.2_32bits_MSVC2013_20142906
Posted: Tue Jul 01, 2014 07:19 PM

Ahora he probado ese código con Borland y falla tambien...

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug harbour_3.2_32bits_MSVC2013_20142906
Posted: Tue Jul 01, 2014 07:22 PM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug harbour_3.2_32bits_MSVC2013_20142906
Posted: Tue Jul 01, 2014 07:24 PM
Creo que aqui está la clave:

dwTypeData
Type: LPTSTR
The contents of the menu item. The meaning of this member depends on the value of fType and is used only if the MIIM_TYPE flag is set in the fMask member.
To retrieve a menu item of type MFT_STRING, first find the size of the string by setting the dwTypeData member of MENUITEMINFO to NULL and then calling GetMenuItemInfo. The value of cch+1 is the size needed. Then allocate a buffer of this size, place the pointer to the buffer in dwTypeData, increment cch, and call GetMenuItemInfo once again to fill the buffer with the string. If the retrieved menu item is of some other type, then GetMenuItemInfo sets the dwTypeData member to a value whose type is specified by the fType member.
When using with the SetMenuItemInfo function, this member should contain a value whose type is specified by the fType member.
dwTypeData is used only if the MIIM_STRING flag is set in the fMask member
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug harbour_3.2_32bits_MSVC2013_20142906
Posted: Tue Jul 01, 2014 07:26 PM
Solucionado :-)

Este es el código correcto. Un bug menos :-)

Code (fw): Select all Collapse
HB_FUNC( MISTEXT ) // pItemStruct --> cPrompt
{
     #ifdef _WIN64
      LPDRAWITEMSTRUCT lpdis = ( LPDRAWITEMSTRUCT ) hb_parnll( 1 ); 
   #else
      LPDRAWITEMSTRUCT lpdis = ( LPDRAWITEMSTRUCT ) hb_parnl( 1 );  
   #endif
      
   MENUITEMINFO mi;
   BYTE buffer[ 100 ];

   memset( &mi, 0, sizeof( mi ) );
   
   mi.cbSize = sizeof( MENUITEMINFO );
   mi.fMask = MIIM_STRING;

   mi.dwTypeData = NULL; 
   GetMenuItemInfo( ( HMENU ) lpdis->hwndItem, lpdis->itemID, FALSE, &mi );

   mi.dwTypeData = ( LPSTR ) buffer; 
   mi.cch++;
   GetMenuItemInfo( ( HMENU ) lpdis->hwndItem, lpdis->itemID, FALSE, &mi );
   
   hb_retc( buffer );
}
regards, saludos

Antonio Linares
www.fivetechsoft.com