Bug in TDialog title [Solved]

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

Bug in TDialog title [Solved]

Post by Enrico Maria Giordano »

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

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

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

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL
EMG
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bug in TDialog title

Post by cnavarro »

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
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Bug in TDialog title

Post by Enrico Maria Giordano »

Cristobal,

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

EMG
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bug in TDialog title

Post by cnavarro »

Enrico
I've sent you an email
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bug in TDialog title

Post by cnavarro »

Enrico Maria Giordano wrote:Cristobal,

received and already answered! :-)

EMG
I answered
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Bug in TDialog title

Post by Enrico Maria Giordano »

Some other clues. The following sample does work fine:

Code: Select all

#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: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Bug in TDialog title

Post by Enrico Maria Giordano »

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
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bug in TDialog title

Post by cnavarro »

Enrico
It is true
Fw cCaption Controls the length of the dialogue in the first case

Code: Select all

DEFINE DIALOG oDlg TITLE REPLICATE( "X", 415 )
 
In this second case, the length is not controlled

Code: Select all

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

 
In this third case, the length is not controlled

Code: Select all

#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

   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
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Bug in TDialog title

Post by Enrico Maria Giordano »

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
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bug in TDialog title

Post by cnavarro »

Enrico
If I had understood what you have written
My proposal is a temporary solution
I've already tried
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Bug in TDialog title

Post by Enrico Maria Giordano »

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
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bug in TDialog title

Post by cnavarro »

Enrico

Great, fine
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Bug in TDialog title

Post by Enrico Maria Giordano »

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
Post Reply