Long standing bug in FWH
Posted: Fri Nov 07, 2014 8:06 am
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:
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
and in dialog.prg
In control.prg
I would like to know your opinions before proceeding to implement it, thanks
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 )
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.> )
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
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 )