summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Cornu <ccornu>2003-07-14 20:03:11 +0000
committerChristophe Cornu <ccornu>2003-07-14 20:03:11 +0000
commit4868927bd275130c538c2b7a0fe8f1cbcc0f59a0 (patch)
tree38b418f7db7beee1a2a263c00477e44dd5e975b7
parent0e82b1623c17e532719e47ae4b56044e3bd06fd6 (diff)
downloadeclipse.platform.swt-4868927bd275130c538c2b7a0fe8f1cbcc0f59a0.tar.gz
eclipse.platform.swt-4868927bd275130c538c2b7a0fe8f1cbcc0f59a0.tar.xz
eclipse.platform.swt-4868927bd275130c538c2b7a0fe8f1cbcc0f59a0.zip
PR39011
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_custom.c25
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java29
4 files changed, 57 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h
index 76538ae4a0..3d4ef5f0bf 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h
@@ -217,6 +217,7 @@
#define NO_LoadLibraryA
#define NO_MapVirtualKeyA
#define NO_MessageBoxA
+#define NO_MonitorFromWindow
#define NO_MoveMemory__ILorg_eclipse_swt_internal_win32_DROPFILES_2I
#define NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMREBARCHEVRON_2II
#define NO_MoveMemory__Lorg_eclipse_swt_internal_win32_HELPINFO_2II
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_custom.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_custom.c
index 7377dc3870..8e38a8e84d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_custom.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_custom.c
@@ -305,6 +305,31 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(IsSP)
}
#endif
+#ifndef NO_MonitorFromWindow
+JNIEXPORT jint JNICALL OS_NATIVE(MonitorFromWindow)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ jint rc;
+ NATIVE_ENTER(env, that, "MonitorFromWindow\n")
+ //rc = (jint)MonitorFromWindow(arg0, arg1);
+ {
+ /*
+ * MonitorFromWindow is a Win2000 and Win98 specific call
+ * If you link it into swt.dll a system modal entry point not found dialog will
+ * appear as soon as swt.dll is loaded. Here we check for the entry point and
+ * only do the call if it exists.
+ */
+ HMODULE hm;
+ FARPROC fp;
+ if ((hm=GetModuleHandle("user32.dll")) && (fp=GetProcAddress(hm, "MonitorFromWindow"))) {
+ rc = (jint)(fp)(arg0, arg1);
+ }
+ }
+ NATIVE_EXIT(env, that, "MonitorFromWindow\n")
+ return rc;
+}
+#endif
+
#ifndef NO_SendMessageW__II_3I_3I
JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__II_3I_3I)
(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jintArray arg3)
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 8515ec6f0b..fd444cca96 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
@@ -648,6 +648,7 @@ public class OS {
public static final int MM_TEXT = 0x1;
public static final int MNC_CLOSE = 0x1;
public static final int MNS_CHECKORBMP = 0x4000000;
+ public static final int MONITOR_DEFAULTTONEAREST = 0x2;
public static final int MONITORINFOF_PRIMARY = 0x1;
public static final int MWMO_INPUTAVAILABLE = 0x4;
public static final int NM_CLICK = 0xfffffffe;
@@ -2269,6 +2270,7 @@ public static final native int MapWindowPoints (int hWndFrom, int hWndTo, RECT l
public static final native boolean MessageBeep (int uType);
public static final native int MessageBoxW (int hWnd, char [] lpText, char [] lpCaption, int uType);
public static final native int MessageBoxA (int hWnd, byte [] lpText, byte [] lpCaption, int uType);
+public static final native int MonitorFromWindow (int hwnd, int dwFlags);
public static final native void MoveMemory (char[] Destination, int SourcePtr, int Length);
public static final native void MoveMemory (byte [] Destination, int Source, int Length);
public static final native void MoveMemory (byte [] Destination, ACCEL Source, int Length);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
index 6c5b7f2106..ca21b03fe3 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
@@ -830,6 +830,35 @@ public Menu getMenu () {
}
/**
+ * Returns the receiver's monitor.
+ *
+ * @return the receiver's monitor
+ *
+ * @since 3.0
+ */
+public Monitor getMonitor () {
+ checkWidget ();
+ if (OS.IsWinCE || (OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) < (4 << 16 | 10)) {
+ return display.getPrimaryMonitor ();
+ }
+ int hmonitor = OS.MonitorFromWindow (handle, OS.MONITOR_DEFAULTTONEAREST);
+ MONITORINFO lpmi = new MONITORINFO ();
+ lpmi.cbSize = MONITORINFO.sizeof;
+ OS.GetMonitorInfo (hmonitor, lpmi);
+ Monitor monitor = new Monitor ();
+ monitor.handle = hmonitor;
+ monitor.x = lpmi.rcMonitor_left;
+ monitor.y = lpmi.rcMonitor_top;
+ monitor.width = lpmi.rcMonitor_right - lpmi.rcMonitor_left;
+ monitor.height = lpmi.rcMonitor_bottom - lpmi.rcMonitor_top;
+ monitor.clientX = lpmi.rcWork_left;
+ monitor.clientY = lpmi.rcWork_top;
+ monitor.clientWidth = lpmi.rcWork_right - lpmi.rcWork_left;
+ monitor.clientHeight = lpmi.rcWork_bottom - lpmi.rcWork_top;
+ return monitor;
+}
+
+/**
* Returns the receiver's parent, which must be a <code>Composite</code>
* or null when the receiver is a shell that was created with null or
* a display for a parent.