From: Geoff Chambers on 9 Jan 2010 15:18 I have a bBrowser set up in a window so the browser fills the window. I have a column set with AutoWodthColumn, so the browser fills the entire window. I would like to limit the AutoWidthColumn to say 500 using oColumn:WidthMax, but I still want the browser to fill the window and setting this property prevents that. I gues I would like a second column to take over and automatically adjust. Is this possible? Thx
From: Geoff Schaller on 9 Jan 2010 16:10 Hi Geoff. No, this is not possible unless you want to get into the source code of bBrowser and deal with the Resize method. I know exactly what you mean and have often thought it would be nice but here is what is required: 1. bBrowser would need a new property to hold the column number of the 'second' autowidth column. 2. Method AdjustAutoWidthColumn would now need to halt at Row 60 and test iWdith against the max width for that column. 3. If iWidth > Max, then the column width is set to max and the process called again for the second column. Unless you want to dive into this I might take a look later today. Geoff "Geoff Chambers" <gchambers02(a)msn.com> wrote in message news:225dfc7c-ba16-4209-a341-71d7f83dca46(a)e27g2000yqd.googlegroups.com: > I have a bBrowser set up in a window so the browser fills the window. > I have a column set with AutoWodthColumn, so the browser fills the > entire window. I would like to limit the AutoWidthColumn to say 500 > using oColumn:WidthMax, but I still want the browser to fill the > window and setting this property prevents that. I gues I would like a > second column to take over and automatically adjust. > > Is this possible? > > Thx
From: Geoff Chambers on 9 Jan 2010 20:12 On Jan 9, 4:10 pm, "Geoff Schaller" <geo...(a)softxwareobjectives.com.au> wrote: > Hi Geoff. > > No, this is not possible unless you want to get into the source code of > bBrowser and deal with the Resize method. I know exactly what you mean > and have often thought it would be nice but here is what is required: > > 1. bBrowser would need a new property to hold the column number of the > 'second' autowidth column. > 2. Method AdjustAutoWidthColumn would now need to halt at Row 60 and > test iWdith against the max width for that column. > 3. If iWidth > Max, then the column width is set to max and the process > called again for the second column. > > Unless you want to dive into this I might take a look later today. > > Geoff > > "Geoff Chambers" <gchamber...(a)msn.com> wrote in message > > news:225dfc7c-ba16-4209-a341-71d7f83dca46(a)e27g2000yqd.googlegroups.com: > > > > > I have a bBrowser set up in a window so the browser fills the window. > > I have a column set with AutoWodthColumn, so the browser fills the > > entire window. I would like to limit the AutoWidthColumn to say 500 > > using oColumn:WidthMax, but I still want the browser to fill the > > window and setting this property prevents that. I gues I would like a > > second column to take over and automatically adjust. > > > Is this possible? > > > Thx- Hide quoted text - > > - Show quoted text - Thanks for the quick response, I was just curious because I noticed it, using my computer. Most of my users never run into the problem, cause of the size of their screen. I'm lucky if I can get some of my browsers to fit the screen that they use.
From: Geoff Schaller on 10 Jan 2010 06:06 Geoff, Ok, I've done what you want. Subclass the MybBrowser from your own subclassed bBrowser of course. A couple of rules: 1. The columns must be real fields (not access or expression columns). 2. You must set a reasonable Width, widthMin and WidthMax on the auto sized columns. 3. You can have any number of auto sizing columns but each needs an appropriate minimum width. 4. This will not take into account column groups. I have no idea what the outcome will look like. 5. You cannot use this on auto-sized columns or columns with size properties set. (Anyone who wishes may adjust my code to solve the issues of point 1, 4 or 5) You use the code like this: oMybBrowser:OpenColumn({#ACCT,#ACCTNAME,#MGLTYP,#BASCODE,#NOTINUSE,#U_DATE}) // set the sizes for each column, for example // oColumn := oMybBrowser:GetColumn(#ACCTNAME) // oColumn:Width := 200 // oColumn:WidthMin := 200 // oColumn:WidthMax := 300 oMybBrowser:SetAutoWidthColumn(#ACCTNAME) oMybBrowser:SetAutoWidthColumn(#BASCODE) oMybBrowser:SetAutoWidthColumn(#NOTINUSE) oMybBrowser:Recalculate() This example shows 3 columns in operation but any number will work. I am also sure Joachim could tidy this up better but it is a feature long missing. This code is obviously based on Joachim's source and to be fair to Joachim for those who do not own the source, I have removed some functionality from the method. Anyone who has the source code can re-jig this method themselves. For the others, it will work as long as you are on bBrowser 3 with the restrictions outlined above. No other version will work at all. Have fun. Cheers, Geoff CLASS MybBrowser INHERIT GCSbBrowser PROTECT aAutoWidthColumns AS ARRAY // columns to auto width PROTECT dwAutoCol AS DWORD // iteration manager DECLARE METHOD GetIterativeAutoWidthColumn METHOD AdjustAutoWidthColumn(lRecalculate, lRedraw) CLASS MybBrowser LOCAL lAdjust AS LOGIC LOCAL oColumn AS bBrowserColumn LOCAL otmpColumn AS bBrowserColumn LOCAL iColumn AS INT LOCAL iWidth AS INT LOCAL iWidthMin AS INT LOCAL iWidthMax AS INT LOCAL iWidthTotal AS INT LOCAL lTrySecond AS LOGIC IF SELF:lInAdjustAutoWidthColumn RETURN FALSE ENDIF SELF:lInAdjustAutoWidthColumn := TRUE oColumn := SELF:GetAutoWidthColumn() SELF:ResetAutoWidthColumns() IF oColumn <> NULL_OBJECT iWidthTotal := 0 FOR iColumn := 1 UPTO SELF:iColumnOpenCount otmpColumn := SELF:aoColumnOpen[iColumn] IF otmpColumn <> oColumn iWidthTotal += INT(_CAST, otmpColumn:Width) ENDIF NEXT iWidthMin := INT(_CAST, oColumn:WidthMin) iWidthMax := INT(_CAST, oColumn:WidthMax) iWidth := SELF:srcDataArea.Right - SELF:srcDataArea.Left - iWidthTotal IF iWidth < iWidthMin iWidth := iWidthMin ELSEIF iWidth > iWidthMax iWidth := iWidthMax lTrySecond := TRUE ELSEIF iWidth < BCOLUMNWIDTH_MIN iWidth := BCOLUMNWIDTH_MIN ENDIF IF iWidth <> INT(_CAST, oColumn:Width) oColumn:Width := DWORD(_CAST, iWidth) IF IsNil(lRecalculate) .OR. lRecalculate SELF:Recalculate() ENDIF IF IsNil(lRedraw) .OR. lRedraw iColumn := SELF:GetOpenColumnNo(oColumn) IF iColumn>0 SELF:Redraw(#FromColumn,, iColumn) ENDIF ENDIF lAdjust := TRUE ENDIF IF lTrySecond SELF:IterativeAdjustAutoWidthColumn(lRecalculate, lRedraw) SELF:dwAutoCol := 1 // reset recursion from this point ENDIF ENDIF SELF:lInAdjustAutoWidthColumn := FALSE RETURN lAdjust METHOD GetIterativeAutoWidthColumn() AS OBJECT PASCAL CLASS MybBrowser // modified G Schaller 10/01/2009 to handle multiple widths LOCAL oColumn AS OBJECT LOCAL iColumn AS INT LOCAL uColumn AS USUAL // increment the recursion counter SELF:dwAutoCol += 1 IF SELF:dwAutoCol > ALen(SELF:aAutoWidthColumns) RETURN NULL_OBJECT // end of recursion ENDIF uColumn := SELF:aAutoWidthColumns[SELF:dwAutoCol] IF IsNumeric(uColumn) .AND. uColumn=BCOLUMN_FIRST iColumn := SELF:iFreeze+1 IF iColumn>0 .AND. iColumn<=SELF:iColumnOpenCount .AND. iColumn>=SELF:iFirstColumn .AND. iColumn<=SELF:iLastColumn oColumn := SELF:aoColumnOpen[iColumn] ENDIF ELSEIF IsNumeric(uColumn) .AND. uColumn=BCOLUMN_LAST iColumn := SELF:iColumnOpenCount IF iColumn>0 .AND. iColumn=SELF:iLastColumn oColumn := SELF:aoColumnOpen[iColumn] ENDIF ELSE oColumn := SELF:GetOpenColumn(uColumn) DebugOutput(uColumn, oColumn) ENDIF RETURN oColumn METHOD Init(oOwner, uID, oOrigin, oDimension, kStyle) CLASS MybBrowser SUPER:Init(oOwner, uID, oOrigin, oDimension, kStyle) SELF:aAutoWidthColumns := {} // first assignment will be treated like normal SELF:dwAutoCol := 1 // recursion always starts one position on RETURN SELF METHOD IterativeAdjustAutoWidthColumn(lRecalculate, lRedraw) CLASS MybBrowser LOCAL lAdjust AS LOGIC LOCAL oColumn AS bBrowserColumn LOCAL otmpColumn AS bBrowserColumn LOCAL iColumn AS INT LOCAL iWidth AS INT LOCAL iWidthMin AS INT LOCAL iWidthMax AS INT LOCAL iWidthTotal AS INT LOCAL lTrySecond AS LOGIC oColumn := SELF:GetIterativeAutoWidthColumn() IF oColumn <> NULL_OBJECT iWidthTotal := 0 FOR iColumn := 1 UPTO SELF:iColumnOpenCount otmpColumn := SELF:aoColumnOpen[iColumn] IF otmpColumn <> oColumn iWidthTotal += INT(_CAST, otmpColumn:Width) ENDIF NEXT iWidthMin := INT(_CAST, oColumn:WidthMin) iWidthMax := INT(_CAST, oColumn:WidthMax) iWidth := SELF:srcDataArea.Right - SELF:srcDataArea.Left - iWidthTotal IF iWidthMin <> BCOLUMNWIDTH_AUTO .AND. iWidth < iWidthMin iWidth := iWidthMin ELSEIF iWidthMax <> BCOLUMNWIDTH_AUTO .AND. iWidth > iWidthMax iWidth := iWidthMax lTrySecond := TRUE ELSEIF iWidth < BCOLUMNWIDTH_MIN iWidth := BCOLUMNWIDTH_MIN ENDIF IF iWidth <> INT(_CAST, oColumn:Width) oColumn:Width := DWORD(_CAST, iWidth) IF IsNil(lRecalculate) .OR. lRecalculate SELF:Recalculate() ENDIF IF IsNil(lRedraw) .OR. lRedraw iColumn := SELF:GetOpenColumnNo(oColumn) IF iColumn>0 SELF:Redraw(#FromColumn,, iColumn) ENDIF ENDIF lAdjust := TRUE ENDIF IF lTrySecond SELF:IterativeAdjustAutoWidthColumn(lRecalculate, lRedraw) ENDIF ENDIF // Status zur�ckgeben RETURN lAdjust METHOD ResetAutoWidthColumns() CLASS MybBrowser // reset the autowidth columns to let the auto size adjuster resize in and out LOCAL dwN, dwCount AS DWORD LOCAL oColumn AS bBrowserColumn dwCount := ALen(SELF:aAutoWidthColumns) IF dwCount > 1 FOR dwN := 1 UPTO dwCount oColumn := SELF:GetOpenColumn(SELF:aAutoWidthColumns[dwN]) oColumn:Width := oColumn:WidthMin NEXT ENDIF RETURN NIL METHOD SetAutoWidthColumn (uVal) CLASS MybBrowser // assign this value for consistent behaviour // only the first value is relevant IF Empty(SELF:aAutoWidthColumns) SELF:AutoWidthColumn := uVal ENDIF AAdd(SELF:aAutoWidthColumns, uVal) RETURN NIL
From: Geoff Chambers on 10 Jan 2010 09:21
On Jan 10, 6:06 am, "Geoff Schaller" <geo...(a)softxwareobjectives.com.au> wrote: > Geoff, > > Ok, I've done what you want. Subclass the MybBrowser from your own > subclassed bBrowser of course. A couple of rules: > > 1. The columns must be real fields (not access or expression columns). > 2. You must set a reasonable Width, widthMin and WidthMax on the auto > sized columns. > 3. You can have any number of auto sizing columns but each needs an > appropriate minimum width. > 4. This will not take into account column groups. I have no idea what > the outcome will look like. > 5. You cannot use this on auto-sized columns or columns with size > properties set. > > (Anyone who wishes may adjust my code to solve the issues of point 1, 4 > or 5) > > You use the code like this: > > oMybBrowser:OpenColumn({#ACCT,#ACCTNAME,#MGLTYP,#BASCODE,#NOTINUSE,#U_DATE}) > // set the sizes for each column, for example > // oColumn := oMybBrowser:GetColumn(#ACCTNAME) > // oColumn:Width := 200 > // oColumn:WidthMin := 200 > // oColumn:WidthMax := 300 > oMybBrowser:SetAutoWidthColumn(#ACCTNAME) > oMybBrowser:SetAutoWidthColumn(#BASCODE) > oMybBrowser:SetAutoWidthColumn(#NOTINUSE) > oMybBrowser:Recalculate() > > This example shows 3 columns in operation but any number will work. I am > also sure Joachim could tidy this up better but it is a feature long > missing. This code is obviously based on Joachim's source and to be fair > to Joachim for those who do not own the source, I have removed some > functionality from the method. Anyone who has the source code can re-jig > this method themselves. For the others, it will work as long as you are > on bBrowser 3 with the restrictions outlined above. No other version > will work at all. > > Have fun. > > Cheers, > > Geoff > > CLASS MybBrowser INHERIT GCSbBrowser > > PROTECT aAutoWidthColumns AS ARRAY // columns to auto width > PROTECT dwAutoCol AS DWORD // iteration manager > > DECLARE METHOD GetIterativeAutoWidthColumn > METHOD AdjustAutoWidthColumn(lRecalculate, lRedraw) CLASS MybBrowser > > LOCAL lAdjust AS LOGIC > LOCAL oColumn AS bBrowserColumn > LOCAL otmpColumn AS bBrowserColumn > LOCAL iColumn AS INT > LOCAL iWidth AS INT > LOCAL iWidthMin AS INT > LOCAL iWidthMax AS INT > LOCAL iWidthTotal AS INT > LOCAL lTrySecond AS LOGIC > > IF SELF:lInAdjustAutoWidthColumn > RETURN FALSE > ENDIF > SELF:lInAdjustAutoWidthColumn := TRUE > > oColumn := SELF:GetAutoWidthColumn() > SELF:ResetAutoWidthColumns() > > IF oColumn <> NULL_OBJECT > iWidthTotal := 0 > FOR iColumn := 1 UPTO SELF:iColumnOpenCount > otmpColumn := SELF:aoColumnOpen[iColumn] > IF otmpColumn <> oColumn > iWidthTotal += INT(_CAST, otmpColumn:Width) > ENDIF > NEXT > > iWidthMin := INT(_CAST, oColumn:WidthMin) > iWidthMax := INT(_CAST, oColumn:WidthMax) > > iWidth := SELF:srcDataArea.Right - SELF:srcDataArea.Left - iWidthTotal > IF iWidth < iWidthMin > iWidth := iWidthMin > ELSEIF iWidth > iWidthMax > iWidth := iWidthMax > lTrySecond := TRUE > ELSEIF iWidth < BCOLUMNWIDTH_MIN > iWidth := BCOLUMNWIDTH_MIN > ENDIF > > IF iWidth <> INT(_CAST, oColumn:Width) > oColumn:Width := DWORD(_CAST, iWidth) > > IF IsNil(lRecalculate) .OR. lRecalculate > SELF:Recalculate() > ENDIF > > IF IsNil(lRedraw) .OR. lRedraw > iColumn := SELF:GetOpenColumnNo(oColumn) > IF iColumn>0 > SELF:Redraw(#FromColumn,, iColumn) > ENDIF > ENDIF > > lAdjust := TRUE > ENDIF > > IF lTrySecond > SELF:IterativeAdjustAutoWidthColumn(lRecalculate, lRedraw) > SELF:dwAutoCol := 1 // reset recursion from this point > ENDIF > > ENDIF > > SELF:lInAdjustAutoWidthColumn := FALSE > > RETURN lAdjust > METHOD GetIterativeAutoWidthColumn() AS OBJECT PASCAL CLASS MybBrowser > > // modified G Schaller 10/01/2009 to handle multiple widths > LOCAL oColumn AS OBJECT > LOCAL iColumn AS INT > LOCAL uColumn AS USUAL > > // increment the recursion counter > SELF:dwAutoCol += 1 > IF SELF:dwAutoCol > ALen(SELF:aAutoWidthColumns) > RETURN NULL_OBJECT // end of recursion > ENDIF > > uColumn := SELF:aAutoWidthColumns[SELF:dwAutoCol] > > IF IsNumeric(uColumn) .AND. uColumn=BCOLUMN_FIRST > iColumn := SELF:iFreeze+1 > IF iColumn>0 .AND. iColumn<=SELF:iColumnOpenCount .AND. > iColumn>=SELF:iFirstColumn .AND. iColumn<=SELF:iLastColumn > oColumn := SELF:aoColumnOpen[iColumn] > ENDIF > ELSEIF IsNumeric(uColumn) .AND. uColumn=BCOLUMN_LAST > iColumn := SELF:iColumnOpenCount > IF iColumn>0 .AND. iColumn=SELF:iLastColumn > oColumn := SELF:aoColumnOpen[iColumn] > ENDIF > ELSE > oColumn := SELF:GetOpenColumn(uColumn) > DebugOutput(uColumn, oColumn) > ENDIF > > RETURN oColumn > > METHOD Init(oOwner, uID, oOrigin, oDimension, kStyle) CLASS MybBrowser > > SUPER:Init(oOwner, uID, oOrigin, oDimension, kStyle) > > SELF:aAutoWidthColumns := {} // first assignment will be treated like > normal > SELF:dwAutoCol := 1 // recursion always starts one position on > > RETURN SELF > METHOD IterativeAdjustAutoWidthColumn(lRecalculate, lRedraw) CLASS > MybBrowser > > LOCAL lAdjust AS LOGIC > LOCAL oColumn AS bBrowserColumn > LOCAL otmpColumn AS bBrowserColumn > LOCAL iColumn AS INT > LOCAL iWidth AS INT > LOCAL iWidthMin AS INT > LOCAL iWidthMax AS INT > LOCAL iWidthTotal AS INT > LOCAL lTrySecond AS LOGIC > > oColumn := SELF:GetIterativeAutoWidthColumn() > > IF oColumn <> NULL_OBJECT > iWidthTotal := 0 > FOR iColumn := 1 UPTO SELF:iColumnOpenCount > otmpColumn := SELF:aoColumnOpen[iColumn] > IF otmpColumn <> oColumn > iWidthTotal += INT(_CAST, otmpColumn:Width) > ENDIF > NEXT > > iWidthMin := INT(_CAST, oColumn:WidthMin) > iWidthMax := INT(_CAST, oColumn:WidthMax) > > iWidth := SELF:srcDataArea.Right - SELF:srcDataArea.Left - iWidthTotal > IF iWidthMin <> BCOLUMNWIDTH_AUTO .AND. iWidth < iWidthMin > iWidth := iWidthMin > ELSEIF iWidthMax <> BCOLUMNWIDTH_AUTO .AND. iWidth > iWidthMax > iWidth := iWidthMax > lTrySecond := TRUE > ELSEIF iWidth < BCOLUMNWIDTH_MIN > iWidth := BCOLUMNWIDTH_MIN > ENDIF > > IF iWidth <> INT(_CAST, oColumn:Width) > oColumn:Width := DWORD(_CAST, iWidth) > > IF IsNil(lRecalculate) .OR. lRecalculate > SELF:Recalculate() > ENDIF > > IF IsNil(lRedraw) .OR. lRedraw > iColumn := SELF:GetOpenColumnNo(oColumn) > IF iColumn>0 > SELF:Redraw(#FromColumn,, iColumn) > ENDIF > ENDIF > > lAdjust := TRUE > ENDIF > > IF lTrySecond > SELF:IterativeAdjustAutoWidthColumn(lRecalculate, lRedraw) > ENDIF > > ENDIF > > // Status zur�ckgeben > RETURN lAdjust > > METHOD ResetAutoWidthColumns() CLASS MybBrowser > > // reset the autowidth columns to let the auto size adjuster resize in > and out > LOCAL dwN, dwCount AS DWORD > LOCAL oColumn AS bBrowserColumn > > dwCount := ALen(SELF:aAutoWidthColumns) > IF dwCount > 1 > FOR dwN := 1 UPTO dwCount > oColumn := SELF:GetOpenColumn(SELF:aAutoWidthColumns[dwN]) > oColumn:Width := oColumn:WidthMin > NEXT > ENDIF > > RETURN NIL > METHOD SetAutoWidthColumn (uVal) CLASS MybBrowser > > // assign this value for consistent behaviour > // only the first value is relevant > IF Empty(SELF:aAutoWidthColumns) > SELF:AutoWidthColumn := uVal > ENDIF > > AAdd(SELF:aAutoWidthColumns, uVal) > > RETURN NIL It works great, I'll keep you advised if I run into any problems. I do have a couple of Group columns, I'll try it on them and see what happens. One thing I noticed though, I programed all of my BuildBrowsers on Self:bBrowser from your class GCSbBrowser, I had to change the code to Self:oDCBrowser since Self:bBrowser inherits from GCSBrowser. |