Exemplo n.º 1
0
 protected override void WndProc(ref System.Windows.Forms.Message m)
 {
     base.WndProc(ref m);
     if (m.Msg == WM_COMMAND)
     {
         FormMain_OnWmCommand(m.WParam.ToInt32());
     }
     else if (m.Msg == WM_HOTKEY)
     {
         FormMain_OnWmHotKey(m.WParam.ToInt32());
     }
     else if (m.Msg == WM_SYSCOMMAND)
     {
         if (MainSettings.MinHide && m.WParam.ToInt32() == 0xF20)//SC_MINIMIZE
         {
             Hide();
         }
     }
     //WndProc部分交予 Native 控制
     if (_isNativeBridgeLoaded)
     {
         MainNativeBridge.WndProc(ref m);
     }
 }
Exemplo n.º 2
0
        private void AppOnPreLoad()
        {
            //初始化函数

            //初始化桥
            mainNativeBridge = new MainNativeBridge(this);
            mainNativeBridge.exitCallBack = AppExit;
            mainNativeBridge.terminateImporantWarnCallBack = TermintateImporantProcess;
            mainNativeBridge.coreWndProc = (WNDPROC)Marshal.GetDelegateForFunctionPointer(MAppSetCallBack(IntPtr.Zero, 0), typeof(WNDPROC));
            mainNativeBridge.InitCallbacks();

            _isNativeBridgeLoaded = true;

            MainSettings = new MainSettings(this);

            //加载设置和所有页的代码
            AppLoadPages();
            AppLoadSettings();
            AppLoadAllMenuStyles();

            //标题
            SetConfig("LastWindowTitle", "AppSetting", Text);
            Text = GetConfig("Title", "AppSetting", "任务管理器");
            if (Text == "")
            {
                Text = LanuageFBuffers.Str_AppTitle;
            }

            new System.Threading.Thread(mainPagePerf.PerfInitTray).Start();

            //系统位数
#if _X64_
            Log("64 Bit OS ");
            Is64OS = true;
#else
            Is64OS = MIs64BitOS();
            Log(Is64OS ? "64 Bit OS but 32 bit app " : "32 Bit OS");
#endif
            IsAdmin = MIsRunasAdmin();

            //判断是否支持通用应用(win8 以上)
            SysVer.Get();
            if (!SysVer.IsWin8Upper())
            {
                tabControlMain.TabPages.Remove(tabPageUWPCtl);
            }
            else
            {
                M_UWP_Init();
            }

            //提升权限
            if (!MGetPrivileges())
            {
                TaskDialog.Show(LanuageMgr.GetStr("FailedGetPrivileges"), LanuageFBuffers.Str_AppTitle, "", TaskDialogButton.OK, TaskDialogIcon.Warning);
            }

            //tab 头 的自定义
            TaskMgrTabHeader tabHeader = new TaskMgrTabHeader(tabControlMain);
            Controls.Add(tabHeader);
            tabHeader.Dock   = DockStyle.Top;
            tabHeader.Height = 27;
            tabHeader.BringToFront();
            tabHeader.Font = tabControlMain.Font;
            if (IsSimpleView)
            {
                tabHeader.Visible = false;
            }

            //Shell Icon
            IntPtr shellIconPtr   = MGetShieldIcon2();
            Icon   shellIcon      = Icon.FromHandle(shellIconPtr);
            Bitmap shellIcoBtimap = MainUtils.IconToBitmap(shellIcon, 16, 16);

            check_showAllProcess.Image     = shellIcoBtimap;
            linkRebootAsAdmin.Image        = shellIcoBtimap;
            linkRestartAsAdminDriver.Image = shellIcoBtimap;

            DestroyIcon(shellIconPtr);
        }