Incorrect size of window with Windows scaling active

OS: Windows 10
Setting: In the Windows OS a display setting with a scaling other than 100%, like 125%.

Bug description:
The Window frame is too large by the percentage of the scaling. There is a large black border around it. The plugin wrapper assumes that the wrapped VST2 plugin would run in a ‘zoomed’ mode, which is not the case. It uses a scaling of 1.

Juce also seems to do some kind of weird detection of the editor size. It seems that it hooks on rect.right to notice that the size has changed.

I use this code to create the editor of the wrapped VST2 plugin:

juce::AudioProcessorEditor* createEditor() override
juce::AudioProcessorEditor* ed;
ed = plugin->createEditor();
return ed;

After wasting two days of development time I tracked down the error down to juce_VSTPluginFormat.cpp.
Sorry to say this, but your plugin-size detection code is a complete mess:

void timerCallback() override
if (isShowing())
if (–sizeCheckCount <= 0)
sizeCheckCount = 10;//WTF???

Not sure what this code should do? Check for 10 times if the size has changed? This will definitely create some kind of race condition with crappyHostXYZ.

I also came across this:

void openPluginWindow()

auto w = (int) (r.right - r.left);
auto h = (int) (r.bottom -;
if (rect != nullptr)
auto rw = rect->right - rect->left;
auto rh = rect->bottom - rect->top;
if ((rw > 50 && rh > 50 && rw < 2000 && rh < 2000 && (! isWithin (w, rw, 2) || ! isWithin (h, rh, 2)))
|| ((w == 0 && rw > 0) || (h == 0 && rh > 0)))
// very dodgy logic to decide which size is right.
if (std::abs (rw - w) > 350 || std::abs (rh - h) > 350)

The block does not get called when plugins with a size larger than 2000 pixels are loaded? Why?

I was able to fix the black blocks around the plugins at least for FL Studio and a couple of other hosts by doing this change:

void updateSizeFromEditor (int w, int h)
//this is new…
HDC screen = GetDC(0);
int dpiX = GetDeviceCaps(screen, LOGPIXELSX);
double scale = (double)(dpiX) / 96.f;//desktop skaliering auslesen
ReleaseDC(0, screen);
if (scale == 0) scale = 1;
w /= scale;
h /= scale;
if (! plugin.updateSizeFromEditor (w, h))
setSize (w, h);

However is still does not work in Cubase 11