public FMain() { //#if DEBUG // AOutput.QM2.UseQM2 = true; AOutput.Clear(); // SetHookToMonitorCreatedWindowsOfThisThread(); //#endif Program.MainForm = this; this.SuspendLayout(); this.AutoScaleMode = AutoScaleMode.None; this.Icon = EdStock.IconAppNormal; this.StartPosition = FormStartPosition.Manual; unsafe { var s = Program.Settings.wndPos; if (s != null && Au.Util.AConvert.Base64UrlDecode(s, out Api.WINDOWPLACEMENT p)) { p.rcNormalPosition.EnsureInScreen(); this.Bounds = p.rcNormalPosition; if (p.showCmd == Api.SW_SHOWMAXIMIZED) { this.WindowState = FormWindowState.Maximized; } } else { var wa = AScreen.Primary.WorkArea; this.Bounds = new Rectangle(wa.left + 10, wa.top + 10, wa.Width * 3 / 4, wa.Height - 20); } } //APerf.Next(); Strips.Init(); MainMenuStrip = Strips.Menubar; //APerf.Next(); Panels.Init(); this.Controls.Add(Panels.PanelManager); this.ResumeLayout(false); this.Hwnd(create: true); //this does not create child control handles. We need only of the main form. Program.Tasks = new RunningTasks(); Panels.Files.ZLoadWorkspace(CommandLine.WorkspaceDirectory); EdTrayIcon.Add(); CommandLine.OnProgramLoaded(); Program.Loaded = EProgramState.LoadedWorkspace; Program.Model.RunStartupScripts(); //APerf.Next(); //#if DEBUG // ADebug.Print("Ending form ctor. Must be no parked controls created; use SetHookToMonitorCreatedWindowsOfThisThread."); //#endif #if TRACE _MonitorGC(); #endif }
protected override void OnFormClosed(FormClosedEventArgs e) { if (Program.Loaded >= EProgramState.LoadedUI) { Program.Settings.wndPos = _Hwnd.SavePositionSizeState(); UacDragDrop.AdminProcess.Enable(false); } Program.Loaded = EProgramState.Unloading; ZCloseReason = e.CloseReason; base.OnFormClosed(e); CodeInfo.Stop(); Panels.Files.ZUnloadOnFormClosed(); EdTrayIcon.Dispose(); Program.Loaded = EProgramState.Unloaded; Application.Exit(); }