Next: Belgium Eid
From: Jozo on 22 Sep 2005 13:39 Hi all ! Has anybody tried work with this example, totally to replace VO DataBrowser (conception View as Table/Form) with bBrowser ? When yes, I would to change experience. Jozo
From: Geoff Schaller on 23 Sep 2005 23:49 Jozo, But that's what you do if you move to bbrowser. Unfortunately you have some re-writing to do because bbrowser is a control and does not require the subdatawindow. There is now one-for-one replacement possible. Do it! You won't regret the effort. Geoff "Jozo" <racunalo(a)os.t-com.hr> wrote in message news:dguq8q$2iq$1(a)ss405.t-com.hr: > Hi all ! > > Has anybody tried work with this example, totally to replace VO DataBrowser > (conception View as Table/Form) with bBrowser ? > When yes, I would to change experience. > > Jozo
From: Jozo on 24 Sep 2005 05:19 Geof, You haven't understood me well maybe. I use bBrowser. My problem is that I use very often (acctualy mostly) in my applications conception Databrowser. This conception is embedded (built) in the WED. So, if you understand me, I create in the WED, for example, datawindow that has form (created with Auto Layout) only with singlelineedits, and browser created with WED pushbutton Browse/Form View. The conception of my applications lies on this conception. All singlelineedits are disabled because I use them only for preview (non editable). The browser is non editable too. I use this conception only for navigation, selection record that I want to process. In the menu of this window I have classical options (Top, Bottom, Next, Previous, New, Change, Delete, Browser, Form, Seek, Print). The bBrowser is control that we put in window like other controls (SLE-s, pushbuttons, fixedtexts ...). To get what I want, I have to change behavior of datawindow and browser. Joachim have created the example (from Subject of this reply) for it. I have remaked this example and added two options, sort marker and sensitive search, but like that what I want. I have got one unusual error that was nightmare for me. For this reason I asked twice. First time, Dave replied what I have known already, but I wanted be undoubted. By the way, I wrote correct code but one command was problematic (SetCurrentColumn). Fortunately, I have solved this error. Terefore I wanted to change experience about. If you want I can to send this example. The example is very interesting. Jozo "Geoff Schaller" <geoff(a)nospam.softwareobjectives.com.au> wrote in message news:4334cbd8$1(a)dnews.tpgi.com.au... > Jozo, > > But that's what you do if you move to bbrowser. Unfortunately you have > some re-writing to do because bbrowser is a control and does not require > the subdatawindow. There is now one-for-one replacement possible. > > Do it! You won't regret the effort. > > Geoff > > > "Jozo" <racunalo(a)os.t-com.hr> wrote in message > news:dguq8q$2iq$1(a)ss405.t-com.hr: > >> Hi all ! >> >> Has anybody tried work with this example, totally to replace VO >> DataBrowser >> (conception View as Table/Form) with bBrowser ? >> When yes, I would to change experience. >> >> Jozo >
From: Mathias H?kansson on 26 Sep 2005 02:38 Yes! Works very well. Mathias class bDataBrowser inherit bBrowser // implements the interface of DataWindow:ViewAs(...) method __AutoResize() class bDataBrowser // resize browser local oArea as BoundingBox // adjust browser to size of window if IsAccess(self:Owner, #__FormWindow) oArea := self:Owner:__FormWindow:CanvasArea else oArea := self:Owner:CanvasArea endif SetWindowPos(self:Handle(), NULL_PTR, 0, 0, oArea:Width, oArea:Height, SWP_NOZORDER) return true method __NotifyChanges(iNotify) class bDataBrowser // notification to a change if iNotify=GBNFY_VIEWASBROWSER self:Show() self:SetFocus() elseif iNotify=GBNFY_VIEWASFORM self:Hide() endif return true method __RefreshData() class bDataBrowser // refresh data return true method __RefreshField(uField) class bDataBrowser // refresh field return true method __StatusOK() class bDataBrowser // check data if self:InEdit() .and. !self:EditClose() return self:aoColumnOpen[self:oEditCell:Column] else return NULL_OBJECT endif method Init(oOwner, uID, oOrigin, oDimension, kStyle) class bDataBrowser // initialize browser if PCount()<>1 super:Init(oOwner, uID, oOrigin, oDimension, kStyle) else if IsInstanceOf(oOwner, #DataWindow) .or. IsInstanceOf(oOwner, #DataDialog) super:Init(oOwner:__FormWindow, 1000, Point{0, 0}, Dimension{0, 0}, WS_CHILD+WS_TABSTOP) self:CommandOwner := oOwner else super:Init(oOwner, 1000, Point{0, 0}, Dimension{0, 0}, WS_CHILD+WS_TABSTOP) endif self:Editable := true endif self:autoclose := #OnlyWhenLastClient class bDataWindow inherit DataWindow // variables protect auBVField as array protect auBVFieldOpen as array method __AutoCreateBrowser() as DataWindow pascal class bDataWindow // create and initialize browser if IsNil(self:oGBrowse) self:oGBrowse := CreateInstance(self:symBrowserClass, self) endif if self:sCurrentView=#ViewSwitch Send(self:oGBrowse, #__NOTIFYChanges, GBNFY_VIEWSWITCH) elseif self:sCurrentView=#BrowseView Send(self:oGBrowse, #__NOTIFYChanges, GBNFY_VIEWASBROWSER) elseif self:sCurrentView=#FormView Send(self:oGBrowse ,#__NOTIFYChanges, GBNFY_VIEWASFORM) endif if self:lLinked .and. IsInstanceOfUsual(self:oAttachedServer, #DataServer) if IsAccess(self:oGBrowse, #Server) .and. IsMethod(self:oGBrowse, #Use) if IVarGet(self:oGBrowse, #Server)<>self:oAttachedServer self:BrowseViewInit(self:oAttachedServer) endif endif endif return self method __UpdateCurrent() as DataWindow pascal class bDataWindow local uColumn as usual if self:sCurrentView<>#BrowseView super:__UpdateCurrent() elseif IsAccess(self:oGBrowse, #CurrentColumn) uColumn := IVarGet(self:oGBrowse, #CurrentColumn) if (IsInstanceOfUsual(uColumn, #DataColumn) .and. uColumn:Modified) self:__DoValidate(uColumn) endif endif return self access BrowserFieldList class bDataWindow // return field list of browser return self:auBVField assign BrowserFieldList(auField) class bDataWindow // set field list of browser self:auBVField := auField return auField access BrowserFieldOpenList class bDataWindow // return open field list of browser return self:auBVFieldOpen assign BrowserFieldOpenList(auField) class bDataWindow // set open field list of browser self:auBVFieldOpen := auField return auField method BrowseViewInit(oServer) class bDataWindow // initialize browser local uFieldList as usual local uFieldOpenList as usual // initialize browser if IsInstanceOf(self:oGBrowse, #bBrowser) if self:auBVField<>NULL_ARRAY uFieldList := self:auBVField endif if self:auBVFieldOpen<>NULL_ARRAY uFieldOpenList := self:auBVFieldOpen endif Send(self:oGBrowse, #Use, self:oAttachedServer, uFieldList, uFieldOpenList) else Send(self:oGBrowse, #Use, self:oAttachedServer) endif return true method Init(oOwner, oSource, nResourceID) class bDataWindow // initialize window super:Init(oOwner, oSource, nResourceID) self:BrowserClass := #bDataBrowser return self method ContextMenuShow(oEvent) class bDataBrowser // Context-Men? anzeigen local omnuContext as Menu local sptMouse is _winPoint local srcArea is _winRect local oColumn as bDataColumn local iColumn as int local lSuccess as logic local hmenu as ptr if dword(_cast, oEvent:LParam)=0xffffffff if Between(self:iCurrentColumn, 1, self:iColumnOpenCount) oColumn := self:aoColumnOpen[self:iCurrentColumn] endif omnuContext := self:GetColumnContextMenu(#Data, oColumn) lSuccess := self:GetCellRect(self:iCurrentColumn, self:iCurrentRow,self:server:recno,@srcArea) sptMouse.X := srcArea.Left+10 sptMouse.Y := srcArea.Top+10 ClientToScreen(self:Handle(), @sptMouse) else sptMouse.X := LoWord(oEvent:LParam) sptMouse.Y := HiWord(oEvent:LParam) ScreenToClient(self:Handle(), @sptMouse) iColumn := self:GetColumnToPoint(Point{sptMouse.X, sptMouse.Y}) if iColumn>0 oColumn := self:aoColumnOpen[iColumn] elseif Between(self:iCurrentColumn, 1, self:iColumnOpenCount) oColumn := self:aoColumnOpen[self:iCurrentColumn] endif omnuContext := self:GetColumnContextMenu(#Data, oColumn) endif // ContextMenu vorhanden if omnuContext<>NULL_OBJECT // Context-Men? anzeigen self:lContextMenuVisible := true self:oContextMenuVisible := omnuContext hmenu := omnuContext:Handle() hmenu := GetSubMenu(hMenu,1) if dword(_cast, oEvent:LParam)=0xffffffff lSuccess := TrackPopupMenu(hmenu,TPM_LEFTALIGN,sptMouse.X,sptMouse.Y,0,self:Handle(),NULL_PTR) else lSuccess := TrackPopupMenu(hmenu,TPM_LEFTALIGN,LoWord(oEvent:LParam),HiWord(oEvent:LParam),0,self:Handle(),NULL_PTR) endif if !lSuccess self:oContextMenuVisible := NULL_OBJECT endif self:lContextMenuVisible := false return ISEXECUTED endif "Jozo" <racunalo(a)os.t-com.hr> skrev i meddelandet news:dguq8q$2iq$1(a)ss405.t-com.hr... > Hi all ! > > Has anybody tried work with this example, totally to replace VO > DataBrowser (conception View as Table/Form) with bBrowser ? > When yes, I would to change experience. > > Jozo
From: Jozo on 26 Sep 2005 03:34
Hello Mathias ! That is basic example. If you choose columns that you want than you have to add, for example, next code in method dtwMyViews:BrowseViewInit: SELF:auBVField := { #ID, #FIRSTNAME, #LASTNAME, #CITY, #STATE} SELF:auBVFieldOpen := { #ID, #FIRSTNAME, #LASTNAME, #CITY, #STATE} SELF:auBVFieldFormat := { "ID number", "Firstname", "Lastname", "City", "State"} But, when we choose SELF:ViewAs(#TableView), then browser shows all columns and not that we have chosen (in BrowseViewInit). Therefore Joachim sent new code. He had to implement only the method Use() in the 2 classes bDataWindow and bDataDialog. METHOD Use(oServer) CLASS bDataWindow // activate server in window IF SELF:sCurrentView = #BrowseView IF SELF:oGBrowse <> NULL_OBJECT SELF:oGBrowse:Destroy() SELF:oGBrowse := NULL_OBJECT ENDIF ENDIF RETURN SUPER:Use(oServer) And furthermore I had implement new code, sort marker and sensitive search but not like Joachim in his examples SortMarker and Sensitive search. I work only with cdx and I seek in columns that have attached indexes. (CUST.dbf and CUST.cdx) METHOD CaptionClick(oEvent) CLASS bDataWindow SELF:Browser:ChangeColumnOrder(oEvent:Column) RETURN NIL CLASS bDataBrowser INHERIT bBrowser // implements the interface of DataWindow:ViewAs(...) // My code PROTECT INSTANCE cSeek := "" AS STRING PROTECT INSTANCE iColumnOrder := 0 AS INT PROTECT INSTANCE aOrders := {} AS ARRAY METHOD ChangeColumnOrder(oClickedColumn) CLASS bDataBrowser LOCAL oCol AS bDataColumn LOCAL iCurCol AS INT , i AS INT IF SELF:iColumnOrder = 0 RETURN NIL ENDIF iCurCol := SELF:GetOpenColumnNo(oClickedColumn) FOR i=1 TO ALen(SELF:aOrders) IF SELF:aOrders[i][1] == iCurCol EXIT ENDIF NEXT i IF iCurCol > 0 .and. i <= ALen(SELF:aOrders) // Reset old order oCol := SELF:GetOpenColumn(SELF:iColumnOrder) oCol:Foreground := Color{0, 0, 0} // Set new order oClickedColumn:Foreground := Color{0, 0, 255} SELF:iColumnOrder := iCurCol SELF:Server:SetOrder( SELF:aOrders[i][2] ) SELF:Refresh() ENDIF RETURN NIL METHOD Dispatch( oEvent ) CLASS bDataBrowser LOCAL uValue AS USUAL IF oEvent:uMsg=WM_CHAR uValue := SELF:GetOpenColumn(SELF:iColumnOrder):Value DO CASE CASE oEvent:wParam == 27 Infobox{, "Escape key pressed !"}:Show() SELF:Owner:Owner:EndWindow() CASE oEvent:wParam == 13 Infobox{, "Enter key pressed !"}:Show() CASE oEvent:WParam >=32 // SELF:SuspendNotification() SELF:cSeek := SELF:cSeek+CHR(oEvent:WParam) SELF:Owner:Owner:StatusBar:SetText(SELF:cSeek,#sSeek) SELF:Server:Seek(Iif(IsNumeric(uValue),Val(cSeek), Iif(IsDate(uValue), CToD(cSeek), cSeek ))) SELF:Refresh() // SELF:ResetNotification() CASE oEvent:WParam = 8 IF !SELF:cSeek == "" SELF:cSeek := Left(SELF:cSeek,Len(SELF:cSeek)-1) SELF:Owner:Owner:StatusBar:SetText(SELF:cSeek,#sSeek) // SELF:SuspendNotification() SELF:Server:Seek(Iif(IsNumeric(uValue),Val(cSeek), Iif(IsDate(uValue), CToD(cSeek), cSeek ))) SELF:Refresh() // SELF:ResetNotification() ENDIF ENDCASE ENDIF RETURN SUPER:Dispatch(oEvent) // run as usual METHOD SetBrowserOrder( oCol, cIndexOrder, lInitialOrder ) CLASS bDataBrowser LOCAL ocvCaption AS bCompoundValue LOCAL iColumnNo AS INT iColumnNo := SELF:GetOpenColumnNo(oCol) ocvCaption := bCompoundValue{bIcon{ArrowDown{}, 10},,,BALIGN_LEFT} ocvCaption:AddValue(bCompoundValue{oCol:Caption, Point{12, 0}}) oCol:Caption := ocvCaption IF lInitialOrder oCol:Foreground := Color{0, 0, 255} SELF:iColumnOrder := iColumnNo // SELF:SetCurrentColumn( iColumnNo ) SELF:Server:SetOrder(cIndexOrder) ENDIF AAdd(aOrders, {iColumnNo, cIndexOrder} ) RETURN SELF and at the and in dtwMyViews:BrowseViewInit for example: .... oColumn := SELF:Browser:GetOpenColumn(#ID) IF !Empty(oColumn) SELF:Browser:SetBrowserOrder(oColumn, "ID", FALSE ) ENDIF oColumn := SELF:Browser:GetOpenColumn(#LASTNAME) IF !Empty(oColumn) SELF:Browser:SetBrowserOrder(oColumn, "LASTNAME", TRUE ) ENDIF oColumn := SELF:Browser:GetOpenColumn(#CITY) IF !Empty(oColumn) SELF:Browser:SetBrowserOrder(oColumn, "CITY", FALSE ) ENDIF SELF:Browser:Server:GoTop() .... Jozo "Mathias H?kansson" <mathias.hakansson.pleaseremoveme(a)tendata.se> wrote in message news:2CB548447D0676479854FF9377F06BD2C6EE07(a)SETUBAL... > Yes! > > Works very well. > > Mathias > > > class bDataBrowser inherit bBrowser > // implements the interface of DataWindow:ViewAs(...) > method __AutoResize() class bDataBrowser > // resize browser > local oArea as BoundingBox > > // adjust browser to size of window > if IsAccess(self:Owner, #__FormWindow) > oArea := self:Owner:__FormWindow:CanvasArea > else > oArea := self:Owner:CanvasArea > endif > SetWindowPos(self:Handle(), NULL_PTR, 0, 0, oArea:Width, oArea:Height, > SWP_NOZORDER) > return true > > method __NotifyChanges(iNotify) class bDataBrowser > // notification to a change > if iNotify=GBNFY_VIEWASBROWSER > self:Show() > self:SetFocus() > elseif iNotify=GBNFY_VIEWASFORM > self:Hide() > endif > return true > > method __RefreshData() class bDataBrowser > // refresh data > return true > > method __RefreshField(uField) class bDataBrowser > // refresh field > return true > > method __StatusOK() class bDataBrowser > // check data > if self:InEdit() .and. !self:EditClose() > return self:aoColumnOpen[self:oEditCell:Column] > else > return NULL_OBJECT > endif > > method Init(oOwner, uID, oOrigin, oDimension, kStyle) class bDataBrowser > // initialize browser > if PCount()<>1 > super:Init(oOwner, uID, oOrigin, oDimension, kStyle) > else > if IsInstanceOf(oOwner, #DataWindow) .or. IsInstanceOf(oOwner, > #DataDialog) > super:Init(oOwner:__FormWindow, 1000, Point{0, 0}, Dimension{0, 0}, > WS_CHILD+WS_TABSTOP) > self:CommandOwner := oOwner > else > super:Init(oOwner, 1000, Point{0, 0}, Dimension{0, 0}, > WS_CHILD+WS_TABSTOP) > endif > self:Editable := true > endif > > self:autoclose := #OnlyWhenLastClient > class bDataWindow inherit DataWindow > // variables > protect auBVField as array > protect auBVFieldOpen as array > > method __AutoCreateBrowser() as DataWindow pascal class bDataWindow > // create and initialize browser > if IsNil(self:oGBrowse) > self:oGBrowse := CreateInstance(self:symBrowserClass, self) > endif > > if self:sCurrentView=#ViewSwitch > Send(self:oGBrowse, #__NOTIFYChanges, GBNFY_VIEWSWITCH) > elseif self:sCurrentView=#BrowseView > Send(self:oGBrowse, #__NOTIFYChanges, GBNFY_VIEWASBROWSER) > elseif self:sCurrentView=#FormView > Send(self:oGBrowse ,#__NOTIFYChanges, GBNFY_VIEWASFORM) > endif > > if self:lLinked .and. IsInstanceOfUsual(self:oAttachedServer, #DataServer) > if IsAccess(self:oGBrowse, #Server) .and. IsMethod(self:oGBrowse, #Use) > if IVarGet(self:oGBrowse, #Server)<>self:oAttachedServer > self:BrowseViewInit(self:oAttachedServer) > endif > endif > endif > > return self > > method __UpdateCurrent() as DataWindow pascal class bDataWindow > local uColumn as usual > > if self:sCurrentView<>#BrowseView > super:__UpdateCurrent() > elseif IsAccess(self:oGBrowse, #CurrentColumn) > uColumn := IVarGet(self:oGBrowse, #CurrentColumn) > if (IsInstanceOfUsual(uColumn, #DataColumn) .and. uColumn:Modified) > self:__DoValidate(uColumn) > endif > endif > return self > > access BrowserFieldList class bDataWindow > // return field list of browser > return self:auBVField > > assign BrowserFieldList(auField) class bDataWindow > // set field list of browser > self:auBVField := auField > return auField > > access BrowserFieldOpenList class bDataWindow > // return open field list of browser > return self:auBVFieldOpen > > assign BrowserFieldOpenList(auField) class bDataWindow > // set open field list of browser > self:auBVFieldOpen := auField > return auField > > method BrowseViewInit(oServer) class bDataWindow > // initialize browser > local uFieldList as usual > local uFieldOpenList as usual > > // initialize browser > if IsInstanceOf(self:oGBrowse, #bBrowser) > if self:auBVField<>NULL_ARRAY > uFieldList := self:auBVField > endif > if self:auBVFieldOpen<>NULL_ARRAY > uFieldOpenList := self:auBVFieldOpen > endif > Send(self:oGBrowse, #Use, self:oAttachedServer, uFieldList, > uFieldOpenList) > else > Send(self:oGBrowse, #Use, self:oAttachedServer) > endif > return true > > method Init(oOwner, oSource, nResourceID) class bDataWindow > // initialize window > super:Init(oOwner, oSource, nResourceID) > self:BrowserClass := #bDataBrowser > > return self > > method ContextMenuShow(oEvent) class bDataBrowser > // Context-Men? anzeigen > local omnuContext as Menu > local sptMouse is _winPoint > local srcArea is _winRect > local oColumn as bDataColumn > local iColumn as int > local lSuccess as logic > local hmenu as ptr > > if dword(_cast, oEvent:LParam)=0xffffffff > if Between(self:iCurrentColumn, 1, self:iColumnOpenCount) > oColumn := self:aoColumnOpen[self:iCurrentColumn] > endif > > omnuContext := self:GetColumnContextMenu(#Data, oColumn) > > lSuccess := self:GetCellRect(self:iCurrentColumn, > self:iCurrentRow,self:server:recno,@srcArea) > sptMouse.X := srcArea.Left+10 > sptMouse.Y := srcArea.Top+10 > ClientToScreen(self:Handle(), @sptMouse) > else > sptMouse.X := LoWord(oEvent:LParam) > sptMouse.Y := HiWord(oEvent:LParam) > ScreenToClient(self:Handle(), @sptMouse) > > iColumn := self:GetColumnToPoint(Point{sptMouse.X, sptMouse.Y}) > if iColumn>0 > oColumn := self:aoColumnOpen[iColumn] > elseif Between(self:iCurrentColumn, 1, self:iColumnOpenCount) > oColumn := self:aoColumnOpen[self:iCurrentColumn] > endif > > omnuContext := self:GetColumnContextMenu(#Data, oColumn) > endif > > // ContextMenu vorhanden > if omnuContext<>NULL_OBJECT > // Context-Men? anzeigen > self:lContextMenuVisible := true > self:oContextMenuVisible := omnuContext > > hmenu := omnuContext:Handle() > hmenu := GetSubMenu(hMenu,1) > if dword(_cast, oEvent:LParam)=0xffffffff > lSuccess := > TrackPopupMenu(hmenu,TPM_LEFTALIGN,sptMouse.X,sptMouse.Y,0,self:Handle(),NULL_PTR) > else > lSuccess := > TrackPopupMenu(hmenu,TPM_LEFTALIGN,LoWord(oEvent:LParam),HiWord(oEvent:LParam),0,self:Handle(),NULL_PTR) > endif > > if !lSuccess > self:oContextMenuVisible := NULL_OBJECT > endif > self:lContextMenuVisible := false > return ISEXECUTED > endif > > > "Jozo" <racunalo(a)os.t-com.hr> skrev i meddelandet > news:dguq8q$2iq$1(a)ss405.t-com.hr... >> Hi all ! >> >> Has anybody tried work with this example, totally to replace VO >> DataBrowser (conception View as Table/Form) with bBrowser ? >> When yes, I would to change experience. >> >> Jozo > > |