Bug 403559 - Intermittent loss of caret (or cursor?)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java
index 504eebf..ccb511c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java
@@ -710,14 +710,14 @@
 	lpgui1.cbSize = GUITHREADINFO.sizeof;
 	OS.GetGUIThreadInfo(threadId, lpgui1);
 	objIOleInPlaceObject.UIDeactivate();
+	if (SWT_RESTORECARET == 0) {
+		SWT_RESTORECARET = OS.RegisterWindowMessage (new TCHAR (0, "SWT_RESTORECARET", true));
+	}
 	if (lpgui1.hwndCaret != 0) {
 		GUITHREADINFO lpgui2 = new GUITHREADINFO();
 		lpgui2.cbSize = GUITHREADINFO.sizeof;
 		OS.GetGUIThreadInfo(threadId, lpgui2);
 		if (lpgui2.hwndCaret == 0 && lpgui1.hwndCaret == OS.GetFocus()) {
-			if (SWT_RESTORECARET == 0) {
-				SWT_RESTORECARET = OS.RegisterWindowMessage (new TCHAR (0, "SWT_RESTORECARET", true));
-			}
 			/*
 			* If the caret was not restored by SWT, put it back using
 			* the information from GUITHREADINFO.  Note that this will
@@ -733,6 +733,9 @@
 			}
 		}
 	}
+	if (lpgui1.hwndFocus != 0 && lpgui1.hwndFocus == OS.GetFocus()) {
+		OS.SendMessage (lpgui1.hwndFocus, SWT_RESTORECARET, 0, 0);
+	}
 }
 private int OnFocus(int fGotFocus) {
 	return COM.S_OK;