I use the code to make a C# application embeded in Java application. But I can't set the focus on C# application.
hwnd = OS.FindWindow(null, new TCHAR(0, title, true));
int oldStyle = OS.GetWindowLong(hwnd, OS.GWL_STYLE);
OS.SetWindowLong(hwnd, OS.GWL_STYLE, oldStyle & ~OS.WS_BORDER);
OS.SetParent(hwnd, composite.handle);
OS.SendMessage(hwnd, OS.WM_SYSCOMMAND, OS.SC_MAXIMIZE, 0);
OS.SetForegroundWindow(PlatformUI.getWorkbench().getWorkbenchWindows()[0].getShell().handle);
To set focus to a Windows application I use the following method:
Required Imports:
The method:
This method will also expand the application window should it have been minimized onto the task bar as well as set focus upon it unless of course the integer value of 2 is supplied to the optional windowState parameter which tells the method to gain focus on the application but in its minimized state. If the application is not minimized then it minimizes it.