Page 1 of 3

Bug in TDialog title [Solved]

PostPosted: Fri Feb 14, 2014 12:52 pm
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  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

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

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL


EMG

Re: Bug in TDialog title

PostPosted: Fri Feb 14, 2014 9:03 pm
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

Re: Bug in TDialog title

PostPosted: Fri Feb 14, 2014 9:08 pm
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

Re: Bug in TDialog title

PostPosted: Fri Feb 14, 2014 9:24 pm
by cnavarro
Enrico
I've sent you an email

Re: Bug in TDialog title

PostPosted: Fri Feb 14, 2014 10:10 pm
by Enrico Maria Giordano
Cristobal,

received and already answered! :-)

EMG

Re: Bug in TDialog title

PostPosted: Fri Feb 14, 2014 11:10 pm
by cnavarro
Enrico Maria Giordano wrote:Cristobal,

received and already answered! :-)

EMG


I answered

Re: Bug in TDialog title

PostPosted: Sat Feb 15, 2014 11:00 am
by Enrico Maria Giordano
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

Re: Bug in TDialog title

PostPosted: Sat Feb 15, 2014 11:25 am
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

Re: Bug in TDialog title

PostPosted: Sat Feb 15, 2014 11:54 am
by cnavarro
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

Re: Bug in TDialog title

PostPosted: Sat Feb 15, 2014 1:40 pm
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

Re: Bug in TDialog title

PostPosted: Sat Feb 15, 2014 1:46 pm
by cnavarro
Enrico
If I had understood what you have written
My proposal is a temporary solution
I've already tried

Re: Bug in TDialog title

PostPosted: Sat Feb 15, 2014 2:05 pm
by Enrico Maria Giordano
Cristobal,

We need of a real solution.

EMG

Re: Bug in TDialog title

PostPosted: Sat Feb 15, 2014 3:18 pm
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

Re: Bug in TDialog title

PostPosted: Sat Feb 15, 2014 5:39 pm
by cnavarro
Enrico

Great, fine

Re: Bug in TDialog title

PostPosted: Sat Feb 15, 2014 9:50 pm
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