web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Strange behaviour when changing backgroundColor

(0) ShareShare
ReportReport
Posted on by

Hi

The code below is a very compressed example of a real problem. This code in the exampl exists in a very simple form that has a StringEdit control called StringEdit and a button.

Before pressing the button, the StringEdit control has its default background color. In this case it is White. By code, I change it to a nice orange color. This procedure includes changing colorscheme. After that I restore the original color scheme and the original color. However, now the background turns black.

A functional workaround is to keep the new scheme and pass [255, 255, 255]. That makes the background white again. But if users have selected a different color scheme in Windows, white might be the wrong colour.

I would just like to know if anyone could explain this, and if you have seen any working combination of updates/window locks/redraws and so on to get passed this problem. At least I have failed.

void clicked()
{
    int oldColor;
    int oldScheme;
   
    super();
   
    oldScheme = StringEdit.colorScheme();
    oldColor = StringEdit.backgroundColor();
    //oldScheme has been set to 0
    //oldColor has been set to 16777215

    //Change color scheme and set color = orange
    StringEdit.colorscheme(2);
    StringEdit.backgroundcolor(5876991);

    //Change to original scheme and color
    StringEdit.colorscheme(oldScheme);
    StringEdit.backgroundcolor(oldColor);
    
    oldScheme = StringEdit.colorScheme();
    oldColor = StringEdit.backgroundColor();
    //Oops, now oldColor = 0, should be 16777215
}

/Jonas

*This post is locked for comments

I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

#2
NNaumenko Profile Picture

NNaumenko 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans