Next: Belgium Eid
From: Mathias H?kansson on 27 Sep 2005 02:08 I just set auBVField in the init method of my datawindow (in an inherited class). self:RestoreDataColumnPositionsAndSizes() restores the columns as they were when the user closed the window last time. The columns and widths are saved in the registry and the user can select which columns to show in a dialog. This is from the fieldchoice sample. Mathias ------------------- method Init(oWindow,iCtlID,oServer,uExtra) class WinValjForetagGamla super:Init(oWindow,iCtlID,oServer,uExtra) self:auBVField := {#FTGNR,#FTGNAMN,#POSTADR,#GATUADR,#POSTNR,#ORT,#TEL,#FAX,#EPOST,; #HEMSIDA} self:browser:KeyCommand:Add(bKeyCommand{KEYENTER,,,,,self,#Valjforetag}) self:browser:currentmode := #LINE self:browser:grid := bGrid{BGRID_NONE,2,2,2,2} self:browser:rowheight := 20 self:browser:editable := false self:browser:RowCountMode := #KeyCount self:lSaveDataColumnPositionsAndSizes := true self:RestoreDataColumnPositionsAndSizes() self:lsavewindowsize := true self:RestoreWindowSize() "Jozo" <racunalo(a)os.t-com.hr> skrev i meddelandet news:dh889o$fij$1(a)ss405.t-com.hr... > 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 >> >> >
From: Jozo on 27 Sep 2005 04:10
This is another option from a lot of options that offers Joachim in his examples. I will to consider it. Jozo "Mathias H?kansson" <mathias.hakansson.pleaseremoveme(a)tendata.se> wrote in message news:2CB548447D0676479854FF9377F06BD2D2BD0F(a)SETUBAL... >I just set auBVField in the init method of my datawindow (in an inherited >class). self:RestoreDataColumnPositionsAndSizes() restores the columns as >they were when the user closed the window last time. The columns and widths >are saved in the registry and the user can select which columns to show in >a dialog. This is from the fieldchoice sample. > > Mathias > > > ------------------- > method Init(oWindow,iCtlID,oServer,uExtra) class WinValjForetagGamla > super:Init(oWindow,iCtlID,oServer,uExtra) > > self:auBVField := > {#FTGNR,#FTGNAMN,#POSTADR,#GATUADR,#POSTNR,#ORT,#TEL,#FAX,#EPOST,; > #HEMSIDA} > > self:browser:KeyCommand:Add(bKeyCommand{KEYENTER,,,,,self,#Valjforetag}) > self:browser:currentmode := #LINE > self:browser:grid := bGrid{BGRID_NONE,2,2,2,2} > self:browser:rowheight := 20 > self:browser:editable := false > self:browser:RowCountMode := #KeyCount > > self:lSaveDataColumnPositionsAndSizes := true > self:RestoreDataColumnPositionsAndSizes() > self:lsavewindowsize := true > self:RestoreWindowSize() > > > "Jozo" <racunalo(a)os.t-com.hr> skrev i meddelandet > news:dh889o$fij$1(a)ss405.t-com.hr... >> 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 >>> >>> >> > > |