You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

The SRP Ribbon Control takes a brand new approach to setup. Other SRP ActiveX Controls tend to be very dynamic. In the SRP Tree Control, for example, you add and remove items at will. However, SRP Ribbon Controls are much more complex to set up and as such, lend themselves to a one-time static initialization. This doesn't mean you won't be able to do things at runtime, it's just that it will be a slightly different paradigm than what you might be used to.

For example, let's say you have a tab that only appears in specific circumstances. You might think the solution is to add that tab when the need arises and remove it when you're done. Instead, you add the tab during your initialization along with all the other tabs and simply making it invisible by default. Later, you make it visible when you need it. The reason is because creating a tab can be expensive since it might have a lot of controls on it. It's much more efficient to create the tab once and keep it memory. The same principle should be applied to groups, controls, and everything else. We want everything created at the beginning of your form's life, and to make this easier we use the power of XML to initialize the control. This means we can efficiently setup the entire ribbon in one single call.

Init with XML

You are accustomed to writing line after line of Set_Property statements to setup your SRP ActiveX Controls. During the development of the SRP Ribbon Control, it became quickly apparent that the same approach was far too cumbersome and inefficient. This is due, in part, to the fact that you can have controls within controls. Such a hierarchical architecture screamed for XML as a much preferred solution.

Now your CREATE event handler will typically require only two lines of code to initialize your ribbon: one to grab the XML from the database and one that passes the XML to the ribbon.

// Read the XML from a table and pass it to the Init method
SetupXml = Xlate("SETUP", "RIBBON_TEST", "", "X")
Send_Message(@Window:".OLE_RIBBON", "OLE.Init", SetupXml)

This greatly simplifies the creation code. Now, all you need to do is learn the XML structure. Note that the main page for the SRP Ribbon Control documentation has a section listing all supported XML tags. If you are new to the control, you'll want to start by looking at the <Control> tag, which is the root tag of the XML passed to the Init method.

  • No labels