# Multiwindow repait problem on Windows

**URL:** <https://forum.juce.com/t/multiwindow-repait-problem-on-windows/56959>\
**Category:** General JUCE discussion\
**Created:** [July 8, 2023, 5:14pm UTC](https://forum.juce.com/t/multiwindow-repait-problem-on-windows/56959 "2023-07-08T17:14:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paplet](https://avatars.discourse-cdn.com/v4/letter/p/8e8cbc/32.png) [@Paplet](https://forum.juce.com/u/Paplet)\
**Post date:** [July 8, 2023, 5:14pm UTC](https://forum.juce.com/t/multiwindow-repait-problem-on-windows/56959/1 "2023-07-08T17:14:52Z")

</div>

I’m developing an multiwindow application intended to run on Windows using juce v 7.0.5.  
There are three windows running at the same time in my application, and when I call repaint() method at the same time in the message thread at a frequency about one time per 2 milliseconds to repaint a component in these three windows, the window I’m focusing will repaint it’s component as I expected, but for the second window, the component will be repainted later, as for the third window, it actually won’t be repainted unless I set it as the focus window.

I know that calling repaint() actually won’t do any repaint immediately, but the problem is that the focus window will be repainted as soon as possible. Am I calling the repait() method too often?

I’ve tried to use getPeer()-\>performAnyPendingRepaintsNow(), it will fix this problem but it’s too time-consuming.

Is there any other way to make the the other two window being repainted as the focus window? Also this problem won’t happen on MacOS, so is it actually the OS’s issue?

Here is an video about this problem in case I didn’t discribe it clearly.  
[https://1drv.ms/v/s!AqYmYX8a4y7PnwkXyCbpOMzFvQRc?e=i2Ic62](https://1drv.ms/v/s!AqYmYX8a4y7PnwkXyCbpOMzFvQRc?e=i2Ic62)

---

<div class="post-metadata">

**Author:** ![matt](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/matt/32/18340_2.png) [@matt](https://forum.juce.com/u/matt)\
**Post date:** [July 9, 2023, 5:19pm UTC](https://forum.juce.com/t/multiwindow-repait-problem-on-windows/56959/2 "2023-07-09T17:19:07Z")

</div>

Repainting is triggered by your window receiving a WM\_PAINT message from Windows. As far as I can tell, Windows prioritizes foreground windows over background windows. The Desktop Window Manager seems to intentionally throttle the rate at which WM\_PAINT messages are delivered to non-focused windows. It’s not a JUCE issue.

You could try Direct2D, but of course that’s a work in progress. I’ll have another update soon. More testing is good.

Matt

---

<div class="post-metadata">

**Author:** ![matt](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/matt/32/18340_2.png) [@matt](https://forum.juce.com/u/matt)\
**Post date:** [July 9, 2023, 5:21pm UTC](https://forum.juce.com/t/multiwindow-repait-problem-on-windows/56959/3 "2023-07-09T17:21:23Z")

</div>

Huh - actually you could paint synchronously in software mode.

[https://learn.microsoft.com/en-us/windows/win32/gdi/synchronous-and-asynchronous-drawing](https://learn.microsoft.com/en-us/windows/win32/gdi/synchronous-and-asynchronous-drawing)
