Pregunta

Estoy intentando configurar mi control sobre el Mailgrid Outlook con SetParent y de cambio de tamaño (MoveWindow) e invalidar si el Mailgrid cambió.

Esto funciona, pero el cambio de tamaño del control se inicia el parpadeo.

Mi control es un reemplazo de Mailgrid de Outlook. Para cambiar el mailpreview acabo de cambiar la selección de la mailgrid original a través de mi control.

El Padre de mi control es la ventana principal de Outlook. Ya he tratado de cerrar la ventana Mailgrid, pero eso no ayuda.

El parpadeo se detiene si fijo el del Mailgrid como los padres, pero en este caso que parpadea si cambio de la selección, y no es posible sacar mi control sobre el mailsearch-ventana.

¿Alguien sabe cómo detener el parpadeo extrem?

Clase para manejar los cambios de mensajes de Outlook Mailgrid

sealed class SubWindow : NativeWindow
{

    public event EventHandler Changed;

    protected override void WndProc(ref Message m)
    {                
        if (m.Msg == (int)(NativEnums.WindowMessage.WM_SIZE) ||
            m.Msg == (int)(NativEnums.WindowMessage.WM_WINDOWPOSCHANGED) ||
            m.Msg == (int)(NativEnums.WindowMessage.WM_WINDOWPOSCHANGING) ||
            m.Msg == (int)(NativEnums.WindowMessage.WM_ERASEBKGND) ||
            m.Msg == (int)(NativEnums.WindowMessage.WM_NCHITTEST) ||
            m.Msg == (int)(NativEnums.WindowMessage.WM_NCCALCSIZE) ||
            m.Msg == (int)(NativEnums.WindowMessage.WM_PAINT) ||
            m.Msg == (int)(NativEnums.WindowMessage.WM_NCPAINT) ||
            m.Msg == (int)(NativEnums.WindowMessage.WM_PRINT) ||
            m.Msg == (int)(NativEnums.WindowMessage.WM_PRINTCLIENT) ||
            m.Msg == (int)(NativEnums.WindowMessage.WM_SETREDRAW) ||
            m.Msg == (int)(NativEnums.WindowMessage.WM_MOVE)
            )
        {
            OnChanged();
        }               

        base.WndProc(ref m);
        //I have already tried to ignore wm_paint, but it still painted
        //if (m.Msg != (int)NativEnums.WindowMessage.WM_PAINT)
        //{
        //  base.WndProc(ref m);
        //}         

    }

    private void OnChanged()
    {
        if (Changed != null)
            Changed(this, null);
    }
}

La creación de la Reunión de Oyente y Control y la pusieron los padres

//Is the Class above
SubWindow lw = new SubWindow();
lw.AssignHandle(ListHandle);
lw.Changed += new EventHandler(lw_Changed);

//Gets the IntPtr of the Mailgrid
//MainWindow is the Outlook main-window window
IntPtr ListHandle = GetSizes.GetMailFolderIntPtr(MainWindow);

//Gets the Rectangle of the Mailgrid
System.Drawing.Rectangle listsize = GetSizes.GetMailfolderSize(MainWindow, ListHandle);

//mc is the Custom Control
MoveWindow(mc.Handle, listsize.Left, listsize.Top, listsize.Width, listsize.Height, false);
SetParent(mc.Handle, MainWindow);
SetWindowLong(mc.Handle, (int)NativEnums.GetWindowLongConst.GWL_STYLE, (uint)(NativEnums.WindowStyles.WS_CHILD | NativEnums.WindowStyles.WS_VISIBLE));

Sobre el Cambio-Evento

//Gets the Rectangle of the Mailgrid
System.Drawing.Rectangle listsize = GetSizes.GetMailfolderSize(MainWindow, ListHandle);
//Move and size the CustomControl to the Mailgrid Rectangle
MoveWindow(mc.Handle, listsize.Left, listsize.Top, listsize.Width, listsize.Height, false);
//Invalidate my Control
mc.Invalidate();

Pintura de mi control

protected override void OnPaint(PaintEventArgs e)
{
    DoPaint(e.Graphics);

    //base.OnPaint(e);
}

protected override void OnPaintBackground(PaintEventArgs pevent)
{
    //base.OnPaintBackground(pevent);
}

public void DoPaint(Graphics g)
{
    g.Clear(BackColor);
    //Here comes the painting of the GridRows (only the visible rows)
}

/// editar

Después de la adición de un Thread.Sleep(1000) a la methode la DoPaint i era capaz de ver el orden de pintura. Después de cambiar el tamaño, mis programas de control por un instante, después el Mailgrid de Outlook overpaints mi control. He tratado de conjunto base.WndProc(ref m); se acaben OnChange(); pero nada cambió. Espero que esto ayude a resolver el problema.

/// editar

Después de algunas pruebas he tratado de escuchar a todas las ventanas de Outlook y Graphics.Clear ellas naranja. No sé por qué, pero incluso esto no funciona. Si bien el cambio de tamaño casi todo lo que se dibuja por Outlook.

protected override void WndProc(ref Message m)
{
    base.WndProc(ref m);

        /////////////////////////////////////////////////////
        //  Here i clear the complete window (all windows) //
        /////////////////////////////////////////////////////
    using (Graphics g = Graphics.FromHwnd(m.HWnd))
        g.Clear(Color.Orange);

    if (m.Msg == (int)(NativEnums.WindowMessage.WM_SIZE) ||
        m.Msg == (int)(NativEnums.WindowMessage.WM_WINDOWPOSCHANGED) ||
        m.Msg == (int)(NativEnums.WindowMessage.WM_WINDOWPOSCHANGING) ||
        m.Msg == (int)(NativEnums.WindowMessage.WM_WINDOWPOSCHANGING) ||
        m.Msg == (int)(NativEnums.WindowMessage.WM_ERASEBKGND) ||
        m.Msg == (int)(NativEnums.WindowMessage.WM_NCHITTEST) ||
        m.Msg == (int)(NativEnums.WindowMessage.WM_NCCALCSIZE) ||
        m.Msg == (int)(NativEnums.WindowMessage.WM_PAINT) ||
        m.Msg == (int)(NativEnums.WindowMessage.WM_NCPAINT) ||
        m.Msg == (int)(NativEnums.WindowMessage.WM_PRINT) ||
        m.Msg == (int)(NativEnums.WindowMessage.WM_PRINTCLIENT) ||
        m.Msg == (int)(NativEnums.WindowMessage.WM_SETREDRAW) ||
        m.Msg == (int)(NativEnums.WindowMessage.WM_MOVE)
        )
    {
        OnChanged();
    }               

}
¿Fue útil?

Solución

Me han resuelto el problema mediante la adición al oyente al "marco divisor" de Outlook. Por alguna razón, Outlook establece la Mailgrid invisible y pinturas directo en la ventana principal. (La ventana principal no hay nada windowmessage)

Ahora también pintura en WM_WINDOWPOSCHANGING WM_WINDOWPOSCHANGED WM_SETREDRAW mi control sobre la ventana principal.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top