# BR: Desktop Components have wrong scale unless opened by PopupMenu callback

**URL:** <https://forum.juce.com/t/br-desktop-components-have-wrong-scale-unless-opened-by-popupmenu-callback/44649>\
**Category:** General JUCE discussion\
**Created:** [February 25, 2021, 4:38am UTC](https://forum.juce.com/t/br-desktop-components-have-wrong-scale-unless-opened-by-popupmenu-callback/44649 "2021-02-25T04:38:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![RolandMR](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rolandmr/32/641_2.png) [@RolandMR](https://forum.juce.com/u/RolandMR)\
**Post date:** [February 25, 2021, 4:38am UTC](https://forum.juce.com/t/br-desktop-components-have-wrong-scale-unless-opened-by-popupmenu-callback/44649/1 "2021-02-25T04:38:55Z")

</div>

Desktop Components have wrong scale unless opened by PopupMenu callback. This is a strange one, no idea what is going wrong. I have reduced it to minimal example with latest develop juce.

Setup:  
Windows 10  
Desktop scale 150%  
VST3  
AudioPluginHost

Start a 1000 ms timer. Create a desktop component from timer, scale will be wrong.  
Create desktop component from PopupMenu, scale will be correct

Video:

[![](https://us1.discourse-cdn.com/flex026/uploads/juce/original/2X/c/cf441c518290a7adc4e5c0fa0fe4883e69c25de9.jpeg "Screen 02 24 2021 20 31 55") ](https://www.youtube.com/watch?v=vkSofbeUM3I)

Code:

> <https://github.com/FigBug/juce_bugs/blob/master/bad_scale/Source/PluginEditor.cpp>

---

<div class="post-metadata">

**Author:** ![RolandMR](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rolandmr/32/641_2.png) [@RolandMR](https://forum.juce.com/u/RolandMR)\
**Post date:** [February 26, 2021, 6:24pm UTC](https://forum.juce.com/t/br-desktop-components-have-wrong-scale-unless-opened-by-popupmenu-callback/44649/2 "2021-02-26T18:24:44Z")

</div>

I figured out the cause of the issue. Any new Windows created will have the same DPI awareness settings as the current window. In `mouseDown` or `mouseUp` the current window is the plugin editor window.

However, if you are creating a window from a `Timer` there is a hidden Window that is used to pass the message from the background timer thread to the UI thread. When the new Window is created, it has the same DPI awareness as this hidden window, which is not correct.

Work around for now is to only create new windows from `Component` events.

---

<div class="post-metadata">

**Author:** ![ed95](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ed95/32/7635_2.png) [@ed95](https://forum.juce.com/u/ed95)\
**Post date:** [February 26, 2021, 7:07pm UTC](https://forum.juce.com/t/br-desktop-components-have-wrong-scale-unless-opened-by-popupmenu-callback/44649/3 "2021-02-26T19:07:20Z")

</div>

Yes, this is something that needs to be addressed in the AudioPluginHost - we have an option for disabling DPI awareness for plug-ins but it will only disable it for the main window.

An alternative for the time being is to create an instance of `ScopedDPIAwarenessDisabler` before opening your new windows.

---

<div class="post-metadata">

**Author:** ![RolandMR](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rolandmr/32/641_2.png) [@RolandMR](https://forum.juce.com/u/RolandMR)\
**Post date:** [February 26, 2021, 7:40pm UTC](https://forum.juce.com/t/br-desktop-components-have-wrong-scale-unless-opened-by-popupmenu-callback/44649/4 "2021-02-26T19:40:35Z")

</div>

Is this something that is on to TODO list? I notice my plugin looks good in FL Studio, but it’s stretched and obviously blurry in the AudioPluginHost.

---

<div class="post-metadata">

**Author:** ![ed95](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ed95/32/7635_2.png) [@ed95](https://forum.juce.com/u/ed95)\
**Post date:** [February 26, 2021, 7:50pm UTC](https://forum.juce.com/t/br-desktop-components-have-wrong-scale-unless-opened-by-popupmenu-callback/44649/5 "2021-02-26T19:50:45Z")

</div>

If you right-click on the plug-in node and toggle “Enable DPI awareness” the editor window will be opened in DPI aware mode and won’t be bitmap stretched by Windows.

---

<div class="post-metadata">

**Author:** ![RolandMR](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rolandmr/32/641_2.png) [@RolandMR](https://forum.juce.com/u/RolandMR)\
**Post date:** [February 26, 2021, 8:40pm UTC](https://forum.juce.com/t/br-desktop-components-have-wrong-scale-unless-opened-by-popupmenu-callback/44649/6 "2021-02-26T20:40:25Z")

</div>

Ah, got it, thanks.

---

<div class="post-metadata">

**Author:** ![ed95](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ed95/32/7635_2.png) [@ed95](https://forum.juce.com/u/ed95)\
**Post date:** [March 2, 2021, 4:20pm UTC](https://forum.juce.com/t/br-desktop-components-have-wrong-scale-unless-opened-by-popupmenu-callback/44649/7 "2021-03-02T16:20:45Z")

</div>

We’ve added an application-wide setting for DPI scaling hosted plug-ins on Windows to the AudioPluginHost on `develop`:

> <https://github.com/juce-framework/JUCE/commit/3a0af69eff840958c53185fd0ff79df226d68e25>

If you enable `Options->Auto-Scale Plug-in Windows` menu item and then add an instance of your plug-in to the graph it’ll use the correct DPI-awareness setting for all windows.
