| **Navigation:**  [[abc library reference.htm|ABC Library Reference]] > ToolbarUpdateClass >====== ToolbarUpdateClass Overview {{c6h0009.jpg|C6H0009.jpg}} ====== | [[toolbarupdateclass.htm|{{btn_prev_n.gif|Previous page}}]][[abc library reference.htm|{{btn_home_n.gif|Return to chapter overview}}]][[toolbarupdateclass properties.htm|{{btn_next_n.gif|Next page}}]] | | || The ToolbarUpdateClass is a ToolbarTarget that handles events for a template generated Form Procedure that is called from a template generated Browse Procedure. See //Procedure Templates--[[tplcontrolbrowsebox.htm|Browse]] //and [[tplcontrolsavebutton.htm|Form]] for more information. **ToolbarUpdateClass Concepts** ToolbarUpdateClass objects implement the event handling specific to a template generated Form Procedure. The Form specific events are primarily the event to complete the Form and save the record (EVENT:Accepted for an OK button). There may be zero or several ToolbarTarget objects within a procedure; however, //only one is active// at a time. **ToolbarUpdateClass Relationship to Other Application Builder Classes** The ToolbarUpdateClass is derived from the ToolbarTarget class. The ToolbarClass keeps a list of ToolbarTarget objects (including ToolbarUpdateClass objects) so it can forward events and method calls to a particular target. **ToolbarUpdateClass ABC Template Implementation** The FormVCRControls extension template generates code to declare a ToolbarUpdateClass object called ToolbarForm, and to register the ToolbarForm object with the procedure's WindowManager. Once the ToolbarForm is registered with the WindowManager, the WindowManager handles the interaction between the ToolbarClass object and the ToolbarUpdateClass object with no other references in the template generated code. You can use the FormVCRControl template's prompts to derive from the ToolbarUpdateClass. The templates provide the derived class so you can modify the ToolBarForm's behavior on an instance-by-instance basis. **ToolbarUpdateClass Source Files** The ToolbarUpdateClass source code is installed by default to the Clarion \LIBSRC folder. The ToolbarUpdateClass source code and its respective components are: | | ABTOOLBA.INC | ToolbarUpdateClass declarations | | | ABTOOLBA.CLW | ToolbarUpdateClass method definitions | **ToolbarUpdateClass Conceptual Example** The following example shows a typical sequence of statements to declare, instantiate, initialize, use, and terminate a ToolbarClass object and related ToolbarTarget (ToolbarUpdateClass and ToolbarListboxClass) objects. This example uses a global toolbar to drive a BrowseClass LIST, its child Form procedure, and the Form procedure's secondary BrowseClass LIST. The program POSTs toolbar events to the active MDI window using the SYSTEM{Prop:Active} property. Then the local ToolbarClass object calls on the active ToolbarTarget object to handle the event. ** PROGRAM** **_ABCDllMode_  EQUATE(0)** **_ABCLinkMode_ EQUATE(1)** ** INCLUDE('ABERROR.INC')** ** INCLUDE('ABFILE.INC')** ** INCLUDE('ABWINDOW.INC')** ** INCLUDE('ABBROWSE.INC')** ** INCLUDE('ABTOOLBA.INC')** ** INCLUDE('KEYCODES.CLW')** ** MAP** **Main            PROCEDURE                !contains global toolbar** **BrowseCustomers PROCEDURE                !template generated Browse** **UpdateCustomer  PROCEDURE                !template generated Form** ** END** **GlobalErrors  ErrorClass** **Access:Customer CLASS(FileManager)** **Init             PROCEDURE** **                END** **Relate:Customer CLASS(RelationManager)** **Init             PROCEDURE** **Kill             PROCEDURE,VIRTUAL** **                END** **Access:Orders  CLASS(FileManager)** **Init            PROCEDURE** **               END** **Relate:Orders  CLASS(RelationManager)** **Init            PROCEDURE** **Kill            PROCEDURE,VIRTUAL** **               END** **GlobalRequest  BYTE(0),THREAD** **GlobalResponse BYTE(0),THREAD** **VCRRequest     LONG(0),THREAD** **Customer    FILE,DRIVER('TOPSPEED'),PRE(CUS),CREATE,BINDABLE,THREAD** **KeyCustNumber KEY(CUS:CustNumber),NOCASE,OPT** **KeyCompany    KEY(CUS:Company),DUP,NOCASE** **Record        RECORD,PRE()** **CustNumber     LONG** **Company        STRING(20)** **ZipCode        LONG** **              END** **            END** **Orders     FILE,DRIVER('TOPSPEED'),PRE(ORD),CREATE,BINDABLE,THREAD** **KeyOrderNumber KEY(ORD:OrderNumber),NOCASE,OPT,PRIMARY** **KeyCustNumber  KEY(ORD:CustNumber),DUP,NOCASE,OPT** **Record         RECORD,PRE()** **CustNumber      LONG** **OrderNumber     SHORT** **InvoiceAmount   DECIMAL(7,2)** **               END** **           END** ** CODE** ** GlobalErrors.Init** ** Relate:Customer.Init** ** Relate:Orders.Init** ** Main                          !run Application Frame w/ toolbar** ** Relate:Customer.Kill** ** Relate:Orders.Kill** ** GlobalErrors.Kill** **Main PROCEDURE                 !Application Frame w/ toolbar** **Frame APPLICATION('Application'),AT(,,310,210),SYSTEM,MAX,RESIZE,IMM** **    MENUBAR** **     ITEM('Browse Customers'),USE(?BrowseCustomers)** **    END** **    TOOLBAR,AT(0,0,,20)        !must use toolbar EQUATEs** **   BUTTON,AT(4,4),USE(?Toolbar:Top,Toolbar:Top),DISABLE,ICON('VCRFIRST.ICO')** **   BUTTON,AT(16,4),USE(?Toolbar:PageUp,Toolbar:PageUp),DISABLE,ICON('VCRPRIOR.ICO')** **   BUTTON,AT(28,4),USE(?Toolbar:Up,Toolbar:Up),DISABLE,ICON('VCRUP.ICO')** **   BUTTON,AT(40,4),USE(?Toolbar:Down,Toolbar:Down),DISABLE,ICON('VCRDOWN.ICO')** **   BUTTON,AT(52,4),USE(?Toolbar:PageDown,Toolbar:PageDown),DISABLE,ICON('VCRNEXT.ICO')** **   BUTTON,AT(64,4),USE(?Toolbar:Bottom,Toolbar:Bottom),DISABLE,ICON('VCRLAST.ICO')** **   BUTTON,AT(96,4),USE(?Toolbar:Insert,Toolbar:Insert),DISABLE,ICON('INSERT.ICO')** **   BUTTON,AT(108,4),USE(?Toolbar:Change,Toolbar:Change),DISABLE,ICON('EDIT.ICO')** **   BUTTON,AT(121,4),USE(?Toolbar:Delete,Toolbar:Delete),DISABLE,ICON('DELETE.ICO')** **    END** **   END** **FrameWindow CLASS(WindowManager)** **Init         PROCEDURE(),BYTE,PROC,VIRTUAL** **TakeAccepted PROCEDURE(),BYTE,PROC,VIRTUAL** **            END** ** CODE** ** FrameWindow.Run()** **FrameWindow.Init PROCEDURE()** **ReturnValue    BYTE,AUTO** ** CODE** ** ReturnValue = PARENT.Init()** ** SELF.FirstField = 1** ** OPEN(Frame)** ** SELF.Opened=True** ** RETURN ReturnValue** **FrameWindow.TakeAccepted PROCEDURE()** ** CODE** ** CASE ACCEPTED()** ** OF Toolbar:First TO Toolbar:Last         !post toolbar event to active thread** **  POST(EVENT:Accepted,ACCEPTED(),SYSTEM{Prop:Active})** **  RETURN Level:Notify** ** OF ?BrowseCustomers** **  START(BrowseCustomers,25000)            !start BrowseCustomers procedure/thread** ** END** ** RETURN PARENT.TakeAccepted()** **BrowseCustomers PROCEDURE                 !template generated Browse** **CustView  VIEW(Customer)** **          END** **CustQ      QUEUE** **CUS:CustNumber LIKE(CUS:CustNumber)** **CUS:Company    LIKE(CUS:Company)** **CUS:ZipCode    LIKE(CUS:ZipCode)** **ViewPosition   STRING(1024)** **           END** **QuickWindow WINDOW('Browse Customers'),AT(,,211,155),IMM,SYSTEM,GRAY,DOUBLE,MDI** **         LIST,AT(8,6,198,142),USE(?CustList),IMM,HVSCROLL,FROM(CustQ),|** **         FORMAT('28R(2)|M~ID~C(0)@n4@80L(2)|M~Company~36L(2)|M~Zip~@P#####P@')** **         BUTTON('&Insert'),AT(49,62),USE(?Insert),HIDE** **         BUTTON('&Change'),AT(98,62),USE(?Change),HIDE,DEFAULT** **         BUTTON('&Delete'),AT(147,62),USE(?Delete),HIDE** **            END** **BrowseWindow CLASS(WindowManager)       !derive BrowseWindow object** **Init          PROCEDURE(),BYTE,PROC,VIRTUAL** **Kill          PROCEDURE(),BYTE,PROC,VIRTUAL** **Run           PROCEDURE(USHORT Number,BYTE Request),BYTE,PROC,VIRTUAL** **             END** **Toolbar    ToolbarClass           !declare Toolbar object** **BRW1    CLASS(BrowseClass)        !derive BRW1 object from BrowseClass ** **Q        &CustQ  ** **        END** ** CODE** ** GlobalResponse = BrowseWindow.Run()** **BrowseWindow.Init PROCEDURE()** **ReturnValue    BYTE,AUTO** ** CODE** ** ReturnValue = PARENT.Init()** ** SELF.FirstField = ?CustList** ** SELF.VCRRequest &= VCRRequest** ** SELF.Errors &= GlobalErrors** ** SELF.AddItem(Toolbar)                  !register Toolbar with BrowseWindow** ** Relate:Customer.Open** ** BRW1.Init(?CustList,CustQ.ViewPosition,CustView,CustQ,Relate:Customer,SELF)** ** OPEN(QuickWindow)** ** SELF.Opened=True** ** BRW1.Q &= CustQ** ** BRW1.AddSortOrder(,CUS:KeyCompany)     !set scroll order for Browse AND child Form** ** BRW1.AddField(CUS:CustNumber,BRW1.Q.CUS:CustNumber)** ** BRW1.AddField(CUS:Company,BRW1.Q.CUS:Company)** ** BRW1.AddField(CUS:ZipCode,BRW1.Q.CUS:ZipCode)** ** BRW1.AskProcedure = 1** ** BRW1.InsertControl=?Insert** ** BRW1.ChangeControl=?Change** ** BRW1.DeleteControl=?Delete** ** BRW1.AddToolbarTarget(Toolbar)       !BRW1 instantiates a ToolbarListboxClass** ** SELF.SetAlerts()                     ! object, and makes it a target** ** RETURN ReturnValue** **BrowseWindow.Kill PROCEDURE()** **ReturnValue    BYTE,AUTO** ** CODE** ** ReturnValue = PARENT.Kill()** ** Relate:Customer.Close** ** RETURN ReturnValue** **BrowseWindow.Run PROCEDURE(USHORT Number,BYTE Request)** ** CODE** ** GlobalRequest = Request** ** UpdateCustomer                      !Browse Procedure calls Form Procedure** ** RETURN GlobalResponse** **UpdateCustomer PROCEDURE             !template generated Form Procedure** **OrderView  VIEW(Orders)** **           END** **OrderQ           QUEUE** **ORD:OrderNumber   LIKE(ORD:OrderNumber)** **ORD:InvoiceAmount LIKE(ORD:InvoiceAmount)** **ViewPosition      STRING(1024)** **                 END** **QuickWindow WINDOW('Update Customer'),AT(,,172,132),IMM,GRAY,DOUBLE,MDI** **       SHEET,AT(4,4,164,106),USE(?CurrentTab)** **        TAB('Customer'),USE(?CustomerTab)** **         PROMPT('&Cust Number:'),AT(8,23),USE(?CustNumber:Prompt)** **         STRING(@n4),AT(64,23),USE(CUS:CustNumber),RIGHT(1)** **         PROMPT('&Company:'),AT(8,36),USE(?Company:Prompt)** **         ENTRY(@s20),AT(64,36),USE(CUS:Company)** **         PROMPT('&Zip Code:'),AT(8,52),USE(?Zip:Prompt)** **         ENTRY(@P#####P),AT(64,52),USE(CUS:ZipCode),RIGHT(1)** **        END** **        TAB('Orders'),USE(?OrderTab)** **         LIST,AT(8,22,156,81),USE(?OrdList),IMM,HVSCROLL,FROM(OrderQ),|** **         FORMAT('52R(2)|M~Order ID~C(0)@n-7@60D(12)|M~Amount~C(0)@n-10.2@')** **        END** **       END** **       BUTTON('OK'),AT(97,114),USE(?OK),DEFAULT** **       BUTTON('Cancel'),AT(133,114),USE(?Cancel)** **            END** **FormWindow  CLASS(WindowManager)       !derive FormWindow from WindowManager** **Init         PROCEDURE(),BYTE,PROC,VIRTUAL** **Kill         PROCEDURE(),BYTE,PROC,VIRTUAL** **TakeSelected PROCEDURE(),BYTE,PROC,VIRTUAL** **            END** **Toolbar      ToolbarClass             !declare Toolbar object** **ToolbarForm  ToolbarUpdateClass       !declare ToolbarForm object** **OrderBrowse  CLASS(BrowseClass)       !derive OrderBrowse from BrowseClass** **Q             &OrderQ** **             END** ** CODE** ** GlobalResponse = FormWindow.Run()** **FormWindow.Init PROCEDURE()** **ReturnValue    BYTE,AUTO** ** CODE** ** SELF.Request = GlobalRequest** ** ReturnValue = PARENT.Init()** ** SELF.FirstField = ?CustNumber:Prompt** ** SELF.VCRRequest &= VCRRequest** ** SELF.Errors &= GlobalErrors** ** CLEAR(GlobalRequest)** ** CLEAR(GlobalResponse)** ** SELF.AddItem(?Cancel,RequestCancelled)** ** Relate:Customer.Open** ** SELF.Primary &= Relate:Customer** ** SELF.OkControl = ?OK** ** IF SELF.PrimeUpdate() THEN RETURN Level:Notify.** ** OrderBrowse.Init(?OrdList,OrderQ.ViewPosition,OrderView,OrderQ,Relate:Orders,SELF)** ** OPEN(QuickWindow)** ** SELF.Opened=True** ** OrderBrowse.Q &= OrderQ** ** OrderBrowse.AddSortOrder(,ORD:KeyCustNumber)** ** OrderBrowse.AddRange(ORD:CustNumber,Relate:Orders,Relate:Customer)** ** OrderBrowse.AddField(ORD:OrderNumber,OrderBrowse.Q.ORD:OrderNumber)** ** OrderBrowse.AddField(ORD:InvoiceAmount,OrderBrowse.Q.ORD:InvoiceAmount)** ** SELF.AddItem(Toolbar)                !Register Toolbar with FormWindow** ** SELF.AddItem(ToolbarForm)            !Register ToolbarForm with FormWindow** **                                      ! (and with FormWindow's Toolbar)** ** OrderBrowse.AddToolbarTarget(Toolbar)!Instantiate a ToolbarListboxClass object,** ** SELF.SetAlerts()                     ! and register with FormWindow's Toolbar** ** RETURN ReturnValue** **FormWindow.Kill PROCEDURE()** **ReturnValue   BYTE,AUTO** ** CODE** ** ReturnValue = PARENT.Kill()** ** Relate:Customer.Close** ** RETURN ReturnValue** **FormWindow.TakeSelected PROCEDURE** ** CODE** ** IF FIELD(){PROP:Type}=Create:List** **  Toolbar.SetTarget(FIELD())         !make selected list the active Target** ** END                                 !(FormWindow also auto selects the Target)** ** RETURN PARENT.TakeSelected()** **Access:Customer.Init PROCEDURE** ** CODE** ** PARENT.Init(Customer,GlobalErrors)** ** SELF.FileNameValue = 'Customer'** ** SELF.Buffer &= CUS:Record** ** SELF.Create = 1** ** SELF.AddKey(CUS:KeyCustNumber,'CUS:KeyCustNumber',1)** ** SELF.AddKey(CUS:KeyCompany,'CUS:KeyCompany',0)** ** SELF.AddKey(CUS:KeyZipCode,'CUS:KeyZipCode',0)** **Access:Orders.Init PROCEDURE** ** CODE** ** PARENT.Init(Orders,GlobalErrors)** ** SELF.FileNameValue = 'Orders'** ** SELF.Buffer &= ORD:Record** ** SELF.Create = 1** ** SELF.AddKey(ORD:KeyOrderNumber,'ORD:KeyOrderNumber',1)** ** SELF.AddKey(ORD:KeyCustNumber,'ORD:KeyCustNumber',0)** **Relate:Customer.Init PROCEDURE** ** CODE** ** Access:Customer.Init** ** PARENT.Init(Access:Customer,1)** ** SELF.AddRelation(Relate:Orders,RI:CASCADE,RI:RESTRICT,ORD:KeyCustNumber)** ** SELF.AddRelationLink(CUS:CustNumber,ORD:CustNumber)** **Relate:Customer.Kill PROCEDURE** ** CODE** ** Access:Customer.Kill** ** PARENT.Kill** **Relate:Orders.Init PROCEDURE** ** CODE** ** Access:Orders.Init** ** PARENT.Init(Access:Orders,1)** ** SELF.AddRelation(Relate:Customer)** **Relate:Orders.Kill PROCEDURE** ** CODE** ** Access:Orders.Kill** ** PARENT.Kill**