SetParentでOutlook Mailgridを制御し、Mailgridが変更された場合はResize(MoveWindow)を無効にします。Outlook MailgridでCustomControlを設定するには?
これは機能しますが、リサイズではコントロールがフリッカーを開始します。
マイコントロールは、OutlookのMailgridを置き換えるものです。 mailpreviewを変更するには、私のコントロールで元のmailgridの選択を変更するだけです。
私のコントロールの親は、Outlookのメインウィンドウです。私は既にMailgridのウィンドウを閉じようとしましたが、それは助けになりませんでした。
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);
}
}
の変化に対応し、それがの変更・イベント
//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();
絵画で
//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));
親だ設定する
クラス私のコントロール
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)
}
/// EDIT
私はペイント順序を見ることができたDoPaintのMethodeのにThread.Sleep(1000)
を追加した後。 サイズ変更後、コントロールが瞬時に表示され、その後Outlook Mailgridが自分のコントロールをオーバーパイントします。 base.WndProc(ref m);
befor OnChange();
を設定しようとしましたが、何も変更されませんでした。 これが問題の解決に役立つことを願っています。私は、すべてのOutlookウィンドウを聞くためにしようとしたいくつかのテストの後/// EDIT
とGraphics.Clear
それらをオレンジ。 なぜか分かりませんが、これでも動作しません。ほぼすべてのサイズ変更は見通しによって行われます。
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();
}
}