Bug harbour_3.2_32bits_MSVC2013_20142906

Bug harbour_3.2_32bits_MSVC2013_20142906

Postby fgondi » 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.
Image


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
User avatar
fgondi
 
Posts: 694
Joined: Fri Oct 07, 2005 6:58 am
Location: Palencia, España

Re: Bug harbour_3.2_32bits_MSVC2013_20142906

Postby Antonio Linares » Tue Jul 01, 2014 3:24 pm

Fernando,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug harbour_3.2_32bits_MSVC2013_20142906

Postby fgondi » Tue Jul 01, 2014 4: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: Select all  Expand view
...
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
User avatar
fgondi
 
Posts: 694
Joined: Fri Oct 07, 2005 6:58 am
Location: Palencia, España

Re: Bug harbour_3.2_32bits_MSVC2013_20142906

Postby Antonio Linares » Tue Jul 01, 2014 6:27 pm

Fernando,

ok, visto el error tambien aqui.

Estoy buscando la causa...

gracias :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug harbour_3.2_32bits_MSVC2013_20142906

Postby Antonio Linares » Tue Jul 01, 2014 6: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug harbour_3.2_32bits_MSVC2013_20142906

Postby Antonio Linares » Tue Jul 01, 2014 6:42 pm

La prueba está en que si cambio estas líneas:

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


por:

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


entonces muestra "xyz"

sigo buscando...
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug harbour_3.2_32bits_MSVC2013_20142906

Postby Antonio Linares » Tue Jul 01, 2014 6:45 pm

Este es el código de MISText()

Code: Select all  Expand view
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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug harbour_3.2_32bits_MSVC2013_20142906

Postby Antonio Linares » Tue Jul 01, 2014 6: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: Select all  Expand view
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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug harbour_3.2_32bits_MSVC2013_20142906

Postby Antonio Linares » Tue Jul 01, 2014 6:58 pm

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

sigo... :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug harbour_3.2_32bits_MSVC2013_20142906

Postby Antonio Linares » Tue Jul 01, 2014 7:07 pm

Pues no, no es una cadena "wide" porque este código tambien falla:

Code: Select all  Expand view
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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug harbour_3.2_32bits_MSVC2013_20142906

Postby Antonio Linares » Tue Jul 01, 2014 7:14 pm

Pruebo a concatenarle algo al final para ver que hay en buffer, y muestra un solo caracter "raro" + "here":

Code: Select all  Expand view
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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug harbour_3.2_32bits_MSVC2013_20142906

Postby Antonio Linares » Tue Jul 01, 2014 7:19 pm

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug harbour_3.2_32bits_MSVC2013_20142906

Postby Antonio Linares » Tue Jul 01, 2014 7:22 pm

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug harbour_3.2_32bits_MSVC2013_20142906

Postby Antonio Linares » Tue Jul 01, 2014 7: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug harbour_3.2_32bits_MSVC2013_20142906

Postby Antonio Linares » Tue Jul 01, 2014 7:26 pm

Solucionado :-)

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

Code: Select all  Expand view
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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Next

Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 59 guests