Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Weird shell size on Windows

That does not only happen with a scale of 200% but also with every other
scale. For example when I tried it with 100% on my Windows 10 I got a window
size of 386x293 px.

I guess that was intended by Microsoft due to the thick window borders that
were present in Windows 7. If one developer arranges his UI by pixels and
takes the border thickness into account, the same app would layout ugly on
Windows 8 and newer where the borders have been removed.

There are some registry values that affect this (in Windows 8/10 invisible)
border. These are described here:
http://tweaks.com/windows/62971/adjust-window-border-padding/
I tried to set the PaddedBorderWidth to 0. After that the 400x300 px window
had an actual size of 394x297 px. I don't know how to achieve the remaining
6x3 px. There's an app available to play with the different windows settings
here: https://winaero.com/

I conclude that this isn't a SWT issue but a Windows feature ;)

Regards
Conrad

-----Ursprüngliche Nachricht-----
Von: platform-swt-dev-bounces@xxxxxxxxxxx
[mailto:platform-swt-dev-bounces@xxxxxxxxxxx] Im Auftrag von Thomas Singer
Gesendet: Mittwoch, 27. September 2017 13:04
An: platform-swt-dev@xxxxxxxxxxx
Betreff: [platform-swt-dev] Weird shell size on Windows

I'm using following tiny snippet to show a shell with a certain size on my
Windows 10 machine with 4K-monitor (200% zoom):

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;

public class WindowSize {

	public static void main(String[] args) {
		final Display display = new Display();

		final Shell shell = new Shell(display);
		shell.addListener(SWT.Resize, new Listener() {
			@Override
			public void handleEvent(Event event) {
				System.out.println(shell.getSize());
			}
		});
		shell.setSize(400, 300);

		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}

		display.dispose();
	}
}

As it is printed on console, the size is equal to the one specified. 
While debugging it is obvious that the file is scaled to double-size, so
actually Control.setBoundsInPixels() is invoked with 800x600 as argument. So
far, so understandable, but when I take a screenshot with 
Alt+Print and paste it into a graphic application, e.g. IrfanView, the
size 778x589 is displayed. The same occurs if I use, e.g. GreenShot to take
the screenshot and view its size. This somehow makes me wonder where the
remaining 22x11 pixels have gone.

--
Best regards,
Thomas Singer
=============
syntevo GmbH
http://www.syntevo.com
http://www.syntevo.com/blog
_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from
this list, visit https://dev.eclipse.org/mailman/listinfo/platform-swt-dev



Back to the top