diff options
author | Alexandr Miloslavskiy | 2020-02-20 13:46:55 +0000 |
---|---|---|
committer | Niraj Modi | 2020-05-15 10:22:33 +0000 |
commit | b6321a99e75b725c0d32bf08cb11485cb2fae744 (patch) | |
tree | f2f4e726d16a93e9f97f3c8c45d1e6c36a11a9e7 /bundles/org.eclipse.swt | |
parent | 1885cf19dcbcbc4ef7332320f2aadaacb9bd699d (diff) | |
download | eclipse.platform.swt-b6321a99e75b725c0d32bf08cb11485cb2fae744.tar.gz eclipse.platform.swt-b6321a99e75b725c0d32bf08cb11485cb2fae744.tar.xz eclipse.platform.swt-b6321a99e75b725c0d32bf08cb11485cb2fae744.zip |
Bug 560316: Preparation: Fix WS_BORDER behavior for Text
Currently, Text will never use `WS_BORDER`.
However, it will be used in the next commit.
Change-Id: Ifdfc6be1127fd3ac629634bb8869968b45e71f89
Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Diffstat (limited to 'bundles/org.eclipse.swt')
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java | 1 | ||||
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java | 23 |
2 files changed, 23 insertions, 1 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java index 3300c4c584..65c054b061 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java @@ -1336,6 +1336,7 @@ public class OS extends C { public static final int STM_SETIMAGE = 0x172; public static final int SWP_ASYNCWINDOWPOS = 0x4000; public static final int SWP_DRAWFRAME = 0x20; + public static final int SWP_FRAMECHANGED = 0x0020; public static final int SWP_NOACTIVATE = 0x10; public static final int SWP_NOCOPYBITS = 0x100; public static final int SWP_NOMOVE = 0x2; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java index 1e0b6f18ef..05ae85b29c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java @@ -306,7 +306,28 @@ long callWindowProc (long hwnd, int msg, long wParam, long lParam) { @Override void createHandle () { - super.createHandle (); + long editStyle = widgetStyle (); + if ((editStyle & OS.WS_BORDER) == 0) + super.createHandle (); + else { + /* + * Feature on Windows: when `Edit` control is created, it removes + * `WS_BORDER`, but then internally draws the border over the client + * area. This is undesirable because all SWT coordinates will then + * need to be adjusted by the border size. The workaround is to create + * control without `WS_BORDER` and add it just after creating. + */ + style &= ~SWT.BORDER; + super.createHandle (); + style |= SWT.BORDER; + + editStyle = OS.GetWindowLongPtr(handle, OS.GWL_STYLE); + editStyle |= OS.WS_BORDER; + OS.SetWindowLongPtr(handle, OS.GWL_STYLE, editStyle); + + OS.SetWindowPos(handle, 0, 0, 0, 0, 0, OS.SWP_NOMOVE | OS.SWP_NOSIZE | OS.SWP_NOZORDER | OS.SWP_FRAMECHANGED); + } + OS.SendMessage (handle, OS.EM_LIMITTEXT, 0, 0); if ((style & SWT.READ_ONLY) != 0) { if (applyThemeBackground () == 1) { |