Long standing bug in FWH

Post Reply
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Long standing bug in FWH

Post by Antonio Linares »

Our dear Paco García sent me an email some days ago as he found a bug that has been in FiveWin since its early days and that it is the cause for pixels dimensions used on the dialogs not to work fine:

Code: Select all

METHOD cToChar( cCtrlClass ) CLASS TControl

   local n := GetDlgBaseUnits()

   DEFAULT cCtrlClass := ::ClassName(),;
           ::cCaption := "",;
           ::nId      := ::GetNewId(),;
           ::nStyle   := nOR( WS_CHILD, WS_VISIBLE, WS_TABSTOP )

return cCtrl2Chr( Int( 2 * 8 * ::nTop    / nHiWord( n ) ),;
                  Int( 2 * 4 * ::nLeft   / nLoWord( n ) ),;
                  Int( 2 * 8 * ::nBottom / nHiWord( n ) ),;
                  Int( 2 * 4 * ::nRight  / nLoWord( n ) ),;
                  ::nId, ::nStyle, cCtrlClass, ::cCaption )
Those "2" are not needed at all and thats the reason why the pixels dimensions are not respected.

I am very thankfull to Paco for his great help discovering this londstanding bug.

Now we need to decide what to do. We have to keep backwards compatibility, so he proposed me a new clause:

In dialog.ch

Code: Select all

#xcommand DEFINE DIALOG <oDlg> ;
             [ <resource: NAME, RESNAME, RESOURCE> <cResName> ] ;
             [ TITLE <cTitle> ] ;
             [ FROM <nTop>, <nLeft> TO <nBottom>, <nRight> ] ;
             [ SIZE <nWidth>, <nHeight> ] ;
             [ <lib: LIBRARY, DLL> <hResources> ] ;
             [ <vbx: VBX> ] ;
             [ STYLE <nStyle> ] ;
             [ <color: COLOR, COLORS> <nClrText> [,<nClrBack> ] ] ;
             [ BRUSH <oBrush> ] ;
             [ <of: WINDOW, DIALOG, OF> <oWnd> ] ;
             [ <pixel: PIXEL> ] ;
             [ ICON <oIco> ] ;
             [ FONT <oFont> ] ;
             [ <help: HELP, HELPID> <nHelpId> ] ;
             [ <transparent: TRANSPARENT> ] ;
             [ GRADIENT <aGradColors> ] ;
             [ <lTruePixel: TRUEPIXEL>  ] ;
       => ;
          <oDlg> = TDialog():New( <nTop>, <nLeft>, <nBottom>, <nRight>,;
                 <cTitle>, <cResName>, <hResources>, <.vbx.>, <nStyle>,;
                 <nClrText>, <nClrBack>, <oBrush>, <oWnd>, <.pixel.>,;
                 <oIco>, <oFont>, <nHelpId>, <nWidth>, <nHeight>, <.transparent.>,;
                 <aGradColors>, <.lTruePixel.> )
 
and in dialog.prg

Code: Select all

Dialog.prg

   DATA   lTruePixel AS LOGICAL INIT .F.

   METHOD New( nTop, nLeft, nBottom, nRight, cCaption, cResName, hResources,;
               lVbx, nStyle, nClrText, nClrBack, oBrush, oWnd, lPixels,;
               oIco, oFont, nHelpId, nWidth, nHeight, lTransparent, aNewGradColors, lTruePixel ) CONSTRUCTOR

METHOD New( nTop, nLeft, nBottom, nRight, cCaption, cResName, hResources,;
            lVbx, nStyle, nClrText, nClrBack, oBrush, oWnd, lPixels,;
            oIco, oFont, nHelpId, nWidth, nHeight, lTransparent, aNewGradColors, lTruePixel ) CLASS TDialog

   DEFAULT hResources := GetResources(), lVbx := .f.,;
           nClrText   := GetSysColor( COLOR_BTNTEXT ), nClrBack := GetSysColor( COLOR_BTNFACE ),;
           lPixels    := .f., nTop := 0, nLeft := 0, nBottom := 10, nRight := 40,;
           nWidth     := 0, nHeight := 0, lTransparent := .f.,;
           nStyle     := nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU ),;
           lTruePixel := .f.

   ::lTruePixel = lTruePixel
 
In control.prg

Code: Select all

METHOD cToChar( cCtrlClass ) CLASS TControl

   local n := GetDlgBaseUnits()

   DEFAULT cCtrlClass := ::ClassName(),;
           ::cCaption := "",;
           ::nId      := ::GetNewId(),;
           ::nStyle   := nOR( WS_CHILD, WS_VISIBLE, WS_TABSTOP )

return cCtrl2Chr( Int( if(::oWnd:lTruePixel,1,2) * 8 * ::nTop    / nHiWord( n ) ),;
                  Int( if(::oWnd:lTruePixel,1,2) * 4 * ::nLeft   / nLoWord( n ) ),;
                  Int( if(::oWnd:lTruePixel,1,2) * 8 * ::nBottom / nHiWord( n ) ),;
                  Int( if(::oWnd:lTruePixel,1,2) * 4 * ::nRight  / nLoWord( n ) ),;
                  ::nId, ::nStyle, cCtrlClass, ::cCaption )
 
I would like to know your opinions before proceeding to implement it, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
IBTC
Posts: 103
Joined: Sat Oct 18, 2008 8:13 pm
Location: Stuttgart, Germany
Contact:

Re: Long standing bug in FWH

Post by IBTC »

o.k. Good solution.
Best Regards,
Ruediger Alich

---
HMG 3.1.3 | FTDN/FWH 13.12 | Harbour 3.2 | BCC/MinGW | Windows XP/Vista/7/8/10 (32/64-Bit), Wine (Linux/Mac) - started 1999 with FW, 1989 with Clipper
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: Long standing bug in FWH

Post by James Bott »

I like it.
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Long standing bug in FWH

Post by nageswaragunupudi »

I suggest a Global setting too.
If I set globally I need not have to write the clause everytime I create a new dialog in my future projects.
Regards

G. N. Rao.
Hyderabad, India
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: Long standing bug in FWH

Post by Silvio.Falconi »

I don't understood can you make a sample... perhaps I not see the differences or I not Understood wich are the differences
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
FiveWiDi
Posts: 910
Joined: Mon Oct 10, 2005 2:38 pm

Re: Long standing bug in FWH

Post by FiveWiDi »

nageswaragunupudi wrote:I suggest a Global setting too.
If I set globally I need not have to write the clause everytime I create a new dialog in my future projects.
I dont agree wiht you.

Sólo sería válido para nuevas aplicaciones, en las existentes os obligaría a tocar todas las ventanas ya existentes.
Una combinación de global y cláusula si que sería válido.
Traducírselo por favor.

Regards,
Un Saludo
Carlos G.

FiveWin 19.06 + Harbour 3.2, BCC 7 Windows 10
User avatar
Carles
Posts: 937
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona
Contact:

Re: Long standing bug in FWH

Post by Carles »

+1

but CLASSDATA instead DATA
Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

https://modharbour.app
https://modharbour.app/compass
https://forum.modharbour.app
Post Reply