public static int Main(string[] rgArgs) { return(TeApp.Main(rgArgs)); }
public static int Main(string[] rgArgs) { try { // Enable visual styles. Ignored on Windows 2000. Needs to be called before // we create any controls! Application.EnableVisualStyles(); // REVIEW (EberhardB): Do we need the following line? .NET 2.0 puts it in if you // create a new project. // Application.SetCompatibleTextRenderingDefault(false); if (ExistingProcess != null) { try { IntPtr hWndMain = ExistingProcess.MainWindowHandle; if (hWndMain != (IntPtr)0) { Win32.SetForegroundWindow(hWndMain); //Win32.WINDOWPLACEMENT placementInfo = new Win32.WINDOWPLACEMENT(); Win32.WINDOWPLACEMENT placementInfo; Win32.GetWindowPlacement(hWndMain, out placementInfo); if (placementInfo.showCmd == (uint)Win32.WINDOWPLACEMENT.ShowWindowCommands.SW_SHOWMINIMIZED) { //placementInfo.length = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(Win32.WINDOWPLACEMENT)); //placementInfo.showCmd = (uint)Win32.WINDOWPLACEMENT.ShowWindowCommands.SW_NORMAL; //placementInfo.showCmd = (uint)Win32.WINDOWPLACEMENT.ShowWindowCommands.SW_SHOWNORMAL; //placementInfo.showCmd = (uint)Win32.WINDOWPLACEMENT.ShowWindowCommands.SW_SHOW; //placementInfo.showCmd = (uint)Win32.WINDOWPLACEMENT.ShowWindowCommands.SW_SHOWDEFAULT; placementInfo.showCmd = (uint)Win32.WINDOWPLACEMENT.ShowWindowCommands.SW_RESTORE; Win32.SetWindowPlacement(hWndMain, ref placementInfo); } // This didn't work: Form mainWnd = (Form)Control.FromHandle(hWndMain); // ActivateWindow(mainWnd); } // If there is a command line project to load, tell the other // instance to load the project if (rgArgs != null && rgArgs.Length > 0) { // Create a channel for communicating w/ the main instance // of TE. TcpChannel chan = new TcpChannel(); ChannelServices.RegisterChannel(chan, false); // Create an instance of the remote object RemoteRequest requestor = (RemoteRequest)Activator.GetObject( typeof(RemoteRequest), "tcp://*****:*****@sil.org"; appTranslationEditor.Run(); } } return(0); } catch (Exception e) { // This should catch any remaining exceptions that HandleUnhandledException() // and HandleTopLevelError() don't catch so that we can display the // "Green Screen". DisplayError(e, null); return(-1); } }
public static int Main(string[] rgArgs) { try { // Enable visual styles. Ignored on Windows 2000. Needs to be called before // we create any controls! Application.EnableVisualStyles(); // REVIEW (EberhardB): Do we need the following line? .NET 2.0 puts it in if you // create a new project. // Application.SetCompatibleTextRenderingDefault(false); if (ExistingProcess != null) { try { IntPtr hWndMain = ExistingProcess.MainWindowHandle; if (hWndMain != (IntPtr)0) { Win32.SetForegroundWindow(hWndMain); //Win32.WINDOWPLACEMENT placementInfo = new Win32.WINDOWPLACEMENT(); Win32.WINDOWPLACEMENT placementInfo; Win32.GetWindowPlacement(hWndMain, out placementInfo); if (placementInfo.showCmd == (uint)Win32.WINDOWPLACEMENT.ShowWindowCommands.SW_SHOWMINIMIZED) { //placementInfo.length = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(Win32.WINDOWPLACEMENT)); //placementInfo.showCmd = (uint)Win32.WINDOWPLACEMENT.ShowWindowCommands.SW_NORMAL; //placementInfo.showCmd = (uint)Win32.WINDOWPLACEMENT.ShowWindowCommands.SW_SHOWNORMAL; //placementInfo.showCmd = (uint)Win32.WINDOWPLACEMENT.ShowWindowCommands.SW_SHOW; //placementInfo.showCmd = (uint)Win32.WINDOWPLACEMENT.ShowWindowCommands.SW_SHOWDEFAULT; placementInfo.showCmd = (uint)Win32.WINDOWPLACEMENT.ShowWindowCommands.SW_RESTORE; Win32.SetWindowPlacement(hWndMain, ref placementInfo); } // This didn't work: Form mainWnd = (Form)Control.FromHandle(hWndMain); // ActivateWindow(mainWnd); } // If there is a command line project to load, tell the other // instance to load the project if (rgArgs != null && rgArgs.Length > 0) { // Create a channel for communicating w/ the main instance // of TE. TcpChannel chan = new TcpChannel(); ChannelServices.RegisterChannel(chan, false); // Create an instance of the remote object RemoteRequest requestor = (RemoteRequest)Activator.GetObject( typeof(RemoteRequest), "tcp://*****:*****@sil.org"; appTranslationEditor.Run(); } } return 0; } catch (Exception e) { // This should catch any remaining exceptions that HandleUnhandledException() // and HandleTopLevelError() don't catch so that we can display the // "Green Screen". DisplayError(e, null); return -1; } }