Skip to content

Commit f0a9f93

Browse files
HeikoKlarefedejeanne
authored andcommitted
[Win32] Fix initial control location #2643
With a recent change to the initial location of newly created controls, the locations of some controls inside shells are broken. The intent of that previous change was to improve the initial location of shells. This change adapts the previous modification to only apply an improved pattern for initial shell placement when the control is actually shell and to keep the previous behavior for all other controls. Fixes #2643
1 parent 1f8df87 commit f0a9f93

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -672,25 +672,13 @@ Control computeTabRoot () {
672672

673673
void createHandle () {
674674
long hwndParent = widgetParent ();
675-
676-
int x=OS.CW_USEDEFAULT;
677-
int y=0;
678-
679-
// Set it to be near the top-left corner of the parent shell by default
680-
if (hwndParent != 0) {
681-
RECT rect = new RECT();
682-
OS.GetWindowRect(hwndParent, rect);
683-
684-
x = rect.left + 100;
685-
y = rect.top + 100;
686-
}
687-
675+
Point initialLocation = getInitialLocation();
688676
handle = OS.CreateWindowEx (
689677
widgetExtStyle (),
690678
windowClass (),
691679
null,
692680
widgetStyle (),
693-
x, y, OS.CW_USEDEFAULT, 0,
681+
initialLocation.x, initialLocation.y, OS.CW_USEDEFAULT, 0,
694682
hwndParent,
695683
0,
696684
OS.GetModuleHandle (null),
@@ -702,6 +690,10 @@ void createHandle () {
702690
}
703691
}
704692

693+
Point getInitialLocation() {
694+
return new Point(OS.CW_USEDEFAULT, 0);
695+
}
696+
705697
void checkGesture () {
706698
int value =getSystemMetrics (OS.SM_DIGITIZER);
707699
if ((value & (OS.NID_READY | OS.NID_MULTI_INPUT)) != 0) {

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,18 @@ void createHandle () {
645645
}
646646
}
647647

648+
@Override
649+
Point getInitialLocation() {
650+
long hwndParent = widgetParent ();
651+
// Set it to be near the top-left corner of the parent shell by default
652+
if (hwndParent != 0) {
653+
RECT rect = new RECT();
654+
OS.GetWindowRect(hwndParent, rect);
655+
return new Point(rect.left + 100, rect.top + 100);
656+
}
657+
return super.getInitialLocation();
658+
}
659+
648660
void createMenuItemToolTipHandle() {
649661
menuItemToolTipHandle = createToolTipHandle (0);
650662
}

0 commit comments

Comments
 (0)