Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 336600 | Differences between
and this patch

Collapse All | Expand All

(-)a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java (-19 / +28 lines)
Lines 705-738 void onFocusOut(Event e) { Link Here
705
	* that shows a caret then the caret disappears.  The fix 
705
	* that shows a caret then the caret disappears.  The fix 
706
	* is to detect this case and restore the caret.
706
	* is to detect this case and restore the caret.
707
	*/
707
	*/
708
	int threadId = OS.GetCurrentThreadId();
708
	final int threadId = OS.GetCurrentThreadId();
709
	GUITHREADINFO lpgui1 = new GUITHREADINFO();
709
	final GUITHREADINFO lpgui1 = new GUITHREADINFO();
710
	lpgui1.cbSize = GUITHREADINFO.sizeof;
710
	lpgui1.cbSize = GUITHREADINFO.sizeof;
711
	OS.GetGUIThreadInfo(threadId, lpgui1);
711
	OS.GetGUIThreadInfo(threadId, lpgui1);
712
	System.out.println(lpgui1.hwndCaret + " " + lpgui1.hwndFocus + " " + OS.GetFocus());
712
	objIOleInPlaceObject.UIDeactivate();
713
	objIOleInPlaceObject.UIDeactivate();
713
	if (SWT_RESTORECARET == 0) {
714
	if (SWT_RESTORECARET == 0) {
714
		SWT_RESTORECARET = OS.RegisterWindowMessage (new TCHAR (0, "SWT_RESTORECARET", true));
715
		SWT_RESTORECARET = OS.RegisterWindowMessage (new TCHAR (0, "SWT_RESTORECARET", true));
715
	}
716
	}
717
	System.out.println(lpgui1.hwndCaret + " " + lpgui1.hwndFocus + " " + OS.GetFocus());
716
	if (lpgui1.hwndCaret != 0) {
718
	if (lpgui1.hwndCaret != 0) {
717
		GUITHREADINFO lpgui2 = new GUITHREADINFO();
719
		getDisplay().asyncExec(new Runnable() {
718
		lpgui2.cbSize = GUITHREADINFO.sizeof;
720
			public void run() {
719
		OS.GetGUIThreadInfo(threadId, lpgui2);
721
				GUITHREADINFO lpgui2 = new GUITHREADINFO();
720
		if (lpgui2.hwndCaret == 0 && lpgui1.hwndCaret == OS.GetFocus()) {
722
				lpgui2.cbSize = GUITHREADINFO.sizeof;
721
			/*
723
				OS.GetGUIThreadInfo(threadId, lpgui2);
722
			* If the caret was not restored by SWT, put it back using
724
				System.out.println("=>" + lpgui2.hwndCaret + " " + lpgui2.hwndFocus + " " + OS.GetFocus());
723
			* the information from GUITHREADINFO.  Note that this will
725
				if (lpgui2.hwndCaret == 0 && lpgui1.hwndCaret == OS.GetFocus()) {
724
			* not be correct when the caret has a bitmap.  There is no
726
					/*
725
			* API to query the bitmap that the caret is using.
727
					 * If the caret was not restored by SWT, put it back using
726
			*/
728
					 * the information from GUITHREADINFO.  Note that this will
727
			if (OS.SendMessage (lpgui1.hwndCaret, SWT_RESTORECARET, 0, 0) == 0) {
729
					 * not be correct when the caret has a bitmap.  There is no
728
				int width = lpgui1.right - lpgui1.left;
730
					 * API to query the bitmap that the caret is using.
729
				int height = lpgui1.bottom - lpgui1.top;
731
					 */
730
				OS.CreateCaret (lpgui1.hwndCaret, 0, width, height);
732
					System.out.println("FIXING1");
731
				OS.SetCaretPos (lpgui1.left, lpgui1.top);
733
					if (OS.SendMessage (lpgui1.hwndCaret, SWT_RESTORECARET, 0, 0) == 0) {
732
				OS.ShowCaret (lpgui1.hwndCaret);
734
						int width = lpgui1.right - lpgui1.left;
735
						int height = lpgui1.bottom - lpgui1.top;
736
						OS.CreateCaret (lpgui1.hwndCaret, 0, width, height);
737
						OS.SetCaretPos (lpgui1.left, lpgui1.top);
738
						OS.ShowCaret (lpgui1.hwndCaret);
739
					}
740
				}
733
			}
741
			}
734
		}
742
		});
735
	} else if (lpgui1.hwndFocus != 0 && lpgui1.hwndFocus == OS.GetFocus()) {
743
	} else if (lpgui1.hwndFocus != 0 && lpgui1.hwndFocus == OS.GetFocus()) {
744
		System.out.println("FIXING2");
736
		OS.SendMessage (lpgui1.hwndFocus, SWT_RESTORECARET, 0, 0);
745
		OS.SendMessage (lpgui1.hwndFocus, SWT_RESTORECARET, 0, 0);
737
	}
746
	}
738
}
747
}

Return to bug 336600