Ejemplo n.º 1
0
    /// <summary>
    /// Handles MdiChildActivate event handler.
    /// </summary>
    /// <remarks>
    /// Validates whether current MDI may lose the focus. If validation failes,
    /// reactivates invalid MDI that is losing the focus.
    /// </remarks>
    ///
    private void ValidateMdiChildActivate()
    {
        Debug.TraceLine("MdiChildActivate:  {0}",
                        ActiveMdiChild == null ? "none" : ActiveMdiChild.Name);

        MyMdiForm myMdiForm = this.lastMdiChild as MyMdiForm;

        if (this.lastMdiChild != ActiveMdiChild && myMdiForm != null)
        {
            FormBase mdiForm = myMdiForm.Tag as FormBase;

            if (mdiForm != null && mdiForm.IsDirty())
            {
                // System.Media.SystemSounds.Beep.Play ();

                mdiForm.MdiForm.Activate();

                Debug.TraceLine("MdiChildActivate: Reactivated as dirty: {0}",
                                ActiveMdiChild == null ? "none" : ActiveMdiChild.Name);
            }
        }

        this.lastMdiChild = ActiveMdiChild;

        this.InfoMessage = ActiveMdiChild == null ? "Ready." : ActiveMdiChild.Text;
    }
Ejemplo n.º 2
0
    /////////////////////////////////////////////////////////////////////////////////

    #region [ Overriden Base Methods ]

    /// <summary>
    /// Intercepts Windows messages.
    /// </summary>
    /// <remarks>
    /// Prevents combobox to respond to left mouse button keys and wheel
    /// in read-only mode. Mouse wheel events are forwarded to MyMdiForm parent.
    /// </remarks>
    ///
    protected override void WndProc(ref Message m)
    {
        if (ReadOnly)   // Ignore left mouse button and forward mouse wheel to parent
        {
            switch (m.Msg)
            {
            case 0x0201:     // WM_LBUTTONDOWN
            case 0x0202:     // WM_LBUTTONUP
            case 0x0203:     // WM_LBUTTONDBLCLK
                return;

            case 0x020A:     // WM_MOUSEWHEEL
                MyMdiForm parent = Parent as MyMdiForm;
                if (parent != null)
                {
                    int            delta = ((int)m.WParam) >> 16;    // high-order word
                    int            xpos  = ((int)m.LParam) & 0xFFFF; // low-order word
                    int            ypos  = ((int)m.LParam) >> 16;    // high-order word
                    MouseEventArgs e     = new MouseEventArgs(0, 0, xpos, ypos, delta);
                    parent.ProcessMouseWheel(e);
                }
                return;
            }
        }
        else // Ignore mouse wheel when not read-only
        {
            switch (m.Msg)
            {
            case 0x020A:     // WM_MOUSEWHEEL
                return;
            }
        }

        base.WndProc(ref m);
    }
Ejemplo n.º 3
0
    /////////////////////////////////////////////////////////////////////////////////////

    #region [ Protected Constructor ]

    /// <summary>
    /// Initializes a new instance of the FormBase with specified caption and dimensions.
    /// </summary>
    /// <remarks>
    /// Note that protected constructor forbidds instantiation of the FormBase objects
    /// outside the dervied classes from FormBase.
    /// </remarks>
    ///
    protected FormBase(string caption, int width, int height)
    {
        Caption             = caption;
        ReadOnly            = true;
        IgnoreRecordChanges = false;

        /////////////////////////////////////////////////////////////////////////////////

        MdiForm = new MyMdiForm(width, height)
        {
            Tag = this, ReadOnly = true
        };

        TraceID = MdiForm.Name + "-[" + Caption + "]";

        InitializeMdiForm();
    }
Ejemplo n.º 4
0
    /////////////////////////////////////////////////////////////////////////////////////

    /// <summary>
    /// Forces validation of the window and executes delegate if
    /// validation was successfull.
    /// </summary>
    /// <param name="method">Delegate to be executed if validation was ok.</param>
    /// <returns>True if validation was successfull.</returns>
    ///
    public static bool IfValidateOk(this MdiClient control, Action method = null)
    {
        Form parent = control.Parent as Form;

        if (parent != null)
        {
            MyMdiForm mdiForm = parent.ActiveMdiChild as MyMdiForm;

            if (mdiForm != null)
            {
                return(mdiForm.IfValidateOk(method));
            }
        }

        if (method != null)
        {
            method();
        }

        return(true);
    }