Hello everyone
I'm facing following problem:
Forms should be able to have different and custom colors for its controls and the form itself.
This seems to work in some cases, but especially for forms using templates like "ListPage" or "DetailsFormMaster" it does not.
Simply setting it in the properties it not an option, as the colors should be persistent throughout multiple forms and I don't want to change it in every form when I want to change the colors.
I've tried doing several things as I'll describe in a moment, but none worked to my satisfaction.
NOTE:
I based most of my Attempts on information I found on the MSDN.
For example, I can't find it right now, but I read that the colorScheme (and/or backgroundColor) attribute are carried to the children if they use the default values, if you simply change them on the biggest container.
Attempt No 1:
Try to find some sort of property or ini file which stores shared property information for multiple objects. (Did not find one)
Attempt No 2:
Define my own class which the targeted forms could then extend from.
Couldn't find the correct class that I should extend from, as EVERY form is defined like this:
public class FormRun extends ObjectRun { }
and I couldn't find anything that would work for me, as extending from ObjectRun didn't work as it resulted in an error (My new class would extend from ObjectRun and the FormRun then would extend from my own, new class).
I did try to extend from the class "Form", which did not result in any errors, but I couldn't override any functions except for "finalize()" I think.
Attempt No 3:
Modify "SysSetupFormRun" to atleast try to change the whole Window Color and try to see if that would work (I found this a lot as people seem to use this to change window colors depending on the current company)
I tried to add this to the "run()" and to the "init()" method, both worked for some windows and dialogs, but forms created from a template still looked mostly the way they always look.
this.design().colorScheme(FormColorScheme::RGB); this.design().backgroundColor(WinAPI::RGB2int(255, 0, 0));
Attempt No 4:
This is my favorite method so far in terms of code design.
I tried to implement my own small class that simply has a function to change the colors of the "design" thing from the form.
I defined an Enum (WindowColor) to make it easier to choose color and created a table to store the RGB-Values.
public static void changeColor(FormRun fr, WindowColor wc) { ColorDef colorDef; // This is my Table for storing the RGB-Values select count(WindowColorId) from colorDef where colorDef.WindowColorId == wc; if(colorDef.WindowColorId > 0) { select colorDef where colorDef.WindowColorId == wc; fr.design().colorScheme(FormColorScheme::RGB); fr.design().backgroundColor(WinAPI::RGB2int(colorDef.R, colorDef.G, colorDef.B)); } else { info(strFmt("%1 is not a valid WindowColor", wc)); } }
I would simply call this function in the init() function of the desired form and it would work in forms that are NOT based of a template.
public void init() { super(); ColorChange::changeColor(this, WindowColor::Warning); }
public static void changeControlColor(FormBuildControl fbc, WindowColor wc, int ctrlClassNum) { int handle; int i; FormBuildWindowControl fbwc; if(fbc.isContainer()) { for(i = 1; i <= fbc.controlCount(); i++) { ColorChange::changeControlColor(fbc.controlNum(i), wc, ctrlClassNum); } } handle = fbc.handle(); if(handle == ctrlClassNum) { info(strFmt("%1 == %2", fbc.handle(), ctrlClassNum)); fbwc = fbc; fbwc.colorScheme(FormColorScheme::RGB); fbwc.backgroundColor(WinAPI::RGB2int(255, 0, 0)); } }
int i; for(i = 1; i <= element.form().design().controlCount(); i++) { ColorChange::changeControlColor(element.form().design().controlNum(i), WindowColor::Important, classNum(FormBuildGridControl)); }
*This post is locked for comments
Thank you for your answer!
Its a pitty that ListPages don't support coloring.
The tip with the bar on the top is very great though, thanks alot!
You aren't very clear on what your actual question is. If you want colors on all forms, you'll have trouble with ListPages, but if you're looking for an indicator, you should look at adding a bar at the top.
See this post for a great example:
daxguy.blogspot.com/.../ax-environment-information-on-ui-simple.html
Mohamed Amine Mahmoudi
100
Super User 2025 Season 1
Community Member
48
Zain Mehmood
6
Moderator