Example #1
0
        static public System.IntPtr PrepareMainWndReady(int cTimeOut)
        {
            IntPtr mainWnd = GenericWindow.FindWindow("rctrl_renwnd32", null);
            int    begin   = Environment.TickCount;

            Tracer._Trace("Waiting while main window is loaded");
            while ((int)mainWnd == 0 && (Environment.TickCount - begin) < cTimeOut)
            {
                mainWnd = GenericWindow.FindWindow("rctrl_renwnd32", null);
            }
            return(mainWnd);
        }
Example #2
0
        private void OnStart(object sender, System.EventArgs e)
        {
            SettingSaver.Save(Controls);
            Settings.LoadSettings();
            string path = RegUtil.GetValue(Registry.LocalMachine, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\OUTLOOK.EXE", "") as string;

            if (path == null)
            {
                path = "Outlook.exe";
            }

            _process = new Process();
            _process.StartInfo.FileName = path;
            if (Settings.ProcessWindowStyle == "Hidden")
            {
                _process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            }
            else
            {
                _process.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
            }
            _process.StartInfo.UseShellExecute = Settings.UseShellExecuteForOutlook;
            _process.Start();
            _mainWnd = GenericWindow.FindWindow("rctrl_renwnd32", null);
            int begin = Environment.TickCount;

            Tracer._Trace("Waiting while main window is loaded");
            while ((int)_mainWnd == 0 && (Environment.TickCount - begin) < 3000)
            {
                _mainWnd = GenericWindow.FindWindow("rctrl_renwnd32", null);
            }
            Win32Declarations.SendMessage(_mainWnd, Win32Declarations.WM_ACTIVATEAPP, (IntPtr)1, IntPtr.Zero);
            Win32Declarations.SendMessage(_mainWnd, Win32Declarations.WM_NCACTIVATE, (IntPtr)0x200001, IntPtr.Zero);
            Win32Declarations.SendMessage(_mainWnd, Win32Declarations.WM_ACTIVATE, (IntPtr)0x200001, IntPtr.Zero);
            Win32Declarations.SendMessage(_mainWnd, Win32Declarations.WM_ACTIVATETOPLEVEL, (IntPtr)0x200001, (IntPtr)0x13FBE8);
            Win32Declarations.SendMessage(_mainWnd, Win32Declarations.WM_SETFOCUS, IntPtr.Zero, IntPtr.Zero);
            _close.Enabled = true;
        }