Exemplo n.º 1
0
        protected override void WndProc(ref Message msg)
        {
            // Now we should catch the WM_SYSCOMMAND message
            // and process it.

            // We override the WndProc to catch the WM_SYSCOMMAND message.
            // You don't have to look this message up in the MSDN it is defined
            // in WindowMessages enumeration.
            // The WParam of the message contains the ID which was pressed. It is the
            // same value you have passed through InsertMenu() or AppendMenu() member
            // functions of my class.

            // Just check for them and do the proper action.
            //
            if (msg.Msg == (int)WindowMessages.wmSysCommand)
            {
                switch (msg.WParam.ToInt32())
                {
                case m_ResetID:
                {
                    if (MessageBox.Show(this, "\tAre you sure?", "Question", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {                                     // Reset the Systemmenu
                        SystemMenu.ResetSystemMenu(this);
                    }
                }
                break;

                case m_AboutID:
                {                                 // Our about id
                    MessageBox.Show(this, "Written by Florian \"nohero\"" +
                                    "Stinglmayr.\nEMail: [email protected]", "About");
                }
                break;

                // TODO: Add more handles, for more menu items

                default:
                {                                 // Do nothing
                } break;
                }
            }
            // Call base class function
            base.WndProc(ref msg);
        }
Exemplo n.º 2
0
        void ResetMenuStates(bool doReset)
        {
            try
            {
                if (doReset)
                {
                    SystemMenu.ResetSystemMenu(this);
                }

                m_SystemMenu = SystemMenu.FromForm(this);

                m_SystemMenu.AppendSeparator();
                //TODO: позволяет переключится в full screen только после пересоздания формы
                m_SystemMenu.AppendMenu(m_SeparateWindow, "Allow full screen (and show the form in task bar)", this.ShowInTaskbar ? ItemFlags.mfChecked : ItemFlags.mfUnchecked);
                m_SystemMenu.AppendMenu(m_TopMode, "Keep the form \"On Top\" mode", this.TopMost ? ItemFlags.mfChecked : ItemFlags.mfUnchecked);
                m_SystemMenu.AppendMenu(m_StretchVideoToFit, "Stretch Video to Fit", this.StretchVideoToFit ? ItemFlags.mfChecked : ItemFlags.mfUnchecked);
//                m_SystemMenu.InsertSeparator(0);
//                m_SystemMenu.InsertMenu(0, m_TopMode, "Enable \"On Top\" mode", (this.TopMostManualExplicit ? ItemFlags.mfChecked : ItemFlags.mfUnchecked));
            }
            catch (NoSystemMenuException /* err */)
            {
                // Do some error handling
            }
        }