示例#1
0
文件: WinProc.cs 项目: labeuze/source
        public void Init(Form parentWindow, IWinProc wp, Icon icon, WAOptions options)
        {

            if (parentWindow == null)
                parentWindow = new MainBaseForm();

            if (wp == null)
            {
                if (parentWindow is IWinProc)
                    wp = (IWinProc)parentWindow;
                else
                    wp = new WinProc(parentWindow);
            }
            parentWindow.ShowInTaskbar = true;
            parentWindow.Load += new EventHandler(parentWindow_Load);

            wp.MessageEvent += new MessageProc(WndProc_ParentWindow);
            gParentWindow = new WindowData() { Form = parentWindow, WinProc = wp, EnableCtrlF4Close = false, DisableAltF4 = false, CloseApplicationOnAltF4 = false };

            //AppMessageFilter = new MessageFilter();
            //AppMessageFilter.PreFilterMessageEvent += new MessageFilter.PreFilterMessageProc(AppPreFilterMessage);
            //Application.AddMessageFilter(AppMessageFilter);

            // gestion CTRL-TAB, CTRL-F4, ALT-F4
            gKeyboardHook = new KeyboardHook();
            gKeyboardHook.HookEvent += new KeyboardHook.HookProc(KeyboardHookProc);

            //gPreWindowHook = new PreWindowHook();
            //gPreWindowHook.HookEvent += new PreWindowHook.HookProc(PreWindowHookProc);

            //gPostWindowHook = new PostWindowHook();
            //gPostWindowHook.HookEvent += new PostWindowHook.HookProc(PostWindowHookProc);

            //gGetMessageWindowHook = new GetMessageWindowHook();
            //gGetMessageWindowHook.HookEvent += new GetMessageWindowHook.HookProc(GetMessageWindowHookProc);
            //gGetMessageWindowHook.Trace = true;

            gbMinimizeParentWindowWhenMinimize = false;
            if ((options & WAOptions.MinimizeParentWindowWhenMinimize) == WAOptions.MinimizeParentWindowWhenMinimize)
                gbMinimizeParentWindowWhenMinimize = true;
            gbHideWindowWhenMinimize = false;
            if ((options & WAOptions.HideWindowWhenMinimize) == WAOptions.HideWindowWhenMinimize)
                gbHideWindowWhenMinimize = true;
            gbHideWindowWhenClose = false;
            if ((options & WAOptions.HideWindowWhenClose) == WAOptions.HideWindowWhenClose)
                gbHideWindowWhenClose = true;
            gbEnableCtrlF4Close = false;
            if ((options & WAOptions.EnableCtrlF4Close) == WAOptions.EnableCtrlF4Close)
                gbEnableCtrlF4Close = true;
            gbDisableAltF4 = false;
            if ((options & WAOptions.DisableAltF4) == WAOptions.DisableAltF4)
                gbDisableAltF4 = true;
            gbCloseApplicationOnAltF4 = false;
            if ((options & WAOptions.CloseApplicationOnAltF4) == WAOptions.CloseApplicationOnAltF4)
                gbCloseApplicationOnAltF4 = true;
            if ((options & WAOptions.CreateNotifyIcon) == WAOptions.CreateNotifyIcon)
                CreateNotifyIcon(icon);
            Icon = icon;

            if (gbTrace)
                pb.Trace.WriteLine("WindowsApp                        : new WindowsApp                            window {0,-25} hWnd {1}", parentWindow.Text, parentWindow.Handle);
        }
示例#2
0
文件: WinProc.cs 项目: labeuze/source
 public WindowsApp(Icon icon, WAOptions options)
 {
     Init(null, null, icon, options);
 }