# CellBackgroundPaint in Subclass not working in DarkMode on Windows 11

**URL:** <https://forum.xojo.com/t/cellbackgroundpaint-in-subclass-not-working-in-darkmode-on-windows-11/86737>\
**Category:** Windows\
**Created:** [October 17, 2025, 5:22am UTC](https://forum.xojo.com/t/cellbackgroundpaint-in-subclass-not-working-in-darkmode-on-windows-11/86737 "2025-10-17T05:22:48Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sascha\_S](https://forum.xojo.com/user_avatar/forum.xojo.com/sascha_s/32/22328_2.png) [@Sascha\_S](https://forum.xojo.com/u/Sascha_S)\
**Post date:** [October 17, 2025, 5:22am UTC](https://forum.xojo.com/t/cellbackgroundpaint-in-subclass-not-working-in-darkmode-on-windows-11/86737/1 "2025-10-17T05:22:48Z")

</div>

I have a Subclass of DesktopListbox in which i’ve added a PaintCellBackground Event.  
In this event selected rows will get the Color.Highlight Color as Background Color.  
This is working as expected while running my app in light mode.

**In dark mode the event is executed but the painting does not happen.**  
If i use the same code in a non-subclassed listbox, it works as expected again.

Maybe i’m doing something wrong here?

Issue with an example Project: [https://tracker.xojo.com/xojoinc/xojo/-/issues/80042](https://tracker.xojo.com/xojoinc/xojo/-/issues/80042)

---

<div class="post-metadata">

**Author:** ![StefanA](https://forum.xojo.com/user_avatar/forum.xojo.com/stefana/32/286_2.png) [@StefanA](https://forum.xojo.com/u/StefanA)\
**Post date:** [October 17, 2025, 6:15am UTC](https://forum.xojo.com/t/cellbackgroundpaint-in-subclass-not-working-in-darkmode-on-windows-11/86737/2 "2025-10-17T06:15:43Z")

</div>

I tried three cases:

- Default DesktopListbox
- Subclassed DesktopListbox with event handler in super class
- Subclassed DesktopListbox with event handler in control itself

[listboxes.xojo\_binary\_project.zip](https://forum.xojo.com/uploads/short-url/5A3Dglt80IAq9NJzEieCHKDZl3M.zip) (7.3 KB)

All three work

 ![image](https://forum.xojo.com/uploads/default/original/3X/e/6/e646e28e6f6d553e75e918db4aceef3981e1aa60.jpeg)

---

<div class="post-metadata">

**Author:** ![Sascha\_S](https://forum.xojo.com/user_avatar/forum.xojo.com/sascha_s/32/22328_2.png) [@Sascha\_S](https://forum.xojo.com/u/Sascha_S)\
**Post date:** [October 17, 2025, 6:16am UTC](https://forum.xojo.com/t/cellbackgroundpaint-in-subclass-not-working-in-darkmode-on-windows-11/86737/3 "2025-10-17T06:16:49Z")

</div>

And my example also works?

---

<div class="post-metadata">

**Author:** ![StefanA](https://forum.xojo.com/user_avatar/forum.xojo.com/stefana/32/286_2.png) [@StefanA](https://forum.xojo.com/u/StefanA)\
**Post date:** [October 17, 2025, 6:17am UTC](https://forum.xojo.com/t/cellbackgroundpaint-in-subclass-not-working-in-darkmode-on-windows-11/86737/4 "2025-10-17T06:17:55Z")

</div>

![image](https://forum.xojo.com/uploads/default/original/3X/7/1/717fd73c4319d194b74aa69ef335bf6f7e1d74f9.jpeg)

---

<div class="post-metadata">

**Author:** ![Sascha\_S](https://forum.xojo.com/user_avatar/forum.xojo.com/sascha_s/32/22328_2.png) [@Sascha\_S](https://forum.xojo.com/u/Sascha_S)\
**Post date:** [October 17, 2025, 6:19am UTC](https://forum.xojo.com/t/cellbackgroundpaint-in-subclass-not-working-in-darkmode-on-windows-11/86737/5 "2025-10-17T06:19:58Z")

</div>

Both listboxes should show selected entries with a blue (highlight color) background.  
Your image shows the issue i encounter.

---

<div class="post-metadata">

**Author:** ![StefanA](https://forum.xojo.com/user_avatar/forum.xojo.com/stefana/32/286_2.png) [@StefanA](https://forum.xojo.com/u/StefanA)\
**Post date:** [October 17, 2025, 6:23am UTC](https://forum.xojo.com/t/cellbackgroundpaint-in-subclass-not-working-in-darkmode-on-windows-11/86737/6 "2025-10-17T06:23:33Z")

</div>

The left one is only blue if it has the focus

 ![image](https://forum.xojo.com/uploads/default/original/3X/a/1/a193ffbd5abad2be2b390478ea5f6580c3e61865.jpeg)

---

<div class="post-metadata">

**Author:** ![Sascha\_S](https://forum.xojo.com/user_avatar/forum.xojo.com/sascha_s/32/22328_2.png) [@Sascha\_S](https://forum.xojo.com/u/Sascha_S)\
**Post date:** [October 17, 2025, 6:24am UTC](https://forum.xojo.com/t/cellbackgroundpaint-in-subclass-not-working-in-darkmode-on-windows-11/86737/7 "2025-10-17T06:24:22Z")

</div>

Exactly. It behaves different from the right one, but it shouldn’t. 🙂

---

<div class="post-metadata">

**Author:** ![StefanA](https://forum.xojo.com/user_avatar/forum.xojo.com/stefana/32/286_2.png) [@StefanA](https://forum.xojo.com/u/StefanA)\
**Post date:** [October 17, 2025, 6:25am UTC](https://forum.xojo.com/t/cellbackgroundpaint-in-subclass-not-working-in-darkmode-on-windows-11/86737/8 "2025-10-17T06:25:49Z")

</div>

Ah, now I understand.

The left one is the wrong one 😄 .

Yeah, reproducable on my side.

---

<div class="post-metadata">

**Author:** ![StefanA](https://forum.xojo.com/user_avatar/forum.xojo.com/stefana/32/286_2.png) [@StefanA](https://forum.xojo.com/u/StefanA)\
**Post date:** [October 17, 2025, 6:27am UTC](https://forum.xojo.com/t/cellbackgroundpaint-in-subclass-not-working-in-darkmode-on-windows-11/86737/9 "2025-10-17T06:27:44Z")

</div>

Oh no, it isn’t.

You use

`Return RaiseEvent PaintCellBackground( g, row, column )`

As you don’t return anything in the control in the window the painting is handled by Xojo and not by your code.

---

<div class="post-metadata">

**Author:** ![StefanA](https://forum.xojo.com/user_avatar/forum.xojo.com/stefana/32/286_2.png) [@StefanA](https://forum.xojo.com/u/StefanA)\
**Post date:** [October 17, 2025, 6:28am UTC](https://forum.xojo.com/t/cellbackgroundpaint-in-subclass-not-working-in-darkmode-on-windows-11/86737/10 "2025-10-17T06:28:12Z")

</div>

Return True and it works

 ![image](https://forum.xojo.com/uploads/default/original/3X/5/c/5cc80986c497c00ff4e2426f473ce06faca85434.jpeg)

 ![image](https://forum.xojo.com/uploads/default/original/3X/5/6/56a9fcb041b081e72a497f5d682177190024f7a0.jpeg)

---

<div class="post-metadata">

**Author:** ![Sascha\_S](https://forum.xojo.com/user_avatar/forum.xojo.com/sascha_s/32/22328_2.png) [@Sascha\_S](https://forum.xojo.com/u/Sascha_S)\
**Post date:** [October 17, 2025, 6:57am UTC](https://forum.xojo.com/t/cellbackgroundpaint-in-subclass-not-working-in-darkmode-on-windows-11/86737/11 "2025-10-17T06:57:29Z")

</div>

Thank you @StefanA, i see the problem here now. 🙂

How can i make sure the Code in the Subclassed DesktopListbox is respected without me having to add a PaintCellBackground Event in each of my object which use this subclass?

Because i need the `Return RaiseEvent PaintCellBackground( g, row, column )` for instances in which i use this subclass but extended it’s functionality in the PaintCellBackground Event and i don’t want to add a `Return True` i all those instances. And sometimes i need to `Return False` here, too.

---

<div class="post-metadata">

**Author:** ![StefanA](https://forum.xojo.com/user_avatar/forum.xojo.com/stefana/32/286_2.png) [@StefanA](https://forum.xojo.com/u/StefanA)\
**Post date:** [October 17, 2025, 7:17am UTC](https://forum.xojo.com/t/cellbackgroundpaint-in-subclass-not-working-in-darkmode-on-windows-11/86737/12 "2025-10-17T07:17:43Z")

</div>

Well, if you want to handle it yourself you have to return true. Otherwise Xojo will handle it.

We use this for such cases:

```auto
If Not RaiseEvent PaintCellBackground( g, row, column ) Then

    Return True

End If

```

So you have the chance to handle it in the control itself.

Otherwise the super class will handle it.

---

<div class="post-metadata">

**Author:** ![Sascha\_S](https://forum.xojo.com/user_avatar/forum.xojo.com/sascha_s/32/22328_2.png) [@Sascha\_S](https://forum.xojo.com/u/Sascha_S)\
**Post date:** [October 17, 2025, 7:38am UTC](https://forum.xojo.com/t/cellbackgroundpaint-in-subclass-not-working-in-darkmode-on-windows-11/86737/13 "2025-10-17T07:38:36Z")

</div>

Thanks, Stefan. I now understand what the problem is and what I need to do. And I’m glad it’s not a bug. I’ll close my case in the issue tracker.

Have a nice weekend! 🙂
