質問

Outlook MailGridをSetParentとResize(MoveWindow)でコントロールし、MailGridが変更された場合に無効にしようとしています。

これは機能しますが、サイズ変更時にコントロールがフリッカーを開始します。

私のコントロールは、OutlookのMailGridの置き換えです。 MailPreviewを変更するには、コントロールを介して元のMailGridの選択を変更するだけです。

私のコントロールの親は、Outlook Main-Windowです。私はすでにMailGridウィンドウを閉じようとしましたが、それは役に立ちませんでした。

FlickerはMailGridを親として設定すると停止しますが、この場合、選択を変更するとちらつき、MailSearch-Windowを制御することはできません。

誰かが極端なちらつきを止める方法を知っていますか?

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);
    }
}

イベントリストナーとコントロールを作成して、それを親に設定します

//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));

変更イベント

//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();

私のコントロールの絵

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)
}

/// 編集

追加した後 Thread.Sleep(1000) Dopaint Methodeに、私は絵画の秩序を見ることができました。サイズを変更した後、私のコントロールはすぐに現れ、その後Outlook MailGridは私のコントロールを高すぎます。設定しようとしました base.WndProc(ref m); のために OnChange(); しかし、何も変わりませんでした。これが問題を解決するのに役立つことを願っています。

/// 編集

いくつかのテストの後、私はすべてのOutlookウィンドウを聞こうとしました Graphics.Clear それらはオレンジ色です。理由はわかりませんが、これでさえうまくいきません。ほぼすべてをサイズ変更しながら、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();
    }               

}
役に立ちましたか?

解決

リスナーをOutlook「Frame Splitter」に追加することで、問題を解決しました。何らかの理由で、OutlookはMailGridを見えないものに設定し、メインウィンドウに直接塗装します。 (メインウィンドウはウィンドウメッセージを取得しません)

私も今ペイントします WM_WINDOWPOSCHANGING WM_WINDOWPOSCHANGED WM_SETREDRAW メインウィンドウを制御します。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top