Bug in TDialog title [Solved]

Bug in TDialog title [Solved]

Postby Enrico Maria Giordano » Fri Feb 14, 2014 12:52 pm

The following sample demonstrates the problem. It doesn't show the dialog (tested under Win 8.1). It works correctly with a title up to 114 characters. In dialog.prg there is a check for maximum size of 140 characters. It should be lower to 114.

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    DEFINE DIALOG oDlg;
           TITLE REPLICATE( "X", 115 )

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TDialog title

Postby cnavarro » Fri Feb 14, 2014 9:03 pm

The following sample demonstrates the problem. It doesn't show the dialog (tested under Win 8.1). It works correctly with a title up to 114 characters. In dialog.prg there is a check for maximum size of 140 characters. It should be lower to 114.


Enrico

I use Windows 8.1 and Fwh 13.12
The version that appears Fivewin image is incorrect
Image suit.
Image
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6548
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bug in TDialog title

Postby Enrico Maria Giordano » Fri Feb 14, 2014 9:08 pm

Cristobal,

are you using Win 8.1 64 bit? If yes, can you send me your EXE to test it here?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TDialog title

Postby cnavarro » Fri Feb 14, 2014 9:24 pm

Enrico
I've sent you an email
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6548
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bug in TDialog title

Postby Enrico Maria Giordano » Fri Feb 14, 2014 10:10 pm

Cristobal,

received and already answered! :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TDialog title

Postby cnavarro » Fri Feb 14, 2014 11:10 pm

Enrico Maria Giordano wrote:Cristobal,

received and already answered! :-)

EMG


I answered
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6548
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bug in TDialog title

Postby Enrico Maria Giordano » Sat Feb 15, 2014 11:00 am

Some other clues. The following sample does work fine:

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    DEFINE DIALOG oDlg;
//           TITLE REPLICATE( "X", 115 )

//    oDlg:cCaption = REPLICATE( "X", 115 )

    ACTIVATE DIALOG oDlg;
             ON INIT oDlg:SetText( REPLICATE( "X", 500 ) );
             CENTER

    RETURN NIL


It doesn't if you comment out ON INIT clause and uncomment one of the two commented lines. Please note that there is a check for a maximum of 140 characters in TDialog cCaption (that does not trim my 500 characters string) which seems unuseful now.

Any ideas?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TDialog title

Postby Enrico Maria Giordano » Sat Feb 15, 2014 11:25 am

I traced the problem. It seems to be inside cDlg2Chr() function, probably in the calculation of wSize. But I guess we have to wait for Antonio to fix this.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TDialog title

Postby cnavarro » Sat Feb 15, 2014 11:54 am

Enrico
It is true
Fw cCaption Controls the length of the dialogue in the first case
Code: Select all  Expand view

DEFINE DIALOG oDlg TITLE REPLICATE( "X", 415 )
 


In this second case, the length is not controlled
Code: Select all  Expand view

    DEFINE DIALOG oDlg //TITLE REPLICATE( "X", 415 )
    oDlg:cCaption = REPLICATE( "X", 415 )

 


In this third case, the length is not controlled
Code: Select all  Expand view

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    DEFINE DIALOG oDlg //TITLE REPLICATE( "X", 415 )

    //oDlg:cCaption = REPLICATE( "X", 415 )

    ACTIVATE DIALOG oDlg;
             ON INIT oDlg:SetText( REPLICATE( "X", 500 ) );
             VALID (Msginfo( Len( oDlg:cCaption ) ), .T. );
             CENTER

    RETURN NIL
 


One possible solution would be to add at the end of the Initiate method of TDialog: (no activate method)

Code: Select all  Expand view

   if ::bInit != nil
      lResult = Eval( ::bInit, Self )
      if ValType( lResult ) == "L" .and. ! lResult
         lFocus = .f.
      endif
   endif

// Add
  if len( ::cCaption ) > 140
     ::cCaption := Left( ::cCaption , 140 )
     ::SetText( ::cCaption )
  endif
 


It's an idea and I have not tried yet


Tried
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6548
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bug in TDialog title

Postby Enrico Maria Giordano » Sat Feb 15, 2014 1:40 pm

Cristobal,

The third case works fine so the problem is not related to the length checking. As I already wrote, the problem is in cDlg2Chr() function. Once it is fixed, we can probably remove the length checking.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TDialog title

Postby cnavarro » Sat Feb 15, 2014 1:46 pm

Enrico
If I had understood what you have written
My proposal is a temporary solution
I've already tried
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6548
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bug in TDialog title

Postby Enrico Maria Giordano » Sat Feb 15, 2014 2:05 pm

Cristobal,

We need of a real solution.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TDialog title

Postby Enrico Maria Giordano » Sat Feb 15, 2014 3:18 pm

Found! It seems that the correct solution is:

WORD wSize = sizeof( DIALOG_RES ) + ( hb_parclen( 6 ) * 2 ) +
1 + 2 + ( hb_parclen( 9 ) * 2 ) + 3 + 1;

Please note the + 1 at the end of the line. With it I can use a title of 10000 characters without problems! :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TDialog title

Postby cnavarro » Sat Feb 15, 2014 5:39 pm

Enrico

Great, fine
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6548
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bug in TDialog title

Postby Enrico Maria Giordano » Sat Feb 15, 2014 9:50 pm

Enrico Maria Giordano wrote:Found! It seems that the correct solution is:

WORD wSize = sizeof( DIALOG_RES ) + ( hb_parclen( 6 ) * 2 ) +
1 + 2 + ( hb_parclen( 9 ) * 2 ) + 3 + 1;

Please note the + 1 at the end of the line. With it I can use a title of 10000 characters without problems! :-)

EMG


No! Unfortunately this is not the right fix, sorry. :-(

Ok, I will wait for Antonio... :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Next

Return to Bugs report & fixes / Informe de errores y arreglos

Who is online

Users browsing this forum: No registered users and 0 guests