Windows 10, colorsettings

I declare GetSysColor to obtain the users’ Form-backcolor-setting:

[code] Declare Function GetSysColor Lib “user32” Alias “GetSysColor” (nIndex As Integer) As Integer
Dim winColor as Variant = GetSysColor(5)
Dim c as color = winColor.ColorValue


It used to work before, but with Windows 10 I get totally wrong colors back from the function.
Anybody know the cause ?

Hi Joost,

Yes, I can confirm that I am getting the same incorrect problems that you are in 2016 r4.1.

Something else does not seem to be correct. I tried to get the back colour with the Xojo command and Backcolor does not exist:

Window1.HasBackColor = True Window1.BackColor = &c110034

I tried it on a new project and then it worked, and tried on another project and it stopped working again. All I did was make a new project, add a pushbutton and an action event and add the two lines of code. Below is the screen grab. Something isn’t right, and it would be nice to figure out a constant way to replicate the inconsistent problem with a feedback case. I’ll see what I can do in the next few hours.

Self.HasBackColor = True
Self.BackColor = &c110034

[quote=318662:@Norman Palardy]Self.HasBackColor = True
Self.BackColor = &c110034[/quote]
Thanks Norman!

Joost, this declare looks like it is the default setting for the system colours, which defaults to whatever the background colour is for all windows on the computer, and not the specific background colour for a window in Xojo.

To get the background colour of the window in a specific Xojo instance, it looks like the WNDCLASS.hbrBackground data will provide this information, in probably colorindex format for windows (needs to reverse red and blue colours for Xojo). The GetClassInfo declare should be able to get this information from the program. Example 5-3 in the Declares book would need to be modified and updated, and its close to what is needed with a few modifications. I’ve run out of time tonight and let me know if you need a hand with this.

Actually I was looking for that, since I don’t have the hasbackcolor property of the window set to true, in order to make sure the color-settings of the Windows OS will be used for the xojo window, whatever they are.
Coloring the window myself is not an option since some controls, like tabpanel, will not adapt my setting.

I played with “Code 94. Example 5-3: GetClassInfo Code

And I checked GetClassInfo
link text

Once you’ve updated this example, would share it with me ? Thanks.

Joost, I am running into the same problem that you are seeing and am always getting the hbrBackground colour of zero. When the GetClassInfo (or GetClassInfoEx) function is called, then the program looks for the Windows OS name of the control. This means that a pushbutton1 control has the name “Button”, and a Combobox1 control has a name “ComboboxEx32”. Below is the code that retrieves these names.

Declare Function GetClassName Lib "user32.dll" Alias "GetClassNameW" (hwnd As Int32, lpClassName As Ptr, nMaxCount As Int32) As Int32 Dim MyClassName as new MemoryBlock(255) Call GetClassName(Window1.handle, MyClassName, 255) System.DebugLog "MyClassName: " + MyClassName.WString(0)

When I retrieve the name of Window1, which should be “Window”, I get “RBWindow”. This doesn’t have the same name that Windows OS uses and the GetClassInfo function fails. I am not sure how Xojo builds a window, and I am not able to get a successful GetClassInfo call.

Sorry, I don’t have a good answer for you.

Thanks a lot for all the work Eugene.

Think there is a lot of legacy to deal with here.
The reason I wanted this is that I would like to have Textfields/areas with transparent background. Since this is not possible, I wanted to give the background the same color as the control it is on top of. And as I am using much page-panels, which don’t have an option to set a backgroundcolor other than what’s given by OS, I need the color given to the panel by OS.
Anyway, there are still more important things to get done than this one.