Today is the second day of being stuck at home due to heavy (by Christchurch standards) snow which has meant that I have had more time to focus on writing up the details of replacing a modification with a combination of a custom control, web-services and jscripts, that and learning about the fun of digging your driveway out.

While working through the existing modification I wondered about look up fields in M3, the ones with those little arrows to the right

The thing that I was really interested in was what control they use?

So for the purposes of expedience I just created a quick script which retrieved the control object and did a GetType() on it. Much to my surprise it was a plain old TextBox 😦

So, my next thought was were Lawson doing some XAML magic? I had a quick look at the Microsoft documentation on XAML and quickly got side tracked and bored and decided to assume that there was something more interesting going on…not that XAML isn’t interesting, it just gets a little arcane when you are trying to figure out how to reverse engineer something.

I started looking for interesting controls in the Visual Studio object browser and that didn’t get far, so I started looking at the RenderEngine – perhaps there was some magic happening there. I couldn’t see anything but one thing stuck out…”AddTextBoxHistory” – I haven’t seen any textboxes in Smart Office that really have a history of commands so I wondered if it was a control that was being reused for something other than the original intended purpose (yup, a random leap). A bit of a search through the Object Browser yielded pay-dirt. “IsHistory” as part of the MForms.ControlTag object.

Gears started turning, small amounts of smoke escaping my ears as I remembered I had come across some issues when I had commandeered a <UIElements>.Tag field. ( – and to think, I had almost had the name of that object in the subject of my post! :-))

This ControlTag needed investigation, and investigate I did – there are only three properties but there are several exposed public objects, and what do we have? “IsBrowseable” This tag is set to true if the field is browsable and false if not. I’m guessing, but I suspect you need to use the AddElement method from MForms.Render.RenderEngine if you wanted to add your own control with the little wee triangle, setting the IsBrowseable flag after the control has been added doesn’t do anything.

Other interesting data in this object “ReferenceField” and “ReferenceFile” – these, at least in the case of our modification identify the column and table respectively in the database that the field corresponds to!

Code as follows, you’ll just need to change the TextBox that you are searching for to something that makes sense in your environment.

import System;
import System.Windows;
import System.Windows.Controls;
import MForms;

package MForms.JScript 
    class Test
        public function Init(element: Object, args: Object, controller : Object, debug : Object)
            var content : Object = controller.RenderEngine.Content;

            // WEBKRF is the TextBox we are interested in
            var tbControl = ScriptUtil.FindChild(content,"WEBKRF");
            if(null != tbControl)
                if(null != tbControl.Tag)
                    // show the type of the Tag object
                    MessageBox.Show("Type: " + tbControl.Tag.GetType());
                    // extract the ControlTag object
                    var ctTag : ControlTag = tbControl.Tag;
                    // show some interesting information
                    MessageBox.Show("IsBrowsable: " + ctTag.IsBrowsable);
                    MessageBox.Show("ReferenceField: " + ctTag.ReferenceField);
                    MessageBox.Show("ReferenceFile: " + ctTag.ReferenceFile);

Have fun! 🙂

This entry was posted in Development, How Far is Too Far?, M3 / MoveX and tagged . Bookmark the permalink.

1 Response to ControlTag

  1. Pingback: ControlTag « M3 ideas

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s