Exemple #1
0
        private void OnTargetWindowHandleRecreated(object sender, EventArgs e)
        {
            // in the case that the handle for the form is recreated we need to set
            // up the handles to point to the new window handle for the form.

            _system.SetNativeTargetWindow(_target);
            _minimize.SetNativeTargetWindow(_target);
            _close.SetNativeTargetWindow(_target);
            _restore.SetNativeTargetWindow(_target);

            IntPtr hMenu = User32.GetSystemMenu(new HandleRef(this, Control.GetSafeHandle(_target)), bRevert: BOOL.FALSE);

            _system.SetNativeTargetMenu(hMenu);
            _minimize.SetNativeTargetMenu(hMenu);
            _close.SetNativeTargetMenu(hMenu);
            _restore.SetNativeTargetMenu(hMenu);

            // clear off the System DropDown.
            if (_system.HasDropDownItems)
            {
                // next time we need one we'll just fetch it fresh.
                _system.DropDown.Items.Clear();
                _system.DropDown.Dispose();
            }

            _system.Image = GetTargetWindowIcon();
        }