Mail/Login: Password : forgot my password!

Ribbon Bar and Uniface

Direct link
Written by JTsagara // Tags: ribbon ribbonbar uniface gui

Back in 1996 I start to use Uniface as a developer, these days was the best choice for innovating products. Till 2007 I was official a Uniface developer now I use Uniface only for hobby and wait Compuware to do the big step and gives us the old glamour of Uniface 5 and 6.

Many times I tried to include GUI enchantments to Uniface (bars, outlook look, etc) but I think the best enchantment I work with is the ribbon bar … Microsoft develop this GUI element for office family at 2007.

So what you have to do for a ribbon bar in Uniface?

Is not a simple implementation but I think be worth it try for presentation on legacy Uniface applications.

All the process is separated in 3 steps
1. ActiveX Ribbon Bar.
2. Uniface code to build a ribbon menu.
3. C++ Routines for formatting.
4. Application Start Up Shell Calling

So let’s see it in detail.

ActiveX Ribbon Bar

The first step to buy a ribbon bar activex I choose codejock’s ribbon bar cause they help me with changes to be more Uniface compatible, also the cost was 1500€ with no runtime licenses (Compuware must learn from them).
Here is the site

After this, I talk with the codejocks customer support department and they changed a vital detail for Uniface compatibility, Uniface doesn’t recognize referencing objects as parameters in extended triggers, if you want a working ribbon bar you must use “Trigger Execute” and “Trigger Update”, but they have a parameter (ControlId) that is an object.

So I request codejock to change this to return an object Id as long number and not like an object, not only they changed without extra cost, but also they tried to communicate with Compuware and do this “Uniface Compatible” for all the components in the activex suite, with no lack of course.

Uniface code to build a ribbon menu

Uniface isn’t a tool that easy you can include activex components much less a presentation framework for all the MDI client of Uniface. The ribbon bar gives the application the look and the feel of office family.
The first think you must do is to “import” the activeX component in Uniface signatures, so after installing the activex component you must start Uniface and use the “/sti” command to import signatures.

In the command line of Uniface type :
Uniface Command Prompt SOURCE CODE
Sorry- ... please log-in or register to get this!

With this command you have all the signatures that must be used to communicate with activex component.
Ribbonmenu form properties
Ribbonmenu form properties

Next create a form, in this example I use the formname “CS_RIBBONMENU” and paint a DUMMY (no database) entity, in this entity paint a field “RIBBOMENU” with these properties:

Data Type : Raw Data
Widget Type : OcxContainer
Interface : Char 1
Syntax : Hidden

In widget type of OcxContainer use the properties, as shown in the image.

OcxContainer properties
OcxContainer properties

Now you are ready to start coding with ribbon bar.

In execute of CS_RIBBONMENU you must initialize the control with properties and make some global definitions.

So let’s start:
Uniface execute trigger SOURCE CODE
Sorry- ... please log-in or register to get this!

This is only the execute trigger that initialize an empty ribbon now you must create an operation that builds the popup and system menu (the round one at the left corner of application)
uOperation BuildSysButMenu SOURCE CODE
Sorry- ... please log-in or register to get this!

In this operation I build a popup menu from the constant list <xtpSystemButtonChoises> and I get the icons from $xtpSystemButtonIcon$ Because the Limit of GetItem (Cannot work with constant)

So now we are ready to build all the tab menus with groups I use an entity that keeps the menu definitions(C_MenuDef) of the application:
Operation BuildTabMenus SOURCE CODE
Sorry- ... please log-in or register to get this!

So until here I have construct the ribbon menu , build the system button and create my application menu….the last thing to do in this form to create an event every time the user press a button ribbon must activate something.

As explained before I use ControlId that we have defined at construction of menu to separate the events coming from tabs, popup menu or system button.

So at extended triggers of RIBBONMENU control I use the Execute Trigger from Codejock manual with the combination of Custom Parameter of Control to activate some forms:
Trigger Execute SOURCE CODE
Sorry- ... please log-in or register to get this!

In many cases you can see that I use constants some times are used for application proposes but other times are constants used by Ribbon bar so here are the contents of trigger defines of CS_RIBBONMENU form :
Ribbon defines SOURCE CODE
Sorry- ... please log-in or register to get this!

What about the image container of the ribbon framework?

If you notice in many lines I use vhImageManagerIcons. At execute trigger of the form I have activate a form called CS_ImageManager
Image container SOURCE CODE
Sorry- ... please log-in or register to get this!

The Cs_imagemanager contains the ActiveX class that is responsible for the icon handling of ribbon menu

To create this form you must draw a dummy entity and an OcxContainer that use Codejock.ImageManager class and add in the execute trigger :
Execute trigger extension SOURCE CODE
Sorry- ... please log-in or register to get this!

The most difficult part is to paint this Activex because due to an incompatibility of Uniface paint procedures when the form is displayed in development environment all the object flicks constantly to work around with this first open any form in development toggle paint tableau in a way that you can’t see the form paint area and then open the CS_ImageManager form.

So this is it now you have a working ribbon bar for your application and later I will explain how you can call it from application startup.

C++ Routines for formatting

In the code above you can see that I use Activate "u3gl".RibbonFormHandling ( vnApplicationHWND ) this is a custom C++ routine that hides the forms CS_RIBBONMENU & CS_IMAGEMANAGER and returns the application HWND for use with Activate vhCommandBarFrame->AttachToWindow(vnApplicationHWND) , maybe in another article I will explain how you can activate pure C++ from Uniface as for now here is the code for this procedure, is simple and very quick comparing to Uniface.
Sorry- ... please log-in or register to get this!

Application Start Up Shell Calling

So everything is ok now let’s call the forms from an application start up shell , so add to your app execute trigger:
Sorry- ... please log-in or register to get this!


As you can see it isn’t very easy to build such menu but it is not impossible (as Compuware states).

This example is just the start point you can do million customizations for this menu bar for example you can use Collections, checkboxes, gallery controls and many things

Ok more or less this is the result :
Ribbonmenu in action
Ribbonmenu in action

Ribbonmenu in Uniface
Ribbonmenu in Uniface

If you need the source code with colors, follow this link.

Hope you enjoyed.

Tsagarakis John


on 2011-08-25 14:07:52 mcanavar wrote:

Did you use the Chart ActiveX also, any examples of the Chart ActiveX ? thanx!

2339 view(s) / 2011-03-01 20:27:55 / LAST UPDATED: 2011-07-13 16:12:00