BeginUpdate/EndUpdate causing mouse move

  • Thread starter Thread starter abhishek ghuwalewala
  • Start date Start date
A

abhishek ghuwalewala

I have implemented a custom control with BeginUpdate/EndUpdate
functionality. The implementation of BeginUpdate basically sends the
WM_SETREDRAW message by P/Invoking SendMessage and setting wparam to 0 and
EndUpdate sends the same message with wparam = -1. When I invoke these
methods on my custom control, I am also getting the MouseMove event. Has
anyone else seen this? Is there a way to prevent the MouseMove event on the
control when BeginUpdate/EndUpdate is called?

Thanks,
Abhishek
 
Hi abhishek.
Thanks for your post!
You mean your mousemove event of your control or your form is fired when
you invoke the P/Invoke SendMessage
method?
I made a small program and tried to repro your problem, however I didn't
get any mouse move event on the user control or on the Form when invoking
these two methods.
I pasted my test code after the signature, you may try it on your system.
Probably it will be helpful if you could give me a
small sample project to repro this problem.

Thanks for using MSDN Newsgroup!!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!

<code file="MyUserControl.cs">
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace WinForm_BeginEndUpdate_MouseMove
{
/// <summary>
/// Summary description for MyUserControl.
/// </summary>
public class MyUserControl : System.Windows.Forms.UserControl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public MyUserControl()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();

// TODO: Add any initialization after the InitializeComponent call

}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
//
// MyUserControl
//
this.BackColor = System.Drawing.SystemColors.Desktop;
this.Name = "MyUserControl";
this.Size = new System.Drawing.Size(368, 424);

}
#endregion

private class NativeMethods
{
[DllImport("user32.dll")]
private extern static int SendMessage(IntPtr hwnd, uint nMsg,
int wParam, int lParam);
private const int WM_SETREDRAW = 0x000B;
public static void BeginUpdate(IntPtr hwnd)
{
SendMessage(hwnd,WM_SETREDRAW,0,0);
}
public static void EndUpdate(IntPtr hwnd)
{
SendMessage(hwnd,WM_SETREDRAW,-1,0);
}

}


public void BeginUpdate()
{
NativeMethods.BeginUpdate(Handle);
}
public void EndUpdate()
{
NativeMethods.EndUpdate(Handle);
}


protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove (e);
System.Diagnostics.Debug.WriteLine("MouseMove received");
}
public void DoUpdate()
{
Graphics g = CreateGraphics();
g.FillRectangle(Brushes.Indigo,this.Bounds);
g.Dispose();
}
}
}
</code>
<code file="Form1.cs">
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WinForm_BeginEndUpdate_MouseMove
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private WinForm_BeginEndUpdate_MouseMove.MyUserControl myUserControl1;
private System.Timers.Timer timer1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.myUserControl1 = new
WinForm_BeginEndUpdate_MouseMove.MyUserControl();
this.timer1 = new System.Timers.Timer();
((System.ComponentModel.ISupportInitialize)(this.timer1)).BeginInit();
this.SuspendLayout();
//
// myUserControl1
//
this.myUserControl1.BackColor = System.Drawing.SystemColors.Desktop;
this.myUserControl1.Location = new System.Drawing.Point(72, 64);
this.myUserControl1.Name = "myUserControl1";
this.myUserControl1.Size = new System.Drawing.Size(256, 240);
this.myUserControl1.TabIndex = 2;
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Interval = 500;
this.timer1.SynchronizingObject = this;
this.timer1.Elapsed += new
System.Timers.ElapsedEventHandler(this.timer1_Elapsed);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(408, 421);
this.Controls.Add(this.myUserControl1);
this.Name = "Form1";
this.Text = "Form1";
this.MouseMove += new
System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);
((System.ComponentModel.ISupportInitialize)(this.timer1)).EndInit();
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void Form1_MouseMove(object sender,
System.Windows.Forms.MouseEventArgs e)
{
System.Diagnostics.Debug.WriteLine("MainForm MouseMove received");
}

private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs
e)
{
myUserControl1.BeginUpdate();
System.Diagnostics.Debug.WriteLine("BeginUpdate");
myUserControl1.DoUpdate();
myUserControl1.EndUpdate();
System.Diagnostics.Debug.WriteLine("EndUpdate");

}
}
}

</code>
 
Another interesting note...Calling BeingUpdate/EndUpdate on the ListBox
control does not exhibit this behavior. Is there something additional I need
to do, besides sending the message to get the correct behavior (no mouse
move event)?

Thanks,
Abhishek
 
Hi abhishek,
Thanks for your sample, I reproed your problem now.
For now, I haven't found a way to prevent MouseMove method to be called.
However, since BeginUpdate/Endupate is called by yourself, could you add a
boolean flag before actually executing your codes in the MouseMove?
such as
InUpdating = false;
void BeginUpdate()
{
InUpdating = true;
SendMessage ....
}
void EndUpdate()
{
SendMessage() ...
InUpdating = false;
}
void MouseMove( ....)
{
if(!IsUpdating)
{
DoMouseMove();
}
}

Does this work around solve your problem?
Please be free to post on the group, if you still have problem on this
issue.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!

--------------------
| From: "abhishek ghuwalewala" <[email protected]>
| References: <uV#[email protected]>
<[email protected]>
| Subject: Re: BeginUpdate/EndUpdate causing mouse move
| Date: Fri, 24 Oct 2003 11:05:22 -0500
| Lines: 638
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| NNTP-Posting-Host: client-64-158.natinst.com 130.164.64.158
| Path:
cpmsftngxa06.phx.gbl!cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.
phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:55191
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| Ying-Shen,
|
| Thanks for your prompt reply. I am attaching a small sample project that
| reproduces the problem. The instructions for reproducing the problem are
| described in the application.
|
| Thanks,
| Abhishek
|
| | > Hi abhishek.
| > Thanks for your post!
| > You mean your mousemove event of your control or your form is fired when
| > you invoke the P/Invoke SendMessage
| > method?
| > I made a small program and tried to repro your problem, however I didn't
| > get any mouse move event on the user control or on the Form when
invoking
| > these two methods.
| > I pasted my test code after the signature, you may try it on your
system.
| > Probably it will be helpful if you could give me a
| > small sample project to repro this problem.
| >
| > Thanks for using MSDN Newsgroup!!
| >
| > Best regards,
| >
| > Ying-Shen Yu [MSFT]
| > Microsoft Online Partner Support
| > Get Secure! - www.microsoft.com/security
| >
| > This posting is provided "AS IS" with no warranties and confers no
rights.
| > You should not reply this mail directly, "Online" should be removed
before
| > sending, Thanks!
| >
| > <code file="MyUserControl.cs">
| > using System;
| > using System.Collections;
| > using System.ComponentModel;
| > using System.Drawing;
| > using System.Data;
| > using System.Windows.Forms;
| > using System.Runtime.InteropServices;
| >
| > namespace WinForm_BeginEndUpdate_MouseMove
| > {
| > /// <summary>
| > /// Summary description for MyUserControl.
| > /// </summary>
| > public class MyUserControl : System.Windows.Forms.UserControl
| > {
| > /// <summary>
| > /// Required designer variable.
| > /// </summary>
| > private System.ComponentModel.Container components = null;
| >
| > public MyUserControl()
| > {
| > // This call is required by the Windows.Forms Form Designer.
| > InitializeComponent();
| >
| > // TODO: Add any initialization after the InitializeComponent call
| >
| > }
| >
| > /// <summary>
| > /// Clean up any resources being used.
| > /// </summary>
| > protected override void Dispose( bool disposing )
| > {
| > if( disposing )
| > {
| > if(components != null)
| > {
| > components.Dispose();
| > }
| > }
| > base.Dispose( disposing );
| > }
| >
| > #region Component Designer generated code
| > /// <summary>
| > /// Required method for Designer support - do not modify
| > /// the contents of this method with the code editor.
| > /// </summary>
| > private void InitializeComponent()
| > {
| > //
| > // MyUserControl
| > //
| > this.BackColor = System.Drawing.SystemColors.Desktop;
| > this.Name = "MyUserControl";
| > this.Size = new System.Drawing.Size(368, 424);
| >
| > }
| > #endregion
| >
| > private class NativeMethods
| > {
| > [DllImport("user32.dll")]
| > private extern static int SendMessage(IntPtr hwnd, uint nMsg,
| > int wParam, int lParam);
| > private const int WM_SETREDRAW = 0x000B;
| > public static void BeginUpdate(IntPtr hwnd)
| > {
| > SendMessage(hwnd,WM_SETREDRAW,0,0);
| > }
| > public static void EndUpdate(IntPtr hwnd)
| > {
| > SendMessage(hwnd,WM_SETREDRAW,-1,0);
| > }
| >
| > }
| >
| >
| > public void BeginUpdate()
| > {
| > NativeMethods.BeginUpdate(Handle);
| > }
| > public void EndUpdate()
| > {
| > NativeMethods.EndUpdate(Handle);
| > }
| >
| >
| > protected override void OnMouseMove(MouseEventArgs e)
| > {
| > base.OnMouseMove (e);
| > System.Diagnostics.Debug.WriteLine("MouseMove received");
| > }
| > public void DoUpdate()
| > {
| > Graphics g = CreateGraphics();
| > g.FillRectangle(Brushes.Indigo,this.Bounds);
| > g.Dispose();
| > }
| > }
| > }
| > </code>
| > <code file="Form1.cs">
| > using System;
| > using System.Drawing;
| > using System.Collections;
| > using System.ComponentModel;
| > using System.Windows.Forms;
| > using System.Data;
| >
| > namespace WinForm_BeginEndUpdate_MouseMove
| > {
| > /// <summary>
| > /// Summary description for Form1.
| > /// </summary>
| > public class Form1 : System.Windows.Forms.Form
| > {
| > private WinForm_BeginEndUpdate_MouseMove.MyUserControl myUserControl1;
| > private System.Timers.Timer timer1;
| > /// <summary>
| > /// Required designer variable.
| > /// </summary>
| > private System.ComponentModel.Container components = null;
| >
| > public Form1()
| > {
| > //
| > // Required for Windows Form Designer support
| > //
| > InitializeComponent();
| >
| > //
| > // TODO: Add any constructor code after InitializeComponent call
| > //
| > }
| >
| > /// <summary>
| > /// Clean up any resources being used.
| > /// </summary>
| > protected override void Dispose( bool disposing )
| > {
| > if( disposing )
| > {
| > if (components != null)
| > {
| > components.Dispose();
| > }
| > }
| > base.Dispose( disposing );
| > }
| >
| > #region Windows Form Designer generated code
| > /// <summary>
| > /// Required method for Designer support - do not modify
| > /// the contents of this method with the code editor.
| > /// </summary>
| > private void InitializeComponent()
| > {
| > this.myUserControl1 = new
| > WinForm_BeginEndUpdate_MouseMove.MyUserControl();
| > this.timer1 = new System.Timers.Timer();
| > ((System.ComponentModel.ISupportInitialize)(this.timer1)).BeginInit();
| > this.SuspendLayout();
| > //
| > // myUserControl1
| > //
| > this.myUserControl1.BackColor = System.Drawing.SystemColors.Desktop;
| > this.myUserControl1.Location = new System.Drawing.Point(72, 64);
| > this.myUserControl1.Name = "myUserControl1";
| > this.myUserControl1.Size = new System.Drawing.Size(256, 240);
| > this.myUserControl1.TabIndex = 2;
| > //
| > // timer1
| > //
| > this.timer1.Enabled = true;
| > this.timer1.Interval = 500;
| > this.timer1.SynchronizingObject = this;
| > this.timer1.Elapsed += new
| > System.Timers.ElapsedEventHandler(this.timer1_Elapsed);
| > //
| > // Form1
| > //
| > this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
| > this.ClientSize = new System.Drawing.Size(408, 421);
| > this.Controls.Add(this.myUserControl1);
| > this.Name = "Form1";
| > this.Text = "Form1";
| > this.MouseMove += new
| > System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);
| > ((System.ComponentModel.ISupportInitialize)(this.timer1)).EndInit();
| > this.ResumeLayout(false);
| >
| > }
| > #endregion
| >
| > /// <summary>
| > /// The main entry point for the application.
| > /// </summary>
| > [STAThread]
| > static void Main()
| > {
| > Application.Run(new Form1());
| > }
| >
| > private void Form1_MouseMove(object sender,
| > System.Windows.Forms.MouseEventArgs e)
| > {
| > System.Diagnostics.Debug.WriteLine("MainForm MouseMove received");
| > }
| >
| > private void timer1_Elapsed(object sender,
System.Timers.ElapsedEventArgs
| > e)
| > {
| > myUserControl1.BeginUpdate();
| > System.Diagnostics.Debug.WriteLine("BeginUpdate");
| > myUserControl1.DoUpdate();
| > myUserControl1.EndUpdate();
| > System.Diagnostics.Debug.WriteLine("EndUpdate");
| >
| > }
| > }
| > }
| >
| > </code>
| >
| >
| >
| >
|
|
|
 
I had thought of that work-around. The problem is that it is more of a hack
than anything else. I would prefer a "cleaner" solution to the problem. But,
if one does not exist, then I will have to make do with the hack. Since you
are confirming this as a bug, do you know when this might be fixed?

Thanks,
Abhishek

Ying-Shen Yu said:
Hi abhishek,
Thanks for your sample, I reproed your problem now.
For now, I haven't found a way to prevent MouseMove method to be called.
However, since BeginUpdate/Endupate is called by yourself, could you add a
boolean flag before actually executing your codes in the MouseMove?
such as
InUpdating = false;
void BeginUpdate()
{
InUpdating = true;
SendMessage ....
}
void EndUpdate()
{
SendMessage() ...
InUpdating = false;
}
void MouseMove( ....)
{
if(!IsUpdating)
{
DoMouseMove();
}
}

Does this work around solve your problem?
Please be free to post on the group, if you still have problem on this
issue.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!

--------------------
| From: "abhishek ghuwalewala" <[email protected]>
| References: <uV#[email protected]>
<[email protected]>
| Subject: Re: BeginUpdate/EndUpdate causing mouse move
| Date: Fri, 24 Oct 2003 11:05:22 -0500
| Lines: 638
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| NNTP-Posting-Host: client-64-158.natinst.com 130.164.64.158
| Path:
cpmsftngxa06.phx.gbl!cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.
phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:55191
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| Ying-Shen,
|
| Thanks for your prompt reply. I am attaching a small sample project that
| reproduces the problem. The instructions for reproducing the problem are
| described in the application.
|
| Thanks,
| Abhishek
|
| | > Hi abhishek.
| > Thanks for your post!
| > You mean your mousemove event of your control or your form is fired when
| > you invoke the P/Invoke SendMessage
| > method?
| > I made a small program and tried to repro your problem, however I didn't
| > get any mouse move event on the user control or on the Form when
invoking
| > these two methods.
| > I pasted my test code after the signature, you may try it on your
system.
| > Probably it will be helpful if you could give me a
| > small sample project to repro this problem.
| >
| > Thanks for using MSDN Newsgroup!!
| >
| > Best regards,
| >
| > Ying-Shen Yu [MSFT]
| > Microsoft Online Partner Support
| > Get Secure! - www.microsoft.com/security
| >
| > This posting is provided "AS IS" with no warranties and confers no
rights.
| > You should not reply this mail directly, "Online" should be removed
before
| > sending, Thanks!
| >
| > <code file="MyUserControl.cs">
| > using System;
| > using System.Collections;
| > using System.ComponentModel;
| > using System.Drawing;
| > using System.Data;
| > using System.Windows.Forms;
| > using System.Runtime.InteropServices;
| >
| > namespace WinForm_BeginEndUpdate_MouseMove
| > {
| > /// <summary>
| > /// Summary description for MyUserControl.
| > /// </summary>
| > public class MyUserControl : System.Windows.Forms.UserControl
| > {
| > /// <summary>
| > /// Required designer variable.
| > /// </summary>
| > private System.ComponentModel.Container components = null;
| >
| > public MyUserControl()
| > {
| > // This call is required by the Windows.Forms Form Designer.
| > InitializeComponent();
| >
| > // TODO: Add any initialization after the InitializeComponent call
| >
| > }
| >
| > /// <summary>
| > /// Clean up any resources being used.
| > /// </summary>
| > protected override void Dispose( bool disposing )
| > {
| > if( disposing )
| > {
| > if(components != null)
| > {
| > components.Dispose();
| > }
| > }
| > base.Dispose( disposing );
| > }
| >
| > #region Component Designer generated code
| > /// <summary>
| > /// Required method for Designer support - do not modify
| > /// the contents of this method with the code editor.
| > /// </summary>
| > private void InitializeComponent()
| > {
| > //
| > // MyUserControl
| > //
| > this.BackColor = System.Drawing.SystemColors.Desktop;
| > this.Name = "MyUserControl";
| > this.Size = new System.Drawing.Size(368, 424);
| >
| > }
| > #endregion
| >
| > private class NativeMethods
| > {
| > [DllImport("user32.dll")]
| > private extern static int SendMessage(IntPtr hwnd, uint nMsg,
| > int wParam, int lParam);
| > private const int WM_SETREDRAW = 0x000B;
| > public static void BeginUpdate(IntPtr hwnd)
| > {
| > SendMessage(hwnd,WM_SETREDRAW,0,0);
| > }
| > public static void EndUpdate(IntPtr hwnd)
| > {
| > SendMessage(hwnd,WM_SETREDRAW,-1,0);
| > }
| >
| > }
| >
| >
| > public void BeginUpdate()
| > {
| > NativeMethods.BeginUpdate(Handle);
| > }
| > public void EndUpdate()
| > {
| > NativeMethods.EndUpdate(Handle);
| > }
| >
| >
| > protected override void OnMouseMove(MouseEventArgs e)
| > {
| > base.OnMouseMove (e);
| > System.Diagnostics.Debug.WriteLine("MouseMove received");
| > }
| > public void DoUpdate()
| > {
| > Graphics g = CreateGraphics();
| > g.FillRectangle(Brushes.Indigo,this.Bounds);
| > g.Dispose();
| > }
| > }
| > }
| > </code>
| > <code file="Form1.cs">
| > using System;
| > using System.Drawing;
| > using System.Collections;
| > using System.ComponentModel;
| > using System.Windows.Forms;
| > using System.Data;
| >
| > namespace WinForm_BeginEndUpdate_MouseMove
| > {
| > /// <summary>
| > /// Summary description for Form1.
| > /// </summary>
| > public class Form1 : System.Windows.Forms.Form
| > {
| > private WinForm_BeginEndUpdate_MouseMove.MyUserControl myUserControl1;
| > private System.Timers.Timer timer1;
| > /// <summary>
| > /// Required designer variable.
| > /// </summary>
| > private System.ComponentModel.Container components = null;
| >
| > public Form1()
| > {
| > //
| > // Required for Windows Form Designer support
| > //
| > InitializeComponent();
| >
| > //
| > // TODO: Add any constructor code after InitializeComponent call
| > //
| > }
| >
| > /// <summary>
| > /// Clean up any resources being used.
| > /// </summary>
| > protected override void Dispose( bool disposing )
| > {
| > if( disposing )
| > {
| > if (components != null)
| > {
| > components.Dispose();
| > }
| > }
| > base.Dispose( disposing );
| > }
| >
| > #region Windows Form Designer generated code
| > /// <summary>
| > /// Required method for Designer support - do not modify
| > /// the contents of this method with the code editor.
| > /// </summary>
| > private void InitializeComponent()
| > {
| > this.myUserControl1 = new
| > WinForm_BeginEndUpdate_MouseMove.MyUserControl();
| > this.timer1 = new System.Timers.Timer();
| > ((System.ComponentModel.ISupportInitialize)(this.timer1)).BeginInit();
| > this.SuspendLayout();
| > //
| > // myUserControl1
| > //
| > this.myUserControl1.BackColor = System.Drawing.SystemColors.Desktop;
| > this.myUserControl1.Location = new System.Drawing.Point(72, 64);
| > this.myUserControl1.Name = "myUserControl1";
| > this.myUserControl1.Size = new System.Drawing.Size(256, 240);
| > this.myUserControl1.TabIndex = 2;
| > //
| > // timer1
| > //
| > this.timer1.Enabled = true;
| > this.timer1.Interval = 500;
| > this.timer1.SynchronizingObject = this;
| > this.timer1.Elapsed += new
| > System.Timers.ElapsedEventHandler(this.timer1_Elapsed);
| > //
| > // Form1
| > //
| > this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
| > this.ClientSize = new System.Drawing.Size(408, 421);
| > this.Controls.Add(this.myUserControl1);
| > this.Name = "Form1";
| > this.Text = "Form1";
| > this.MouseMove += new
| > System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);
| > ((System.ComponentModel.ISupportInitialize)(this.timer1)).EndInit();
| > this.ResumeLayout(false);
| >
| > }
| > #endregion
| >
| > /// <summary>
| > /// The main entry point for the application.
| > /// </summary>
| > [STAThread]
| > static void Main()
| > {
| > Application.Run(new Form1());
| > }
| >
| > private void Form1_MouseMove(object sender,
| > System.Windows.Forms.MouseEventArgs e)
| > {
| > System.Diagnostics.Debug.WriteLine("MainForm MouseMove received");
| > }
| >
| > private void timer1_Elapsed(object sender,
System.Timers.ElapsedEventArgs
| > e)
| > {
| > myUserControl1.BeginUpdate();
| > System.Diagnostics.Debug.WriteLine("BeginUpdate");
| > myUserControl1.DoUpdate();
| > myUserControl1.EndUpdate();
| > System.Diagnostics.Debug.WriteLine("EndUpdate");
| >
| > }
| > }
| > }
| >
| > </code>
| >
| >
| >
| >
|
|
|
 
As I had mentioned before, this behavior does not reproduce for the ListBox
control. Would you happen to know what the ListBox control is doing that
prevents this from happening?

Abhishek

Ying-Shen Yu said:
Hi abhishek,
Thanks for your sample, I reproed your problem now.
For now, I haven't found a way to prevent MouseMove method to be called.
However, since BeginUpdate/Endupate is called by yourself, could you add a
boolean flag before actually executing your codes in the MouseMove?
such as
InUpdating = false;
void BeginUpdate()
{
InUpdating = true;
SendMessage ....
}
void EndUpdate()
{
SendMessage() ...
InUpdating = false;
}
void MouseMove( ....)
{
if(!IsUpdating)
{
DoMouseMove();
}
}

Does this work around solve your problem?
Please be free to post on the group, if you still have problem on this
issue.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!

--------------------
| From: "abhishek ghuwalewala" <[email protected]>
| References: <uV#[email protected]>
<[email protected]>
| Subject: Re: BeginUpdate/EndUpdate causing mouse move
| Date: Fri, 24 Oct 2003 11:05:22 -0500
| Lines: 638
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| NNTP-Posting-Host: client-64-158.natinst.com 130.164.64.158
| Path:
cpmsftngxa06.phx.gbl!cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.
phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:55191
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| Ying-Shen,
|
| Thanks for your prompt reply. I am attaching a small sample project that
| reproduces the problem. The instructions for reproducing the problem are
| described in the application.
|
| Thanks,
| Abhishek
|
| | > Hi abhishek.
| > Thanks for your post!
| > You mean your mousemove event of your control or your form is fired when
| > you invoke the P/Invoke SendMessage
| > method?
| > I made a small program and tried to repro your problem, however I didn't
| > get any mouse move event on the user control or on the Form when
invoking
| > these two methods.
| > I pasted my test code after the signature, you may try it on your
system.
| > Probably it will be helpful if you could give me a
| > small sample project to repro this problem.
| >
| > Thanks for using MSDN Newsgroup!!
| >
| > Best regards,
| >
| > Ying-Shen Yu [MSFT]
| > Microsoft Online Partner Support
| > Get Secure! - www.microsoft.com/security
| >
| > This posting is provided "AS IS" with no warranties and confers no
rights.
| > You should not reply this mail directly, "Online" should be removed
before
| > sending, Thanks!
| >
| > <code file="MyUserControl.cs">
| > using System;
| > using System.Collections;
| > using System.ComponentModel;
| > using System.Drawing;
| > using System.Data;
| > using System.Windows.Forms;
| > using System.Runtime.InteropServices;
| >
| > namespace WinForm_BeginEndUpdate_MouseMove
| > {
| > /// <summary>
| > /// Summary description for MyUserControl.
| > /// </summary>
| > public class MyUserControl : System.Windows.Forms.UserControl
| > {
| > /// <summary>
| > /// Required designer variable.
| > /// </summary>
| > private System.ComponentModel.Container components = null;
| >
| > public MyUserControl()
| > {
| > // This call is required by the Windows.Forms Form Designer.
| > InitializeComponent();
| >
| > // TODO: Add any initialization after the InitializeComponent call
| >
| > }
| >
| > /// <summary>
| > /// Clean up any resources being used.
| > /// </summary>
| > protected override void Dispose( bool disposing )
| > {
| > if( disposing )
| > {
| > if(components != null)
| > {
| > components.Dispose();
| > }
| > }
| > base.Dispose( disposing );
| > }
| >
| > #region Component Designer generated code
| > /// <summary>
| > /// Required method for Designer support - do not modify
| > /// the contents of this method with the code editor.
| > /// </summary>
| > private void InitializeComponent()
| > {
| > //
| > // MyUserControl
| > //
| > this.BackColor = System.Drawing.SystemColors.Desktop;
| > this.Name = "MyUserControl";
| > this.Size = new System.Drawing.Size(368, 424);
| >
| > }
| > #endregion
| >
| > private class NativeMethods
| > {
| > [DllImport("user32.dll")]
| > private extern static int SendMessage(IntPtr hwnd, uint nMsg,
| > int wParam, int lParam);
| > private const int WM_SETREDRAW = 0x000B;
| > public static void BeginUpdate(IntPtr hwnd)
| > {
| > SendMessage(hwnd,WM_SETREDRAW,0,0);
| > }
| > public static void EndUpdate(IntPtr hwnd)
| > {
| > SendMessage(hwnd,WM_SETREDRAW,-1,0);
| > }
| >
| > }
| >
| >
| > public void BeginUpdate()
| > {
| > NativeMethods.BeginUpdate(Handle);
| > }
| > public void EndUpdate()
| > {
| > NativeMethods.EndUpdate(Handle);
| > }
| >
| >
| > protected override void OnMouseMove(MouseEventArgs e)
| > {
| > base.OnMouseMove (e);
| > System.Diagnostics.Debug.WriteLine("MouseMove received");
| > }
| > public void DoUpdate()
| > {
| > Graphics g = CreateGraphics();
| > g.FillRectangle(Brushes.Indigo,this.Bounds);
| > g.Dispose();
| > }
| > }
| > }
| > </code>
| > <code file="Form1.cs">
| > using System;
| > using System.Drawing;
| > using System.Collections;
| > using System.ComponentModel;
| > using System.Windows.Forms;
| > using System.Data;
| >
| > namespace WinForm_BeginEndUpdate_MouseMove
| > {
| > /// <summary>
| > /// Summary description for Form1.
| > /// </summary>
| > public class Form1 : System.Windows.Forms.Form
| > {
| > private WinForm_BeginEndUpdate_MouseMove.MyUserControl myUserControl1;
| > private System.Timers.Timer timer1;
| > /// <summary>
| > /// Required designer variable.
| > /// </summary>
| > private System.ComponentModel.Container components = null;
| >
| > public Form1()
| > {
| > //
| > // Required for Windows Form Designer support
| > //
| > InitializeComponent();
| >
| > //
| > // TODO: Add any constructor code after InitializeComponent call
| > //
| > }
| >
| > /// <summary>
| > /// Clean up any resources being used.
| > /// </summary>
| > protected override void Dispose( bool disposing )
| > {
| > if( disposing )
| > {
| > if (components != null)
| > {
| > components.Dispose();
| > }
| > }
| > base.Dispose( disposing );
| > }
| >
| > #region Windows Form Designer generated code
| > /// <summary>
| > /// Required method for Designer support - do not modify
| > /// the contents of this method with the code editor.
| > /// </summary>
| > private void InitializeComponent()
| > {
| > this.myUserControl1 = new
| > WinForm_BeginEndUpdate_MouseMove.MyUserControl();
| > this.timer1 = new System.Timers.Timer();
| > ((System.ComponentModel.ISupportInitialize)(this.timer1)).BeginInit();
| > this.SuspendLayout();
| > //
| > // myUserControl1
| > //
| > this.myUserControl1.BackColor = System.Drawing.SystemColors.Desktop;
| > this.myUserControl1.Location = new System.Drawing.Point(72, 64);
| > this.myUserControl1.Name = "myUserControl1";
| > this.myUserControl1.Size = new System.Drawing.Size(256, 240);
| > this.myUserControl1.TabIndex = 2;
| > //
| > // timer1
| > //
| > this.timer1.Enabled = true;
| > this.timer1.Interval = 500;
| > this.timer1.SynchronizingObject = this;
| > this.timer1.Elapsed += new
| > System.Timers.ElapsedEventHandler(this.timer1_Elapsed);
| > //
| > // Form1
| > //
| > this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
| > this.ClientSize = new System.Drawing.Size(408, 421);
| > this.Controls.Add(this.myUserControl1);
| > this.Name = "Form1";
| > this.Text = "Form1";
| > this.MouseMove += new
| > System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);
| > ((System.ComponentModel.ISupportInitialize)(this.timer1)).EndInit();
| > this.ResumeLayout(false);
| >
| > }
| > #endregion
| >
| > /// <summary>
| > /// The main entry point for the application.
| > /// </summary>
| > [STAThread]
| > static void Main()
| > {
| > Application.Run(new Form1());
| > }
| >
| > private void Form1_MouseMove(object sender,
| > System.Windows.Forms.MouseEventArgs e)
| > {
| > System.Diagnostics.Debug.WriteLine("MainForm MouseMove received");
| > }
| >
| > private void timer1_Elapsed(object sender,
System.Timers.ElapsedEventArgs
| > e)
| > {
| > myUserControl1.BeginUpdate();
| > System.Diagnostics.Debug.WriteLine("BeginUpdate");
| > myUserControl1.DoUpdate();
| > myUserControl1.EndUpdate();
| > System.Diagnostics.Debug.WriteLine("EndUpdate");
| >
| > }
| > }
| > }
| >
| > </code>
| >
| >
| >
| >
|
|
|
 
Hi abhishek,
In fact, this issue also occurred in native win32 application, it by design.
The system sometimes delivers a WM_MOUSEMOVE message even if the mouse
hasn't moved. Programs which are sensitive to physical mouse movement (such
as screen savers) should compare the coordinates in the WM_MOUSEMOVE
message with the coordinates from the previous mouse message and ignore the
message if they are the same.

The Document didn't make this clear, we already noticed this problem, it
mightbe fixed in the next release of the document.Thanks for your reporting.
If you need handle the real OnMouseMove event you need first check if the
point of the cursor is same as the previous one. the code should be
executed only when the values are different.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!

--------------------
| From: "abhishek ghuwalewala" <[email protected]>
| References: <uV#[email protected]>
<[email protected]>
<#[email protected]>
<Km#[email protected]>
| Subject: Re: BeginUpdate/EndUpdate causing mouse move
| Date: Mon, 27 Oct 2003 10:29:09 -0600
| Lines: 348
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <O8N#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| NNTP-Posting-Host: client-79-20.natinst.com 130.164.79.20
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:55305
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| As I had mentioned before, this behavior does not reproduce for the
ListBox
| control. Would you happen to know what the ListBox control is doing that
| prevents this from happening?
|
| Abhishek
|
| | > Hi abhishek,
| > Thanks for your sample, I reproed your problem now.
| > For now, I haven't found a way to prevent MouseMove method to be called.
| > However, since BeginUpdate/Endupate is called by yourself, could you
add a
| > boolean flag before actually executing your codes in the MouseMove?
| > such as
| > InUpdating = false;
| > void BeginUpdate()
| > {
| > InUpdating = true;
| > SendMessage ....
| > }
| > void EndUpdate()
| > {
| > SendMessage() ...
| > InUpdating = false;
| > }
| > void MouseMove( ....)
| > {
| > if(!IsUpdating)
| > {
| > DoMouseMove();
| > }
| > }
| >
| > Does this work around solve your problem?
| > Please be free to post on the group, if you still have problem on this
| > issue.
| > Thanks!
| >
| > Best regards,
| >
| > Ying-Shen Yu [MSFT]
| > Microsoft Online Partner Support
| > Get Secure! - www.microsoft.com/security
| >
| > This posting is provided "AS IS" with no warranties and confers no
rights.
| > You should not reply this mail directly, "Online" should be removed
before
| > sending, Thanks!
| >
| > --------------------
| > | From: "abhishek ghuwalewala" <[email protected]>
| > | References: <uV#[email protected]>
| > <[email protected]>
| > | Subject: Re: BeginUpdate/EndUpdate causing mouse move
| > | Date: Fri, 24 Oct 2003 11:05:22 -0500
| > | Lines: 638
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| > | Message-ID: <#[email protected]>
| > | Newsgroups: microsoft.public.dotnet.framework.windowsforms
| > | NNTP-Posting-Host: client-64-158.natinst.com 130.164.64.158
| > | Path:
| >
|
cpmsftngxa06.phx.gbl!cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.
| > phx.gbl
| > | Xref: cpmsftngxa06.phx.gbl
| > microsoft.public.dotnet.framework.windowsforms:55191
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
| > |
| > | Ying-Shen,
| > |
| > | Thanks for your prompt reply. I am attaching a small sample project
that
| > | reproduces the problem. The instructions for reproducing the problem
are
| > | described in the application.
| > |
| > | Thanks,
| > | Abhishek
| > |
| > | | > | > Hi abhishek.
| > | > Thanks for your post!
| > | > You mean your mousemove event of your control or your form is fired
| when
| > | > you invoke the P/Invoke SendMessage
| > | > method?
| > | > I made a small program and tried to repro your problem, however I
| didn't
| > | > get any mouse move event on the user control or on the Form when
| > invoking
| > | > these two methods.
| > | > I pasted my test code after the signature, you may try it on your
| > system.
| > | > Probably it will be helpful if you could give me a
| > | > small sample project to repro this problem.
| > | >
| > | > Thanks for using MSDN Newsgroup!!
| > | >
| > | > Best regards,
| > | >
| > | > Ying-Shen Yu [MSFT]
| > | > Microsoft Online Partner Support
| > | > Get Secure! - www.microsoft.com/security
| > | >
| > | > This posting is provided "AS IS" with no warranties and confers no
| > rights.
| > | > You should not reply this mail directly, "Online" should be removed
| > before
| > | > sending, Thanks!
| > | >
| > | > <code file="MyUserControl.cs">
| > | > using System;
| > | > using System.Collections;
| > | > using System.ComponentModel;
| > | > using System.Drawing;
| > | > using System.Data;
| > | > using System.Windows.Forms;
| > | > using System.Runtime.InteropServices;
| > | >
| > | > namespace WinForm_BeginEndUpdate_MouseMove
| > | > {
| > | > /// <summary>
| > | > /// Summary description for MyUserControl.
| > | > /// </summary>
| > | > public class MyUserControl : System.Windows.Forms.UserControl
| > | > {
| > | > /// <summary>
| > | > /// Required designer variable.
| > | > /// </summary>
| > | > private System.ComponentModel.Container components = null;
| > | >
| > | > public MyUserControl()
| > | > {
| > | > // This call is required by the Windows.Forms Form Designer.
| > | > InitializeComponent();
| > | >
| > | > // TODO: Add any initialization after the InitializeComponent call
| > | >
| > | > }
| > | >
| > | > /// <summary>
| > | > /// Clean up any resources being used.
| > | > /// </summary>
| > | > protected override void Dispose( bool disposing )
| > | > {
| > | > if( disposing )
| > | > {
| > | > if(components != null)
| > | > {
| > | > components.Dispose();
| > | > }
| > | > }
| > | > base.Dispose( disposing );
| > | > }
| > | >
| > | > #region Component Designer generated code
| > | > /// <summary>
| > | > /// Required method for Designer support - do not modify
| > | > /// the contents of this method with the code editor.
| > | > /// </summary>
| > | > private void InitializeComponent()
| > | > {
| > | > //
| > | > // MyUserControl
| > | > //
| > | > this.BackColor = System.Drawing.SystemColors.Desktop;
| > | > this.Name = "MyUserControl";
| > | > this.Size = new System.Drawing.Size(368, 424);
| > | >
| > | > }
| > | > #endregion
| > | >
| > | > private class NativeMethods
| > | > {
| > | > [DllImport("user32.dll")]
| > | > private extern static int SendMessage(IntPtr hwnd, uint nMsg,
| > | > int wParam, int lParam);
| > | > private const int WM_SETREDRAW = 0x000B;
| > | > public static void BeginUpdate(IntPtr hwnd)
| > | > {
| > | > SendMessage(hwnd,WM_SETREDRAW,0,0);
| > | > }
| > | > public static void EndUpdate(IntPtr hwnd)
| > | > {
| > | > SendMessage(hwnd,WM_SETREDRAW,-1,0);
| > | > }
| > | >
| > | > }
| > | >
| > | >
| > | > public void BeginUpdate()
| > | > {
| > | > NativeMethods.BeginUpdate(Handle);
| > | > }
| > | > public void EndUpdate()
| > | > {
| > | > NativeMethods.EndUpdate(Handle);
| > | > }
| > | >
| > | >
| > | > protected override void OnMouseMove(MouseEventArgs e)
| > | > {
| > | > base.OnMouseMove (e);
| > | > System.Diagnostics.Debug.WriteLine("MouseMove received");
| > | > }
| > | > public void DoUpdate()
| > | > {
| > | > Graphics g = CreateGraphics();
| > | > g.FillRectangle(Brushes.Indigo,this.Bounds);
| > | > g.Dispose();
| > | > }
| > | > }
| > | > }
| > | > </code>
| > | > <code file="Form1.cs">
| > | > using System;
| > | > using System.Drawing;
| > | > using System.Collections;
| > | > using System.ComponentModel;
| > | > using System.Windows.Forms;
| > | > using System.Data;
| > | >
| > | > namespace WinForm_BeginEndUpdate_MouseMove
| > | > {
| > | > /// <summary>
| > | > /// Summary description for Form1.
| > | > /// </summary>
| > | > public class Form1 : System.Windows.Forms.Form
| > | > {
| > | > private WinForm_BeginEndUpdate_MouseMove.MyUserControl
myUserControl1;
| > | > private System.Timers.Timer timer1;
| > | > /// <summary>
| > | > /// Required designer variable.
| > | > /// </summary>
| > | > private System.ComponentModel.Container components = null;
| > | >
| > | > public Form1()
| > | > {
| > | > //
| > | > // Required for Windows Form Designer support
| > | > //
| > | > InitializeComponent();
| > | >
| > | > //
| > | > // TODO: Add any constructor code after InitializeComponent call
| > | > //
| > | > }
| > | >
| > | > /// <summary>
| > | > /// Clean up any resources being used.
| > | > /// </summary>
| > | > protected override void Dispose( bool disposing )
| > | > {
| > | > if( disposing )
| > | > {
| > | > if (components != null)
| > | > {
| > | > components.Dispose();
| > | > }
| > | > }
| > | > base.Dispose( disposing );
| > | > }
| > | >
| > | > #region Windows Form Designer generated code
| > | > /// <summary>
| > | > /// Required method for Designer support - do not modify
| > | > /// the contents of this method with the code editor.
| > | > /// </summary>
| > | > private void InitializeComponent()
| > | > {
| > | > this.myUserControl1 = new
| > | > WinForm_BeginEndUpdate_MouseMove.MyUserControl();
| > | > this.timer1 = new System.Timers.Timer();
| > | >
((System.ComponentModel.ISupportInitialize)(this.timer1)).BeginInit();
| > | > this.SuspendLayout();
| > | > //
| > | > // myUserControl1
| > | > //
| > | > this.myUserControl1.BackColor = System.Drawing.SystemColors.Desktop;
| > | > this.myUserControl1.Location = new System.Drawing.Point(72, 64);
| > | > this.myUserControl1.Name = "myUserControl1";
| > | > this.myUserControl1.Size = new System.Drawing.Size(256, 240);
| > | > this.myUserControl1.TabIndex = 2;
| > | > //
| > | > // timer1
| > | > //
| > | > this.timer1.Enabled = true;
| > | > this.timer1.Interval = 500;
| > | > this.timer1.SynchronizingObject = this;
| > | > this.timer1.Elapsed += new
| > | > System.Timers.ElapsedEventHandler(this.timer1_Elapsed);
| > | > //
| > | > // Form1
| > | > //
| > | > this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
| > | > this.ClientSize = new System.Drawing.Size(408, 421);
| > | > this.Controls.Add(this.myUserControl1);
| > | > this.Name = "Form1";
| > | > this.Text = "Form1";
| > | > this.MouseMove += new
| > | > System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);
| > | > ((System.ComponentModel.ISupportInitialize)(this.timer1)).EndInit();
| > | > this.ResumeLayout(false);
| > | >
| > | > }
| > | > #endregion
| > | >
| > | > /// <summary>
| > | > /// The main entry point for the application.
| > | > /// </summary>
| > | > [STAThread]
| > | > static void Main()
| > | > {
| > | > Application.Run(new Form1());
| > | > }
| > | >
| > | > private void Form1_MouseMove(object sender,
| > | > System.Windows.Forms.MouseEventArgs e)
| > | > {
| > | > System.Diagnostics.Debug.WriteLine("MainForm MouseMove received");
| > | > }
| > | >
| > | > private void timer1_Elapsed(object sender,
| > System.Timers.ElapsedEventArgs
| > | > e)
| > | > {
| > | > myUserControl1.BeginUpdate();
| > | > System.Diagnostics.Debug.WriteLine("BeginUpdate");
| > | > myUserControl1.DoUpdate();
| > | > myUserControl1.EndUpdate();
| > | > System.Diagnostics.Debug.WriteLine("EndUpdate");
| > | >
| > | > }
| > | > }
| > | > }
| > | >
| > | > </code>
| > | >
| > | >
| > | >
| > | >
| > |
| > |
| > |
| >
|
|
|
 
So, this BUG is BY DESIGN?


"The system sometimes delivers a WM_MOUSEMOVE message even if the mouse
hasn't moved"


Sounds like a bug to me, a signal fired that the mouse has moved when infact
it hasnt, sory, by design doesn't hide bullssshit
--

Jack Mayhoff
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Ying-Shen Yu said:
Hi abhishek,
In fact, this issue also occurred in native win32 application, it by design.
The system sometimes delivers a WM_MOUSEMOVE message even if the mouse
hasn't moved. Programs which are sensitive to physical mouse movement (such
as screen savers) should compare the coordinates in the WM_MOUSEMOVE
message with the coordinates from the previous mouse message and ignore the
message if they are the same.

The Document didn't make this clear, we already noticed this problem, it
mightbe fixed in the next release of the document.Thanks for your reporting.
If you need handle the real OnMouseMove event you need first check if the
point of the cursor is same as the previous one. the code should be
executed only when the values are different.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!

--------------------
| From: "abhishek ghuwalewala" <[email protected]>
| References: <uV#[email protected]>
<[email protected]>
<#[email protected]>
<Km#[email protected]>
| Subject: Re: BeginUpdate/EndUpdate causing mouse move
| Date: Mon, 27 Oct 2003 10:29:09 -0600
| Lines: 348
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <O8N#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| NNTP-Posting-Host: client-79-20.natinst.com 130.164.79.20
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:55305
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| As I had mentioned before, this behavior does not reproduce for the
ListBox
| control. Would you happen to know what the ListBox control is doing that
| prevents this from happening?
|
| Abhishek
|
| | > Hi abhishek,
| > Thanks for your sample, I reproed your problem now.
| > For now, I haven't found a way to prevent MouseMove method to be called.
| > However, since BeginUpdate/Endupate is called by yourself, could you
add a
| > boolean flag before actually executing your codes in the MouseMove?
| > such as
| > InUpdating = false;
| > void BeginUpdate()
| > {
| > InUpdating = true;
| > SendMessage ....
| > }
| > void EndUpdate()
| > {
| > SendMessage() ...
| > InUpdating = false;
| > }
| > void MouseMove( ....)
| > {
| > if(!IsUpdating)
| > {
| > DoMouseMove();
| > }
| > }
| >
| > Does this work around solve your problem?
| > Please be free to post on the group, if you still have problem on this
| > issue.
| > Thanks!
| >
| > Best regards,
| >
| > Ying-Shen Yu [MSFT]
| > Microsoft Online Partner Support
| > Get Secure! - www.microsoft.com/security
| >
| > This posting is provided "AS IS" with no warranties and confers no
rights.
| > You should not reply this mail directly, "Online" should be removed
before
| > sending, Thanks!
| >
| > --------------------
| > | From: "abhishek ghuwalewala" <[email protected]>
| > | References: <uV#[email protected]>
| > <[email protected]>
| > | Subject: Re: BeginUpdate/EndUpdate causing mouse move
| > | Date: Fri, 24 Oct 2003 11:05:22 -0500
| > | Lines: 638
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| > | Message-ID: <#[email protected]>
| > | Newsgroups: microsoft.public.dotnet.framework.windowsforms
| > | NNTP-Posting-Host: client-64-158.natinst.com 130.164.64.158
| > | Path:
| >
|
cpmsftngxa06.phx.gbl!cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.
| > phx.gbl
| > | Xref: cpmsftngxa06.phx.gbl
| > microsoft.public.dotnet.framework.windowsforms:55191
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
| > |
| > | Ying-Shen,
| > |
| > | Thanks for your prompt reply. I am attaching a small sample project
that
| > | reproduces the problem. The instructions for reproducing the problem
are
| > | described in the application.
| > |
| > | Thanks,
| > | Abhishek
| > |
| > | | > | > Hi abhishek.
| > | > Thanks for your post!
| > | > You mean your mousemove event of your control or your form is fired
| when
| > | > you invoke the P/Invoke SendMessage
| > | > method?
| > | > I made a small program and tried to repro your problem, however I
| didn't
| > | > get any mouse move event on the user control or on the Form when
| > invoking
| > | > these two methods.
| > | > I pasted my test code after the signature, you may try it on your
| > system.
| > | > Probably it will be helpful if you could give me a
| > | > small sample project to repro this problem.
| > | >
| > | > Thanks for using MSDN Newsgroup!!
| > | >
| > | > Best regards,
| > | >
| > | > Ying-Shen Yu [MSFT]
| > | > Microsoft Online Partner Support
| > | > Get Secure! - www.microsoft.com/security
| > | >
| > | > This posting is provided "AS IS" with no warranties and confers no
| > rights.
| > | > You should not reply this mail directly, "Online" should be removed
| > before
| > | > sending, Thanks!
| > | >
| > | > <code file="MyUserControl.cs">
| > | > using System;
| > | > using System.Collections;
| > | > using System.ComponentModel;
| > | > using System.Drawing;
| > | > using System.Data;
| > | > using System.Windows.Forms;
| > | > using System.Runtime.InteropServices;
| > | >
| > | > namespace WinForm_BeginEndUpdate_MouseMove
| > | > {
| > | > /// <summary>
| > | > /// Summary description for MyUserControl.
| > | > /// </summary>
| > | > public class MyUserControl : System.Windows.Forms.UserControl
| > | > {
| > | > /// <summary>
| > | > /// Required designer variable.
| > | > /// </summary>
| > | > private System.ComponentModel.Container components = null;
| > | >
| > | > public MyUserControl()
| > | > {
| > | > // This call is required by the Windows.Forms Form Designer.
| > | > InitializeComponent();
| > | >
| > | > // TODO: Add any initialization after the InitializeComponent call
| > | >
| > | > }
| > | >
| > | > /// <summary>
| > | > /// Clean up any resources being used.
| > | > /// </summary>
| > | > protected override void Dispose( bool disposing )
| > | > {
| > | > if( disposing )
| > | > {
| > | > if(components != null)
| > | > {
| > | > components.Dispose();
| > | > }
| > | > }
| > | > base.Dispose( disposing );
| > | > }
| > | >
| > | > #region Component Designer generated code
| > | > /// <summary>
| > | > /// Required method for Designer support - do not modify
| > | > /// the contents of this method with the code editor.
| > | > /// </summary>
| > | > private void InitializeComponent()
| > | > {
| > | > //
| > | > // MyUserControl
| > | > //
| > | > this.BackColor = System.Drawing.SystemColors.Desktop;
| > | > this.Name = "MyUserControl";
| > | > this.Size = new System.Drawing.Size(368, 424);
| > | >
| > | > }
| > | > #endregion
| > | >
| > | > private class NativeMethods
| > | > {
| > | > [DllImport("user32.dll")]
| > | > private extern static int SendMessage(IntPtr hwnd, uint nMsg,
| > | > int wParam, int lParam);
| > | > private const int WM_SETREDRAW = 0x000B;
| > | > public static void BeginUpdate(IntPtr hwnd)
| > | > {
| > | > SendMessage(hwnd,WM_SETREDRAW,0,0);
| > | > }
| > | > public static void EndUpdate(IntPtr hwnd)
| > | > {
| > | > SendMessage(hwnd,WM_SETREDRAW,-1,0);
| > | > }
| > | >
| > | > }
| > | >
| > | >
| > | > public void BeginUpdate()
| > | > {
| > | > NativeMethods.BeginUpdate(Handle);
| > | > }
| > | > public void EndUpdate()
| > | > {
| > | > NativeMethods.EndUpdate(Handle);
| > | > }
| > | >
| > | >
| > | > protected override void OnMouseMove(MouseEventArgs e)
| > | > {
| > | > base.OnMouseMove (e);
| > | > System.Diagnostics.Debug.WriteLine("MouseMove received");
| > | > }
| > | > public void DoUpdate()
| > | > {
| > | > Graphics g = CreateGraphics();
| > | > g.FillRectangle(Brushes.Indigo,this.Bounds);
| > | > g.Dispose();
| > | > }
| > | > }
| > | > }
| > | > </code>
| > | > <code file="Form1.cs">
| > | > using System;
| > | > using System.Drawing;
| > | > using System.Collections;
| > | > using System.ComponentModel;
| > | > using System.Windows.Forms;
| > | > using System.Data;
| > | >
| > | > namespace WinForm_BeginEndUpdate_MouseMove
| > | > {
| > | > /// <summary>
| > | > /// Summary description for Form1.
| > | > /// </summary>
| > | > public class Form1 : System.Windows.Forms.Form
| > | > {
| > | > private WinForm_BeginEndUpdate_MouseMove.MyUserControl
myUserControl1;
| > | > private System.Timers.Timer timer1;
| > | > /// <summary>
| > | > /// Required designer variable.
| > | > /// </summary>
| > | > private System.ComponentModel.Container components = null;
| > | >
| > | > public Form1()
| > | > {
| > | > //
| > | > // Required for Windows Form Designer support
| > | > //
| > | > InitializeComponent();
| > | >
| > | > //
| > | > // TODO: Add any constructor code after InitializeComponent call
| > | > //
| > | > }
| > | >
| > | > /// <summary>
| > | > /// Clean up any resources being used.
| > | > /// </summary>
| > | > protected override void Dispose( bool disposing )
| > | > {
| > | > if( disposing )
| > | > {
| > | > if (components != null)
| > | > {
| > | > components.Dispose();
| > | > }
| > | > }
| > | > base.Dispose( disposing );
| > | > }
| > | >
| > | > #region Windows Form Designer generated code
| > | > /// <summary>
| > | > /// Required method for Designer support - do not modify
| > | > /// the contents of this method with the code editor.
| > | > /// </summary>
| > | > private void InitializeComponent()
| > | > {
| > | > this.myUserControl1 = new
| > | > WinForm_BeginEndUpdate_MouseMove.MyUserControl();
| > | > this.timer1 = new System.Timers.Timer();
| > | >
((System.ComponentModel.ISupportInitialize)(this.timer1)).BeginInit();
| > | > this.SuspendLayout();
| > | > //
| > | > // myUserControl1
| > | > //
| > | > this.myUserControl1.BackColor = System.Drawing.SystemColors.Desktop;
| > | > this.myUserControl1.Location = new System.Drawing.Point(72, 64);
| > | > this.myUserControl1.Name = "myUserControl1";
| > | > this.myUserControl1.Size = new System.Drawing.Size(256, 240);
| > | > this.myUserControl1.TabIndex = 2;
| > | > //
| > | > // timer1
| > | > //
| > | > this.timer1.Enabled = true;
| > | > this.timer1.Interval = 500;
| > | > this.timer1.SynchronizingObject = this;
| > | > this.timer1.Elapsed += new
| > | > System.Timers.ElapsedEventHandler(this.timer1_Elapsed);
| > | > //
| > | > // Form1
| > | > //
| > | > this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
| > | > this.ClientSize = new System.Drawing.Size(408, 421);
| > | > this.Controls.Add(this.myUserControl1);
| > | > this.Name = "Form1";
| > | > this.Text = "Form1";
| > | > this.MouseMove += new
| > | > System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);
| > | > ((System.ComponentModel.ISupportInitialize)(this.timer1)).EndInit();
| > | > this.ResumeLayout(false);
| > | >
| > | > }
| > | > #endregion
| > | >
| > | > /// <summary>
| > | > /// The main entry point for the application.
| > | > /// </summary>
| > | > [STAThread]
| > | > static void Main()
| > | > {
| > | > Application.Run(new Form1());
| > | > }
| > | >
| > | > private void Form1_MouseMove(object sender,
| > | > System.Windows.Forms.MouseEventArgs e)
| > | > {
| > | > System.Diagnostics.Debug.WriteLine("MainForm MouseMove received");
| > | > }
| > | >
| > | > private void timer1_Elapsed(object sender,
| > System.Timers.ElapsedEventArgs
| > | > e)
| > | > {
| > | > myUserControl1.BeginUpdate();
| > | > System.Diagnostics.Debug.WriteLine("BeginUpdate");
| > | > myUserControl1.DoUpdate();
| > | > myUserControl1.EndUpdate();
| > | > System.Diagnostics.Debug.WriteLine("EndUpdate");
| > | >
| > | > }
| > | > }
| > | > }
| > | >
| > | > </code>
| > | >
| > | >
| > | >
| > | >
| > |
| > |
| > |
| >
|
|
|
 
If this is by design, then how come the behavior does not reproduce with the
ListBox windows forms control?

- Abhishek

Ying-Shen Yu said:
Hi abhishek,
In fact, this issue also occurred in native win32 application, it by design.
The system sometimes delivers a WM_MOUSEMOVE message even if the mouse
hasn't moved. Programs which are sensitive to physical mouse movement (such
as screen savers) should compare the coordinates in the WM_MOUSEMOVE
message with the coordinates from the previous mouse message and ignore the
message if they are the same.

The Document didn't make this clear, we already noticed this problem, it
mightbe fixed in the next release of the document.Thanks for your reporting.
If you need handle the real OnMouseMove event you need first check if the
point of the cursor is same as the previous one. the code should be
executed only when the values are different.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!

--------------------
| From: "abhishek ghuwalewala" <[email protected]>
| References: <uV#[email protected]>
<[email protected]>
<#[email protected]>
<Km#[email protected]>
| Subject: Re: BeginUpdate/EndUpdate causing mouse move
| Date: Mon, 27 Oct 2003 10:29:09 -0600
| Lines: 348
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <O8N#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| NNTP-Posting-Host: client-79-20.natinst.com 130.164.79.20
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:55305
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| As I had mentioned before, this behavior does not reproduce for the
ListBox
| control. Would you happen to know what the ListBox control is doing that
| prevents this from happening?
|
| Abhishek
|
| | > Hi abhishek,
| > Thanks for your sample, I reproed your problem now.
| > For now, I haven't found a way to prevent MouseMove method to be called.
| > However, since BeginUpdate/Endupate is called by yourself, could you
add a
| > boolean flag before actually executing your codes in the MouseMove?
| > such as
| > InUpdating = false;
| > void BeginUpdate()
| > {
| > InUpdating = true;
| > SendMessage ....
| > }
| > void EndUpdate()
| > {
| > SendMessage() ...
| > InUpdating = false;
| > }
| > void MouseMove( ....)
| > {
| > if(!IsUpdating)
| > {
| > DoMouseMove();
| > }
| > }
| >
| > Does this work around solve your problem?
| > Please be free to post on the group, if you still have problem on this
| > issue.
| > Thanks!
| >
| > Best regards,
| >
| > Ying-Shen Yu [MSFT]
| > Microsoft Online Partner Support
| > Get Secure! - www.microsoft.com/security
| >
| > This posting is provided "AS IS" with no warranties and confers no
rights.
| > You should not reply this mail directly, "Online" should be removed
before
| > sending, Thanks!
| >
| > --------------------
| > | From: "abhishek ghuwalewala" <[email protected]>
| > | References: <uV#[email protected]>
| > <[email protected]>
| > | Subject: Re: BeginUpdate/EndUpdate causing mouse move
| > | Date: Fri, 24 Oct 2003 11:05:22 -0500
| > | Lines: 638
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| > | Message-ID: <#[email protected]>
| > | Newsgroups: microsoft.public.dotnet.framework.windowsforms
| > | NNTP-Posting-Host: client-64-158.natinst.com 130.164.64.158
| > | Path:
| >
|
cpmsftngxa06.phx.gbl!cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.
| > phx.gbl
| > | Xref: cpmsftngxa06.phx.gbl
| > microsoft.public.dotnet.framework.windowsforms:55191
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
| > |
| > | Ying-Shen,
| > |
| > | Thanks for your prompt reply. I am attaching a small sample project
that
| > | reproduces the problem. The instructions for reproducing the problem
are
| > | described in the application.
| > |
| > | Thanks,
| > | Abhishek
| > |
| > | | > | > Hi abhishek.
| > | > Thanks for your post!
| > | > You mean your mousemove event of your control or your form is fired
| when
| > | > you invoke the P/Invoke SendMessage
| > | > method?
| > | > I made a small program and tried to repro your problem, however I
| didn't
| > | > get any mouse move event on the user control or on the Form when
| > invoking
| > | > these two methods.
| > | > I pasted my test code after the signature, you may try it on your
| > system.
| > | > Probably it will be helpful if you could give me a
| > | > small sample project to repro this problem.
| > | >
| > | > Thanks for using MSDN Newsgroup!!
| > | >
| > | > Best regards,
| > | >
| > | > Ying-Shen Yu [MSFT]
| > | > Microsoft Online Partner Support
| > | > Get Secure! - www.microsoft.com/security
| > | >
| > | > This posting is provided "AS IS" with no warranties and confers no
| > rights.
| > | > You should not reply this mail directly, "Online" should be removed
| > before
| > | > sending, Thanks!
| > | >
| > | > <code file="MyUserControl.cs">
| > | > using System;
| > | > using System.Collections;
| > | > using System.ComponentModel;
| > | > using System.Drawing;
| > | > using System.Data;
| > | > using System.Windows.Forms;
| > | > using System.Runtime.InteropServices;
| > | >
| > | > namespace WinForm_BeginEndUpdate_MouseMove
| > | > {
| > | > /// <summary>
| > | > /// Summary description for MyUserControl.
| > | > /// </summary>
| > | > public class MyUserControl : System.Windows.Forms.UserControl
| > | > {
| > | > /// <summary>
| > | > /// Required designer variable.
| > | > /// </summary>
| > | > private System.ComponentModel.Container components = null;
| > | >
| > | > public MyUserControl()
| > | > {
| > | > // This call is required by the Windows.Forms Form Designer.
| > | > InitializeComponent();
| > | >
| > | > // TODO: Add any initialization after the InitializeComponent call
| > | >
| > | > }
| > | >
| > | > /// <summary>
| > | > /// Clean up any resources being used.
| > | > /// </summary>
| > | > protected override void Dispose( bool disposing )
| > | > {
| > | > if( disposing )
| > | > {
| > | > if(components != null)
| > | > {
| > | > components.Dispose();
| > | > }
| > | > }
| > | > base.Dispose( disposing );
| > | > }
| > | >
| > | > #region Component Designer generated code
| > | > /// <summary>
| > | > /// Required method for Designer support - do not modify
| > | > /// the contents of this method with the code editor.
| > | > /// </summary>
| > | > private void InitializeComponent()
| > | > {
| > | > //
| > | > // MyUserControl
| > | > //
| > | > this.BackColor = System.Drawing.SystemColors.Desktop;
| > | > this.Name = "MyUserControl";
| > | > this.Size = new System.Drawing.Size(368, 424);
| > | >
| > | > }
| > | > #endregion
| > | >
| > | > private class NativeMethods
| > | > {
| > | > [DllImport("user32.dll")]
| > | > private extern static int SendMessage(IntPtr hwnd, uint nMsg,
| > | > int wParam, int lParam);
| > | > private const int WM_SETREDRAW = 0x000B;
| > | > public static void BeginUpdate(IntPtr hwnd)
| > | > {
| > | > SendMessage(hwnd,WM_SETREDRAW,0,0);
| > | > }
| > | > public static void EndUpdate(IntPtr hwnd)
| > | > {
| > | > SendMessage(hwnd,WM_SETREDRAW,-1,0);
| > | > }
| > | >
| > | > }
| > | >
| > | >
| > | > public void BeginUpdate()
| > | > {
| > | > NativeMethods.BeginUpdate(Handle);
| > | > }
| > | > public void EndUpdate()
| > | > {
| > | > NativeMethods.EndUpdate(Handle);
| > | > }
| > | >
| > | >
| > | > protected override void OnMouseMove(MouseEventArgs e)
| > | > {
| > | > base.OnMouseMove (e);
| > | > System.Diagnostics.Debug.WriteLine("MouseMove received");
| > | > }
| > | > public void DoUpdate()
| > | > {
| > | > Graphics g = CreateGraphics();
| > | > g.FillRectangle(Brushes.Indigo,this.Bounds);
| > | > g.Dispose();
| > | > }
| > | > }
| > | > }
| > | > </code>
| > | > <code file="Form1.cs">
| > | > using System;
| > | > using System.Drawing;
| > | > using System.Collections;
| > | > using System.ComponentModel;
| > | > using System.Windows.Forms;
| > | > using System.Data;
| > | >
| > | > namespace WinForm_BeginEndUpdate_MouseMove
| > | > {
| > | > /// <summary>
| > | > /// Summary description for Form1.
| > | > /// </summary>
| > | > public class Form1 : System.Windows.Forms.Form
| > | > {
| > | > private WinForm_BeginEndUpdate_MouseMove.MyUserControl
myUserControl1;
| > | > private System.Timers.Timer timer1;
| > | > /// <summary>
| > | > /// Required designer variable.
| > | > /// </summary>
| > | > private System.ComponentModel.Container components = null;
| > | >
| > | > public Form1()
| > | > {
| > | > //
| > | > // Required for Windows Form Designer support
| > | > //
| > | > InitializeComponent();
| > | >
| > | > //
| > | > // TODO: Add any constructor code after InitializeComponent call
| > | > //
| > | > }
| > | >
| > | > /// <summary>
| > | > /// Clean up any resources being used.
| > | > /// </summary>
| > | > protected override void Dispose( bool disposing )
| > | > {
| > | > if( disposing )
| > | > {
| > | > if (components != null)
| > | > {
| > | > components.Dispose();
| > | > }
| > | > }
| > | > base.Dispose( disposing );
| > | > }
| > | >
| > | > #region Windows Form Designer generated code
| > | > /// <summary>
| > | > /// Required method for Designer support - do not modify
| > | > /// the contents of this method with the code editor.
| > | > /// </summary>
| > | > private void InitializeComponent()
| > | > {
| > | > this.myUserControl1 = new
| > | > WinForm_BeginEndUpdate_MouseMove.MyUserControl();
| > | > this.timer1 = new System.Timers.Timer();
| > | >
((System.ComponentModel.ISupportInitialize)(this.timer1)).BeginInit();
| > | > this.SuspendLayout();
| > | > //
| > | > // myUserControl1
| > | > //
| > | > this.myUserControl1.BackColor = System.Drawing.SystemColors.Desktop;
| > | > this.myUserControl1.Location = new System.Drawing.Point(72, 64);
| > | > this.myUserControl1.Name = "myUserControl1";
| > | > this.myUserControl1.Size = new System.Drawing.Size(256, 240);
| > | > this.myUserControl1.TabIndex = 2;
| > | > //
| > | > // timer1
| > | > //
| > | > this.timer1.Enabled = true;
| > | > this.timer1.Interval = 500;
| > | > this.timer1.SynchronizingObject = this;
| > | > this.timer1.Elapsed += new
| > | > System.Timers.ElapsedEventHandler(this.timer1_Elapsed);
| > | > //
| > | > // Form1
| > | > //
| > | > this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
| > | > this.ClientSize = new System.Drawing.Size(408, 421);
| > | > this.Controls.Add(this.myUserControl1);
| > | > this.Name = "Form1";
| > | > this.Text = "Form1";
| > | > this.MouseMove += new
| > | > System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);
| > | > ((System.ComponentModel.ISupportInitialize)(this.timer1)).EndInit();
| > | > this.ResumeLayout(false);
| > | >
| > | > }
| > | > #endregion
| > | >
| > | > /// <summary>
| > | > /// The main entry point for the application.
| > | > /// </summary>
| > | > [STAThread]
| > | > static void Main()
| > | > {
| > | > Application.Run(new Form1());
| > | > }
| > | >
| > | > private void Form1_MouseMove(object sender,
| > | > System.Windows.Forms.MouseEventArgs e)
| > | > {
| > | > System.Diagnostics.Debug.WriteLine("MainForm MouseMove received");
| > | > }
| > | >
| > | > private void timer1_Elapsed(object sender,
| > System.Timers.ElapsedEventArgs
| > | > e)
| > | > {
| > | > myUserControl1.BeginUpdate();
| > | > System.Diagnostics.Debug.WriteLine("BeginUpdate");
| > | > myUserControl1.DoUpdate();
| > | > myUserControl1.EndUpdate();
| > | > System.Diagnostics.Debug.WriteLine("EndUpdate");
| > | >
| > | > }
| > | > }
| > | > }
| > | >
| > | > </code>
| > | >
| > | >
| > | >
| > | >
| > |
| > |
| > |
| >
|
|
|
 
Mr. Jack :
You seem to be someone who was recently fired for being incompetent.
People are trying to get help here and not hear your foul language.
I think Moderator of this group should close your account


Jack Mayhoff said:
So, this BUG is BY DESIGN?


"The system sometimes delivers a WM_MOUSEMOVE message even if the mouse
hasn't moved"


Sounds like a bug to me, a signal fired that the mouse has moved when infact
it hasnt, sory, by design doesn't hide bullssshit
--

Jack Mayhoff
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Ying-Shen Yu said:
Hi abhishek,
In fact, this issue also occurred in native win32 application, it by design.
The system sometimes delivers a WM_MOUSEMOVE message even if the mouse
hasn't moved. Programs which are sensitive to physical mouse movement (such
as screen savers) should compare the coordinates in the WM_MOUSEMOVE
message with the coordinates from the previous mouse message and ignore the
message if they are the same.

The Document didn't make this clear, we already noticed this problem, it
mightbe fixed in the next release of the document.Thanks for your reporting.
If you need handle the real OnMouseMove event you need first check if the
point of the cursor is same as the previous one. the code should be
executed only when the values are different.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!

--------------------
| From: "abhishek ghuwalewala" <[email protected]>
| References: <uV#[email protected]>
<[email protected]>
<#[email protected]>
<Km#[email protected]>
| Subject: Re: BeginUpdate/EndUpdate causing mouse move
| Date: Mon, 27 Oct 2003 10:29:09 -0600
| Lines: 348
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <O8N#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| NNTP-Posting-Host: client-79-20.natinst.com 130.164.79.20
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.windowsforms:55305
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| As I had mentioned before, this behavior does not reproduce for the ListBox
| control. Would you happen to know what the ListBox control is doing that
| prevents this from happening?
|
| Abhishek
|
| | > Hi abhishek,
| > Thanks for your sample, I reproed your problem now.
| > For now, I haven't found a way to prevent MouseMove method to be called.
| > However, since BeginUpdate/Endupate is called by yourself, could you add a
| > boolean flag before actually executing your codes in the MouseMove?
| > such as
| > InUpdating = false;
| > void BeginUpdate()
| > {
| > InUpdating = true;
| > SendMessage ....
| > }
| > void EndUpdate()
| > {
| > SendMessage() ...
| > InUpdating = false;
| > }
| > void MouseMove( ....)
| > {
| > if(!IsUpdating)
| > {
| > DoMouseMove();
| > }
| > }
| >
| > Does this work around solve your problem?
| > Please be free to post on the group, if you still have problem on this
| > issue.
| > Thanks!
| >
| > Best regards,
| >
| > Ying-Shen Yu [MSFT]
| > Microsoft Online Partner Support
| > Get Secure! - www.microsoft.com/security
| >
| > This posting is provided "AS IS" with no warranties and confers no rights.
| > You should not reply this mail directly, "Online" should be removed before
| > sending, Thanks!
| >
| > --------------------
| > | From: "abhishek ghuwalewala" <[email protected]>
| > | References: <uV#[email protected]>
| > | Subject: Re: BeginUpdate/EndUpdate causing mouse move
| > | Date: Fri, 24 Oct 2003 11:05:22 -0500
| > | Lines: 638
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| > | Message-ID: <#[email protected]>
| > | Newsgroups: microsoft.public.dotnet.framework.windowsforms
| > | NNTP-Posting-Host: client-64-158.natinst.com 130.164.64.158
| > | Path:
| >
|
cpmsftngxa06.phx.gbl!cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.
| > phx.gbl
| > | Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.windowsforms:55191
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
| > |
| > | Ying-Shen,
| > |
| > | Thanks for your prompt reply. I am attaching a small sample project that
| > | reproduces the problem. The instructions for reproducing the problem are
| > | described in the application.
| > |
| > | Thanks,
| > | Abhishek
| > |
| > | | > | > Hi abhishek.
| > | > Thanks for your post!
| > | > You mean your mousemove event of your control or your form is fired
when
| > | > you invoke the P/Invoke SendMessage
| > | > method?
| > | > I made a small program and tried to repro your problem, however I didn't
| > | > get any mouse move event on the user control or on the Form when invoking
| > | > these two methods.
| > | > I pasted my test code after the signature, you may try it on your system.
| > | > Probably it will be helpful if you could give me a
| > | > small sample project to repro this problem.
| > | >
| > | > Thanks for using MSDN Newsgroup!!
| > | >
| > | > Best regards,
| > | >
| > | > Ying-Shen Yu [MSFT]
| > | > Microsoft Online Partner Support
| > | > Get Secure! - www.microsoft.com/security
| > | >
| > | > This posting is provided "AS IS" with no warranties and confers no rights.
| > | > You should not reply this mail directly, "Online" should be removed
before
| > | > sending, Thanks!
| > | >
| > | > <code file="MyUserControl.cs">
| > | > using System;
| > | > using System.Collections;
| > | > using System.ComponentModel;
| > | > using System.Drawing;
| > | > using System.Data;
| > | > using System.Windows.Forms;
| > | > using System.Runtime.InteropServices;
| > | >
| > | > namespace WinForm_BeginEndUpdate_MouseMove
| > | > {
| > | > /// <summary>
| > | > /// Summary description for MyUserControl.
| > | > /// </summary>
| > | > public class MyUserControl : System.Windows.Forms.UserControl
| > | > {
| > | > /// <summary>
| > | > /// Required designer variable.
| > | > /// </summary>
| > | > private System.ComponentModel.Container components = null;
| > | >
| > | > public MyUserControl()
| > | > {
| > | > // This call is required by the Windows.Forms Form Designer.
| > | > InitializeComponent();
| > | >
| > | > // TODO: Add any initialization after the InitializeComponent call
| > | >
| > | > }
| > | >
| > | > /// <summary>
| > | > /// Clean up any resources being used.
| > | > /// </summary>
| > | > protected override void Dispose( bool disposing )
| > | > {
| > | > if( disposing )
| > | > {
| > | > if(components != null)
| > | > {
| > | > components.Dispose();
| > | > }
| > | > } base.Dispose( disposing );
| > | > }
| > | >
| > | > #region Component Designer generated code
| > | > /// <summary>
| > | > /// Required method for Designer support - do not modify
| > | > /// the contents of this method with the code editor.
| > | > /// </summary>
| > | > private void InitializeComponent()
| > | > {
| > | > //
| > | > // MyUserControl
| > | > //
| > | > this.BackColor = System.Drawing.SystemColors.Desktop;
| > | > this.Name = "MyUserControl";
| > | > this.Size = new System.Drawing.Size(368, 424);
| > | >
| > | > }
| > | > #endregion
| > | >
| > | > private class NativeMethods
| > | > {
| > | > [DllImport("user32.dll")]
| > | > private extern static int SendMessage(IntPtr hwnd, uint nMsg,
| > | > int wParam, int lParam);
| > | > private const int WM_SETREDRAW = 0x000B;
| > | > public static void BeginUpdate(IntPtr hwnd)
| > | > {
| > | > SendMessage(hwnd,WM_SETREDRAW,0,0);
| > | > }
| > | > public static void EndUpdate(IntPtr hwnd)
| > | > {
| > | > SendMessage(hwnd,WM_SETREDRAW,-1,0);
| > | > }
| > | > }
| > | >
| > | >
| > | > public void BeginUpdate()
| > | > {
| > | > NativeMethods.BeginUpdate(Handle);
| > | > }
| > | > public void EndUpdate()
| > | > {
| > | > NativeMethods.EndUpdate(Handle);
| > | > }
| > | >
| > | >
| > | > protected override void OnMouseMove(MouseEventArgs e)
| > | > {
| > | > base.OnMouseMove (e);
| > | > System.Diagnostics.Debug.WriteLine("MouseMove received");
| > | > }
| > | > public void DoUpdate()
| > | > {
| > | > Graphics g = CreateGraphics();
| > | > g.FillRectangle(Brushes.Indigo,this.Bounds);
| > | > g.Dispose();
| > | > }
| > | > }
| > | > }
| > | > </code>
| > | > <code file="Form1.cs">
| > | > using System;
| > | > using System.Drawing;
| > | > using System.Collections;
| > | > using System.ComponentModel;
| > | > using System.Windows.Forms;
| > | > using System.Data;
| > | >
| > | > namespace WinForm_BeginEndUpdate_MouseMove
| > | > {
| > | > /// <summary>
| > | > /// Summary description for Form1.
| > | > /// </summary>
| > | > public class Form1 : System.Windows.Forms.Form
| > | > {
| > | > private WinForm_BeginEndUpdate_MouseMove.MyUserControl myUserControl1;
| > | > private System.Timers.Timer timer1;
| > | > /// <summary>
| > | > /// Required designer variable.
| > | > /// </summary>
| > | > private System.ComponentModel.Container components = null;
| > | >
| > | > public Form1()
| > | > {
| > | > //
| > | > // Required for Windows Form Designer support
| > | > //
| > | > InitializeComponent();
| > | >
| > | > //
| > | > // TODO: Add any constructor code after InitializeComponent call
| > | > //
| > | > }
| > | >
| > | > /// <summary>
| > | > /// Clean up any resources being used.
| > | > /// </summary>
| > | > protected override void Dispose( bool disposing )
| > | > {
| > | > if( disposing )
| > | > {
| > | > if (components != null)
| > | > {
| > | > components.Dispose();
| > | > }
| > | > } base.Dispose( disposing );
| > | > }
| > | >
| > | > #region Windows Form Designer generated code
| > | > /// <summary>
| > | > /// Required method for Designer support - do not modify
| > | > /// the contents of this method with the code editor.
| > | > /// </summary>
| > | > private void InitializeComponent()
| > | > {
| > | > this.myUserControl1 = new
| > | > WinForm_BeginEndUpdate_MouseMove.MyUserControl();
| > | > this.timer1 = new System.Timers.Timer();
| > | > ((System.ComponentModel.ISupportInitialize)(this.timer1)).BeginInit();
| > | > this.SuspendLayout();
| > | > //
| > | > // myUserControl1
| > | > //
| > | > this.myUserControl1.BackColor = System.Drawing.SystemColors.Desktop;
| > | > this.myUserControl1.Location = new System.Drawing.Point(72, 64);
| > | > this.myUserControl1.Name = "myUserControl1";
| > | > this.myUserControl1.Size = new System.Drawing.Size(256, 240);
| > | > this.myUserControl1.TabIndex = 2;
| > | > //
| > | > // timer1
| > | > //
| > | > this.timer1.Enabled = true;
| > | > this.timer1.Interval = 500;
| > | > this.timer1.SynchronizingObject = this;
| > | > this.timer1.Elapsed += new
| > | > System.Timers.ElapsedEventHandler(this.timer1_Elapsed);
| > | > //
| > | > // Form1
| > | > //
| > | > this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
| > | > this.ClientSize = new System.Drawing.Size(408, 421);
| > | > this.Controls.Add(this.myUserControl1);
| > | > this.Name = "Form1";
| > | > this.Text = "Form1";
| > | > this.MouseMove += new
| > | > System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);
| > | > ((System.ComponentModel.ISupportInitialize)(this.timer1)).EndInit();
| > | > this.ResumeLayout(false);
| > | >
| > | > }
| > | > #endregion
| > | >
| > | > /// <summary>
| > | > /// The main entry point for the application.
| > | > /// </summary>
| > | > [STAThread]
| > | > static void Main()
| > | > {
| > | > Application.Run(new Form1());
| > | > }
| > | >
| > | > private void Form1_MouseMove(object sender,
| > | > System.Windows.Forms.MouseEventArgs e)
| > | > {
| > | > System.Diagnostics.Debug.WriteLine("MainForm MouseMove received");
| > | > }
| > | >
| > | > private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs
| > | > e)
| > | > {
| > | > myUserControl1.BeginUpdate();
| > | > System.Diagnostics.Debug.WriteLine("BeginUpdate");
| > | > myUserControl1.DoUpdate();
| > | > myUserControl1.EndUpdate();
| > | > System.Diagnostics.Debug.WriteLine("EndUpdate");
| > | >
| > | > }
| > | > }
| > | > }
| > | >
| > | > </code>
| > | >
| > | >
| > | >
| > | >
| > |
| > |
| > |
| >
|
|
|
 
I am still looking for an answer as to why the reported behavior does not
reproduce on a ListBox control. What is it doing differently?

Abhishek

Ying-Shen Yu said:
Hi abhishek,
In fact, this issue also occurred in native win32 application, it by design.
The system sometimes delivers a WM_MOUSEMOVE message even if the mouse
hasn't moved. Programs which are sensitive to physical mouse movement (such
as screen savers) should compare the coordinates in the WM_MOUSEMOVE
message with the coordinates from the previous mouse message and ignore the
message if they are the same.

The Document didn't make this clear, we already noticed this problem, it
mightbe fixed in the next release of the document.Thanks for your reporting.
If you need handle the real OnMouseMove event you need first check if the
point of the cursor is same as the previous one. the code should be
executed only when the values are different.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!

--------------------
| From: "abhishek ghuwalewala" <[email protected]>
| References: <uV#[email protected]>
<[email protected]>
<#[email protected]>
<Km#[email protected]>
| Subject: Re: BeginUpdate/EndUpdate causing mouse move
| Date: Mon, 27 Oct 2003 10:29:09 -0600
| Lines: 348
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <O8N#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| NNTP-Posting-Host: client-79-20.natinst.com 130.164.79.20
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:55305
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| As I had mentioned before, this behavior does not reproduce for the
ListBox
| control. Would you happen to know what the ListBox control is doing that
| prevents this from happening?
|
| Abhishek
|
| | > Hi abhishek,
| > Thanks for your sample, I reproed your problem now.
| > For now, I haven't found a way to prevent MouseMove method to be called.
| > However, since BeginUpdate/Endupate is called by yourself, could you
add a
| > boolean flag before actually executing your codes in the MouseMove?
| > such as
| > InUpdating = false;
| > void BeginUpdate()
| > {
| > InUpdating = true;
| > SendMessage ....
| > }
| > void EndUpdate()
| > {
| > SendMessage() ...
| > InUpdating = false;
| > }
| > void MouseMove( ....)
| > {
| > if(!IsUpdating)
| > {
| > DoMouseMove();
| > }
| > }
| >
| > Does this work around solve your problem?
| > Please be free to post on the group, if you still have problem on this
| > issue.
| > Thanks!
| >
| > Best regards,
| >
| > Ying-Shen Yu [MSFT]
| > Microsoft Online Partner Support
| > Get Secure! - www.microsoft.com/security
| >
| > This posting is provided "AS IS" with no warranties and confers no
rights.
| > You should not reply this mail directly, "Online" should be removed
before
| > sending, Thanks!
| >
| > --------------------
| > | From: "abhishek ghuwalewala" <[email protected]>
| > | References: <uV#[email protected]>
| > <[email protected]>
| > | Subject: Re: BeginUpdate/EndUpdate causing mouse move
| > | Date: Fri, 24 Oct 2003 11:05:22 -0500
| > | Lines: 638
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| > | Message-ID: <#[email protected]>
| > | Newsgroups: microsoft.public.dotnet.framework.windowsforms
| > | NNTP-Posting-Host: client-64-158.natinst.com 130.164.64.158
| > | Path:
| >
|
cpmsftngxa06.phx.gbl!cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.
| > phx.gbl
| > | Xref: cpmsftngxa06.phx.gbl
| > microsoft.public.dotnet.framework.windowsforms:55191
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
| > |
| > | Ying-Shen,
| > |
| > | Thanks for your prompt reply. I am attaching a small sample project
that
| > | reproduces the problem. The instructions for reproducing the problem
are
| > | described in the application.
| > |
| > | Thanks,
| > | Abhishek
| > |
| > | | > | > Hi abhishek.
| > | > Thanks for your post!
| > | > You mean your mousemove event of your control or your form is fired
| when
| > | > you invoke the P/Invoke SendMessage
| > | > method?
| > | > I made a small program and tried to repro your problem, however I
| didn't
| > | > get any mouse move event on the user control or on the Form when
| > invoking
| > | > these two methods.
| > | > I pasted my test code after the signature, you may try it on your
| > system.
| > | > Probably it will be helpful if you could give me a
| > | > small sample project to repro this problem.
| > | >
| > | > Thanks for using MSDN Newsgroup!!
| > | >
| > | > Best regards,
| > | >
| > | > Ying-Shen Yu [MSFT]
| > | > Microsoft Online Partner Support
| > | > Get Secure! - www.microsoft.com/security
| > | >
| > | > This posting is provided "AS IS" with no warranties and confers no
| > rights.
| > | > You should not reply this mail directly, "Online" should be removed
| > before
| > | > sending, Thanks!
| > | >
| > | > <code file="MyUserControl.cs">
| > | > using System;
| > | > using System.Collections;
| > | > using System.ComponentModel;
| > | > using System.Drawing;
| > | > using System.Data;
| > | > using System.Windows.Forms;
| > | > using System.Runtime.InteropServices;
| > | >
| > | > namespace WinForm_BeginEndUpdate_MouseMove
| > | > {
| > | > /// <summary>
| > | > /// Summary description for MyUserControl.
| > | > /// </summary>
| > | > public class MyUserControl : System.Windows.Forms.UserControl
| > | > {
| > | > /// <summary>
| > | > /// Required designer variable.
| > | > /// </summary>
| > | > private System.ComponentModel.Container components = null;
| > | >
| > | > public MyUserControl()
| > | > {
| > | > // This call is required by the Windows.Forms Form Designer.
| > | > InitializeComponent();
| > | >
| > | > // TODO: Add any initialization after the InitializeComponent call
| > | >
| > | > }
| > | >
| > | > /// <summary>
| > | > /// Clean up any resources being used.
| > | > /// </summary>
| > | > protected override void Dispose( bool disposing )
| > | > {
| > | > if( disposing )
| > | > {
| > | > if(components != null)
| > | > {
| > | > components.Dispose();
| > | > }
| > | > }
| > | > base.Dispose( disposing );
| > | > }
| > | >
| > | > #region Component Designer generated code
| > | > /// <summary>
| > | > /// Required method for Designer support - do not modify
| > | > /// the contents of this method with the code editor.
| > | > /// </summary>
| > | > private void InitializeComponent()
| > | > {
| > | > //
| > | > // MyUserControl
| > | > //
| > | > this.BackColor = System.Drawing.SystemColors.Desktop;
| > | > this.Name = "MyUserControl";
| > | > this.Size = new System.Drawing.Size(368, 424);
| > | >
| > | > }
| > | > #endregion
| > | >
| > | > private class NativeMethods
| > | > {
| > | > [DllImport("user32.dll")]
| > | > private extern static int SendMessage(IntPtr hwnd, uint nMsg,
| > | > int wParam, int lParam);
| > | > private const int WM_SETREDRAW = 0x000B;
| > | > public static void BeginUpdate(IntPtr hwnd)
| > | > {
| > | > SendMessage(hwnd,WM_SETREDRAW,0,0);
| > | > }
| > | > public static void EndUpdate(IntPtr hwnd)
| > | > {
| > | > SendMessage(hwnd,WM_SETREDRAW,-1,0);
| > | > }
| > | >
| > | > }
| > | >
| > | >
| > | > public void BeginUpdate()
| > | > {
| > | > NativeMethods.BeginUpdate(Handle);
| > | > }
| > | > public void EndUpdate()
| > | > {
| > | > NativeMethods.EndUpdate(Handle);
| > | > }
| > | >
| > | >
| > | > protected override void OnMouseMove(MouseEventArgs e)
| > | > {
| > | > base.OnMouseMove (e);
| > | > System.Diagnostics.Debug.WriteLine("MouseMove received");
| > | > }
| > | > public void DoUpdate()
| > | > {
| > | > Graphics g = CreateGraphics();
| > | > g.FillRectangle(Brushes.Indigo,this.Bounds);
| > | > g.Dispose();
| > | > }
| > | > }
| > | > }
| > | > </code>
| > | > <code file="Form1.cs">
| > | > using System;
| > | > using System.Drawing;
| > | > using System.Collections;
| > | > using System.ComponentModel;
| > | > using System.Windows.Forms;
| > | > using System.Data;
| > | >
| > | > namespace WinForm_BeginEndUpdate_MouseMove
| > | > {
| > | > /// <summary>
| > | > /// Summary description for Form1.
| > | > /// </summary>
| > | > public class Form1 : System.Windows.Forms.Form
| > | > {
| > | > private WinForm_BeginEndUpdate_MouseMove.MyUserControl
myUserControl1;
| > | > private System.Timers.Timer timer1;
| > | > /// <summary>
| > | > /// Required designer variable.
| > | > /// </summary>
| > | > private System.ComponentModel.Container components = null;
| > | >
| > | > public Form1()
| > | > {
| > | > //
| > | > // Required for Windows Form Designer support
| > | > //
| > | > InitializeComponent();
| > | >
| > | > //
| > | > // TODO: Add any constructor code after InitializeComponent call
| > | > //
| > | > }
| > | >
| > | > /// <summary>
| > | > /// Clean up any resources being used.
| > | > /// </summary>
| > | > protected override void Dispose( bool disposing )
| > | > {
| > | > if( disposing )
| > | > {
| > | > if (components != null)
| > | > {
| > | > components.Dispose();
| > | > }
| > | > }
| > | > base.Dispose( disposing );
| > | > }
| > | >
| > | > #region Windows Form Designer generated code
| > | > /// <summary>
| > | > /// Required method for Designer support - do not modify
| > | > /// the contents of this method with the code editor.
| > | > /// </summary>
| > | > private void InitializeComponent()
| > | > {
| > | > this.myUserControl1 = new
| > | > WinForm_BeginEndUpdate_MouseMove.MyUserControl();
| > | > this.timer1 = new System.Timers.Timer();
| > | >
((System.ComponentModel.ISupportInitialize)(this.timer1)).BeginInit();
| > | > this.SuspendLayout();
| > | > //
| > | > // myUserControl1
| > | > //
| > | > this.myUserControl1.BackColor = System.Drawing.SystemColors.Desktop;
| > | > this.myUserControl1.Location = new System.Drawing.Point(72, 64);
| > | > this.myUserControl1.Name = "myUserControl1";
| > | > this.myUserControl1.Size = new System.Drawing.Size(256, 240);
| > | > this.myUserControl1.TabIndex = 2;
| > | > //
| > | > // timer1
| > | > //
| > | > this.timer1.Enabled = true;
| > | > this.timer1.Interval = 500;
| > | > this.timer1.SynchronizingObject = this;
| > | > this.timer1.Elapsed += new
| > | > System.Timers.ElapsedEventHandler(this.timer1_Elapsed);
| > | > //
| > | > // Form1
| > | > //
| > | > this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
| > | > this.ClientSize = new System.Drawing.Size(408, 421);
| > | > this.Controls.Add(this.myUserControl1);
| > | > this.Name = "Form1";
| > | > this.Text = "Form1";
| > | > this.MouseMove += new
| > | > System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);
| > | > ((System.ComponentModel.ISupportInitialize)(this.timer1)).EndInit();
| > | > this.ResumeLayout(false);
| > | >
| > | > }
| > | > #endregion
| > | >
| > | > /// <summary>
| > | > /// The main entry point for the application.
| > | > /// </summary>
| > | > [STAThread]
| > | > static void Main()
| > | > {
| > | > Application.Run(new Form1());
| > | > }
| > | >
| > | > private void Form1_MouseMove(object sender,
| > | > System.Windows.Forms.MouseEventArgs e)
| > | > {
| > | > System.Diagnostics.Debug.WriteLine("MainForm MouseMove received");
| > | > }
| > | >
| > | > private void timer1_Elapsed(object sender,
| > System.Timers.ElapsedEventArgs
| > | > e)
| > | > {
| > | > myUserControl1.BeginUpdate();
| > | > System.Diagnostics.Debug.WriteLine("BeginUpdate");
| > | > myUserControl1.DoUpdate();
| > | > myUserControl1.EndUpdate();
| > | > System.Diagnostics.Debug.WriteLine("EndUpdate");
| > | >
| > | > }
| > | > }
| > | > }
| > | >
| > | > </code>
| > | >
| > | >
| > | >
| > | >
| > |
| > |
| > |
| >
|
|
|
 
Hi abhishek,
Sorry for keeping you waiting, I forwarded your question to our developer
team and got the follow reply:
<cite>
Whether WM_SETREDRAW causes a mousemove is up to the window. Some windows
let USER32 do default redraw handling, which will generate a mousemove on
enable. Listbox has custom redraw code which avoids the mousemove. You
simply shouldn't care one way or the other.
</cite>
So it up to the internal implementation, for why the default redraw will
cause the WM_MOUSEMOVE, here is an blog which may answer your question:
http://blogs.gotdotnet.com/raymondc/PermaLink.aspx/d8afd9b1-06ec-4046-939d-d
dc4d7662ec2

Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!

--------------------
| From: "abhishek ghuwalewala" <[email protected]>
| References: <uV#[email protected]>
<[email protected]>
<#[email protected]>
<Km#[email protected]>
<O8N#[email protected]>
<[email protected]>
| Subject: Re: BeginUpdate/EndUpdate causing mouse move
| Date: Wed, 29 Oct 2003 15:20:12 -0600
| Lines: 424
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| NNTP-Posting-Host: client-78-96.natinst.com 130.164.78.96
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:55468
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| I am still looking for an answer as to why the reported behavior does not
| reproduce on a ListBox control. What is it doing differently?
|
| Abhishek
|
| | > Hi abhishek,
| > In fact, this issue also occurred in native win32 application, it by
| design.
| > The system sometimes delivers a WM_MOUSEMOVE message even if the mouse
| > hasn't moved. Programs which are sensitive to physical mouse movement
| (such
| > as screen savers) should compare the coordinates in the WM_MOUSEMOVE
| > message with the coordinates from the previous mouse message and ignore
| the
| > message if they are the same.
| >
| > The Document didn't make this clear, we already noticed this problem, it
| > mightbe fixed in the next release of the document.Thanks for your
| reporting.
| > If you need handle the real OnMouseMove event you need first check if
the
| > point of the cursor is same as the previous one. the code should be
| > executed only when the values are different.
| > Thanks!
| >
| > Best regards,
| >
| > Ying-Shen Yu [MSFT]
| > Microsoft Online Partner Support
| > Get Secure! - www.microsoft.com/security
| >
| > This posting is provided "AS IS" with no warranties and confers no
rights.
| > You should not reply this mail directly, "Online" should be removed
before
| > sending, Thanks!
| >
| > --------------------
| > | From: "abhishek ghuwalewala" <[email protected]>
| > | References: <uV#[email protected]>
| > <[email protected]>
| > <#[email protected]>
| > <Km#[email protected]>
| > | Subject: Re: BeginUpdate/EndUpdate causing mouse move
| > | Date: Mon, 27 Oct 2003 10:29:09 -0600
| > | Lines: 348
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| > | Message-ID: <O8N#[email protected]>
| > | Newsgroups: microsoft.public.dotnet.framework.windowsforms
| > | NNTP-Posting-Host: client-79-20.natinst.com 130.164.79.20
| > | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| > | Xref: cpmsftngxa06.phx.gbl
| > microsoft.public.dotnet.framework.windowsforms:55305
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
| > |
| > | As I had mentioned before, this behavior does not reproduce for the
| > ListBox
| > | control. Would you happen to know what the ListBox control is doing
that
| > | prevents this from happening?
| > |
| > | Abhishek
| > |
| > | | > | > Hi abhishek,
| > | > Thanks for your sample, I reproed your problem now.
| > | > For now, I haven't found a way to prevent MouseMove method to be
| called.
| > | > However, since BeginUpdate/Endupate is called by yourself, could you
| > add a
| > | > boolean flag before actually executing your codes in the MouseMove?
| > | > such as
| > | > InUpdating = false;
| > | > void BeginUpdate()
| > | > {
| > | > InUpdating = true;
| > | > SendMessage ....
| > | > }
| > | > void EndUpdate()
| > | > {
| > | > SendMessage() ...
| > | > InUpdating = false;
| > | > }
| > | > void MouseMove( ....)
| > | > {
| > | > if(!IsUpdating)
| > | > {
| > | > DoMouseMove();
| > | > }
| > | > }
| > | >
| > | > Does this work around solve your problem?
| > | > Please be free to post on the group, if you still have problem on
this
| > | > issue.
| > | > Thanks!
| > | >
| > | > Best regards,
| > | >
| > | > Ying-Shen Yu [MSFT]
| > | > Microsoft Online Partner Support
| > | > Get Secure! - www.microsoft.com/security
| > | >
| > | > This posting is provided "AS IS" with no warranties and confers no
| > rights.
| > | > You should not reply this mail directly, "Online" should be removed
| > before
| > | > sending, Thanks!
| > | >
| > | > --------------------
| > | > | From: "abhishek ghuwalewala" <[email protected]>
| > | > | References: <uV#[email protected]>
| > | > <[email protected]>
| > | > | Subject: Re: BeginUpdate/EndUpdate causing mouse move
| > | > | Date: Fri, 24 Oct 2003 11:05:22 -0500
| > | > | Lines: 638
| > | > | X-Priority: 3
| > | > | X-MSMail-Priority: Normal
| > | > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| > | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| > | > | Message-ID: <#[email protected]>
| > | > | Newsgroups: microsoft.public.dotnet.framework.windowsforms
| > | > | NNTP-Posting-Host: client-64-158.natinst.com 130.164.64.158
| > | > | Path:
| > | >
| > |
| >
|
cpmsftngxa06.phx.gbl!cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.
| > | > phx.gbl
| > | > | Xref: cpmsftngxa06.phx.gbl
| > | > microsoft.public.dotnet.framework.windowsforms:55191
| > | > | X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
| > | > |
| > | > | Ying-Shen,
| > | > |
| > | > | Thanks for your prompt reply. I am attaching a small sample
project
| > that
| > | > | reproduces the problem. The instructions for reproducing the
problem
| > are
| > | > | described in the application.
| > | > |
| > | > | Thanks,
| > | > | Abhishek
| > | > |
| > | > | | > | > | > Hi abhishek.
| > | > | > Thanks for your post!
| > | > | > You mean your mousemove event of your control or your form is
| fired
| > | when
| > | > | > you invoke the P/Invoke SendMessage
| > | > | > method?
| > | > | > I made a small program and tried to repro your problem, however
I
| > | didn't
| > | > | > get any mouse move event on the user control or on the Form when
| > | > invoking
| > | > | > these two methods.
| > | > | > I pasted my test code after the signature, you may try it on
your
| > | > system.
| > | > | > Probably it will be helpful if you could give me a
| > | > | > small sample project to repro this problem.
| > | > | >
| > | > | > Thanks for using MSDN Newsgroup!!
| > | > | >
| > | > | > Best regards,
| > | > | >
| > | > | > Ying-Shen Yu [MSFT]
| > | > | > Microsoft Online Partner Support
| > | > | > Get Secure! - www.microsoft.com/security
| > | > | >
| > | > | > This posting is provided "AS IS" with no warranties and confers
no
| > | > rights.
| > | > | > You should not reply this mail directly, "Online" should be
| removed
| > | > before
| > | > | > sending, Thanks!
| > | > | >
| > | > | > <code file="MyUserControl.cs">
| > | > | > using System;
| > | > | > using System.Collections;
| > | > | > using System.ComponentModel;
| > | > | > using System.Drawing;
| > | > | > using System.Data;
| > | > | > using System.Windows.Forms;
| > | > | > using System.Runtime.InteropServices;
| > | > | >
| > | > | > namespace WinForm_BeginEndUpdate_MouseMove
| > | > | > {
| > | > | > /// <summary>
| > | > | > /// Summary description for MyUserControl.
| > | > | > /// </summary>
| > | > | > public class MyUserControl : System.Windows.Forms.UserControl
| > | > | > {
| > | > | > /// <summary>
| > | > | > /// Required designer variable.
| > | > | > /// </summary>
| > | > | > private System.ComponentModel.Container components = null;
| > | > | >
| > | > | > public MyUserControl()
| > | > | > {
| > | > | > // This call is required by the Windows.Forms Form Designer.
| > | > | > InitializeComponent();
| > | > | >
| > | > | > // TODO: Add any initialization after the InitializeComponent
call
| > | > | >
| > | > | > }
| > | > | >
| > | > | > /// <summary>
| > | > | > /// Clean up any resources being used.
| > | > | > /// </summary>
| > | > | > protected override void Dispose( bool disposing )
| > | > | > {
| > | > | > if( disposing )
| > | > | > {
| > | > | > if(components != null)
| > | > | > {
| > | > | > components.Dispose();
| > | > | > }
| > | > | > }
| > | > | > base.Dispose( disposing );
| > | > | > }
| > | > | >
| > | > | > #region Component Designer generated code
| > | > | > /// <summary>
| > | > | > /// Required method for Designer support - do not modify
| > | > | > /// the contents of this method with the code editor.
| > | > | > /// </summary>
| > | > | > private void InitializeComponent()
| > | > | > {
| > | > | > //
| > | > | > // MyUserControl
| > | > | > //
| > | > | > this.BackColor = System.Drawing.SystemColors.Desktop;
| > | > | > this.Name = "MyUserControl";
| > | > | > this.Size = new System.Drawing.Size(368, 424);
| > | > | >
| > | > | > }
| > | > | > #endregion
| > | > | >
| > | > | > private class NativeMethods
| > | > | > {
| > | > | > [DllImport("user32.dll")]
| > | > | > private extern static int SendMessage(IntPtr hwnd, uint nMsg,
| > | > | > int wParam, int lParam);
| > | > | > private const int WM_SETREDRAW = 0x000B;
| > | > | > public static void BeginUpdate(IntPtr hwnd)
| > | > | > {
| > | > | > SendMessage(hwnd,WM_SETREDRAW,0,0);
| > | > | > }
| > | > | > public static void EndUpdate(IntPtr hwnd)
| > | > | > {
| > | > | > SendMessage(hwnd,WM_SETREDRAW,-1,0);
| > | > | > }
| > | > | >
| > | > | > }
| > | > | >
| > | > | >
| > | > | > public void BeginUpdate()
| > | > | > {
| > | > | > NativeMethods.BeginUpdate(Handle);
| > | > | > }
| > | > | > public void EndUpdate()
| > | > | > {
| > | > | > NativeMethods.EndUpdate(Handle);
| > | > | > }
| > | > | >
| > | > | >
| > | > | > protected override void OnMouseMove(MouseEventArgs e)
| > | > | > {
| > | > | > base.OnMouseMove (e);
| > | > | > System.Diagnostics.Debug.WriteLine("MouseMove received");
| > | > | > }
| > | > | > public void DoUpdate()
| > | > | > {
| > | > | > Graphics g = CreateGraphics();
| > | > | > g.FillRectangle(Brushes.Indigo,this.Bounds);
| > | > | > g.Dispose();
| > | > | > }
| > | > | > }
| > | > | > }
| > | > | > </code>
| > | > | > <code file="Form1.cs">
| > | > | > using System;
| > | > | > using System.Drawing;
| > | > | > using System.Collections;
| > | > | > using System.ComponentModel;
| > | > | > using System.Windows.Forms;
| > | > | > using System.Data;
| > | > | >
| > | > | > namespace WinForm_BeginEndUpdate_MouseMove
| > | > | > {
| > | > | > /// <summary>
| > | > | > /// Summary description for Form1.
| > | > | > /// </summary>
| > | > | > public class Form1 : System.Windows.Forms.Form
| > | > | > {
| > | > | > private WinForm_BeginEndUpdate_MouseMove.MyUserControl
| > myUserControl1;
| > | > | > private System.Timers.Timer timer1;
| > | > | > /// <summary>
| > | > | > /// Required designer variable.
| > | > | > /// </summary>
| > | > | > private System.ComponentModel.Container components = null;
| > | > | >
| > | > | > public Form1()
| > | > | > {
| > | > | > //
| > | > | > // Required for Windows Form Designer support
| > | > | > //
| > | > | > InitializeComponent();
| > | > | >
| > | > | > //
| > | > | > // TODO: Add any constructor code after InitializeComponent call
| > | > | > //
| > | > | > }
| > | > | >
| > | > | > /// <summary>
| > | > | > /// Clean up any resources being used.
| > | > | > /// </summary>
| > | > | > protected override void Dispose( bool disposing )
| > | > | > {
| > | > | > if( disposing )
| > | > | > {
| > | > | > if (components != null)
| > | > | > {
| > | > | > components.Dispose();
| > | > | > }
| > | > | > }
| > | > | > base.Dispose( disposing );
| > | > | > }
| > | > | >
| > | > | > #region Windows Form Designer generated code
| > | > | > /// <summary>
| > | > | > /// Required method for Designer support - do not modify
| > | > | > /// the contents of this method with the code editor.
| > | > | > /// </summary>
| > | > | > private void InitializeComponent()
| > | > | > {
| > | > | > this.myUserControl1 = new
| > | > | > WinForm_BeginEndUpdate_MouseMove.MyUserControl();
| > | > | > this.timer1 = new System.Timers.Timer();
| > | > | >
| > ((System.ComponentModel.ISupportInitialize)(this.timer1)).BeginInit();
| > | > | > this.SuspendLayout();
| > | > | > //
| > | > | > // myUserControl1
| > | > | > //
| > | > | > this.myUserControl1.BackColor =
| System.Drawing.SystemColors.Desktop;
| > | > | > this.myUserControl1.Location = new System.Drawing.Point(72, 64);
| > | > | > this.myUserControl1.Name = "myUserControl1";
| > | > | > this.myUserControl1.Size = new System.Drawing.Size(256, 240);
| > | > | > this.myUserControl1.TabIndex = 2;
| > | > | > //
| > | > | > // timer1
| > | > | > //
| > | > | > this.timer1.Enabled = true;
| > | > | > this.timer1.Interval = 500;
| > | > | > this.timer1.SynchronizingObject = this;
| > | > | > this.timer1.Elapsed += new
| > | > | > System.Timers.ElapsedEventHandler(this.timer1_Elapsed);
| > | > | > //
| > | > | > // Form1
| > | > | > //
| > | > | > this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
| > | > | > this.ClientSize = new System.Drawing.Size(408, 421);
| > | > | > this.Controls.Add(this.myUserControl1);
| > | > | > this.Name = "Form1";
| > | > | > this.Text = "Form1";
| > | > | > this.MouseMove += new
| > | > | > System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);
| > | > | >
| ((System.ComponentModel.ISupportInitialize)(this.timer1)).EndInit();
| > | > | > this.ResumeLayout(false);
| > | > | >
| > | > | > }
| > | > | > #endregion
| > | > | >
| > | > | > /// <summary>
| > | > | > /// The main entry point for the application.
| > | > | > /// </summary>
| > | > | > [STAThread]
| > | > | > static void Main()
| > | > | > {
| > | > | > Application.Run(new Form1());
| > | > | > }
| > | > | >
| > | > | > private void Form1_MouseMove(object sender,
| > | > | > System.Windows.Forms.MouseEventArgs e)
| > | > | > {
| > | > | > System.Diagnostics.Debug.WriteLine("MainForm MouseMove
received");
| > | > | > }
| > | > | >
| > | > | > private void timer1_Elapsed(object sender,
| > | > System.Timers.ElapsedEventArgs
| > | > | > e)
| > | > | > {
| > | > | > myUserControl1.BeginUpdate();
| > | > | > System.Diagnostics.Debug.WriteLine("BeginUpdate");
| > | > | > myUserControl1.DoUpdate();
| > | > | > myUserControl1.EndUpdate();
| > | > | > System.Diagnostics.Debug.WriteLine("EndUpdate");
| > | > | >
| > | > | > }
| > | > | > }
| > | > | > }
| > | > | >
| > | > | > </code>
| > | > | >
| > | > | >
| > | > | >
| > | > | >
| > | > |
| > | > |
| > | > |
| > | >
| > |
| > |
| > |
| >
|
|
|
 
Thanks for the update. The information you provided is useful. It would be
great if you could elaborate some more on what is contained in the "custom
redraw code which avoids the mousemove". What exactly does this code do?
Essentiaally, I would want to replicate its behavior.

Thanks,
Abhishek

Ying-Shen Yu said:
Hi abhishek,
Sorry for keeping you waiting, I forwarded your question to our developer
team and got the follow reply:
<cite>
Whether WM_SETREDRAW causes a mousemove is up to the window. Some windows
let USER32 do default redraw handling, which will generate a mousemove on
enable. Listbox has custom redraw code which avoids the mousemove. You
simply shouldn't care one way or the other.
</cite>
So it up to the internal implementation, for why the default redraw will
cause the WM_MOUSEMOVE, here is an blog which may answer your question:
http://blogs.gotdotnet.com/raymondc/PermaLink.aspx/d8afd9b1-06ec-4046-939d-d
dc4d7662ec2

Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!

--------------------
| From: "abhishek ghuwalewala" <[email protected]>
| References: <uV#[email protected]>
<[email protected]>
<#[email protected]>
<Km#[email protected]>
<O8N#[email protected]>
<[email protected]>
| Subject: Re: BeginUpdate/EndUpdate causing mouse move
| Date: Wed, 29 Oct 2003 15:20:12 -0600
| Lines: 424
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| NNTP-Posting-Host: client-78-96.natinst.com 130.164.78.96
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:55468
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| I am still looking for an answer as to why the reported behavior does not
| reproduce on a ListBox control. What is it doing differently?
|
| Abhishek
|
| | > Hi abhishek,
| > In fact, this issue also occurred in native win32 application, it by
| design.
| > The system sometimes delivers a WM_MOUSEMOVE message even if the mouse
| > hasn't moved. Programs which are sensitive to physical mouse movement
| (such
| > as screen savers) should compare the coordinates in the WM_MOUSEMOVE
| > message with the coordinates from the previous mouse message and ignore
| the
| > message if they are the same.
| >
| > The Document didn't make this clear, we already noticed this problem, it
| > mightbe fixed in the next release of the document.Thanks for your
| reporting.
| > If you need handle the real OnMouseMove event you need first check if
the
| > point of the cursor is same as the previous one. the code should be
| > executed only when the values are different.
| > Thanks!
| >
| > Best regards,
| >
| > Ying-Shen Yu [MSFT]
| > Microsoft Online Partner Support
| > Get Secure! - www.microsoft.com/security
| >
| > This posting is provided "AS IS" with no warranties and confers no
rights.
| > You should not reply this mail directly, "Online" should be removed
before
| > sending, Thanks!
| >
| > --------------------
| > | From: "abhishek ghuwalewala" <[email protected]>
| > | References: <uV#[email protected]>
| > <[email protected]>
| > <#[email protected]>
| > <Km#[email protected]>
| > | Subject: Re: BeginUpdate/EndUpdate causing mouse move
| > | Date: Mon, 27 Oct 2003 10:29:09 -0600
| > | Lines: 348
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| > | Message-ID: <O8N#[email protected]>
| > | Newsgroups: microsoft.public.dotnet.framework.windowsforms
| > | NNTP-Posting-Host: client-79-20.natinst.com 130.164.79.20
| > | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| > | Xref: cpmsftngxa06.phx.gbl
| > microsoft.public.dotnet.framework.windowsforms:55305
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
| > |
| > | As I had mentioned before, this behavior does not reproduce for the
| > ListBox
| > | control. Would you happen to know what the ListBox control is doing
that
| > | prevents this from happening?
| > |
| > | Abhishek
| > |
| > | | > | > Hi abhishek,
| > | > Thanks for your sample, I reproed your problem now.
| > | > For now, I haven't found a way to prevent MouseMove method to be
| called.
| > | > However, since BeginUpdate/Endupate is called by yourself, could you
| > add a
| > | > boolean flag before actually executing your codes in the MouseMove?
| > | > such as
| > | > InUpdating = false;
| > | > void BeginUpdate()
| > | > {
| > | > InUpdating = true;
| > | > SendMessage ....
| > | > }
| > | > void EndUpdate()
| > | > {
| > | > SendMessage() ...
| > | > InUpdating = false;
| > | > }
| > | > void MouseMove( ....)
| > | > {
| > | > if(!IsUpdating)
| > | > {
| > | > DoMouseMove();
| > | > }
| > | > }
| > | >
| > | > Does this work around solve your problem?
| > | > Please be free to post on the group, if you still have problem on
this
| > | > issue.
| > | > Thanks!
| > | >
| > | > Best regards,
| > | >
| > | > Ying-Shen Yu [MSFT]
| > | > Microsoft Online Partner Support
| > | > Get Secure! - www.microsoft.com/security
| > | >
| > | > This posting is provided "AS IS" with no warranties and confers no
| > rights.
| > | > You should not reply this mail directly, "Online" should be removed
| > before
| > | > sending, Thanks!
| > | >
| > | > --------------------
| > | > | From: "abhishek ghuwalewala" <[email protected]>
| > | > | References: <uV#[email protected]>
| > | > <[email protected]>
| > | > | Subject: Re: BeginUpdate/EndUpdate causing mouse move
| > | > | Date: Fri, 24 Oct 2003 11:05:22 -0500
| > | > | Lines: 638
| > | > | X-Priority: 3
| > | > | X-MSMail-Priority: Normal
| > | > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| > | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| > | > | Message-ID: <#[email protected]>
| > | > | Newsgroups: microsoft.public.dotnet.framework.windowsforms
| > | > | NNTP-Posting-Host: client-64-158.natinst.com 130.164.64.158
| > | > | Path:
| > | >
| > |
| >
|
cpmsftngxa06.phx.gbl!cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.
| > | > phx.gbl
| > | > | Xref: cpmsftngxa06.phx.gbl
| > | > microsoft.public.dotnet.framework.windowsforms:55191
| > | > | X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
| > | > |
| > | > | Ying-Shen,
| > | > |
| > | > | Thanks for your prompt reply. I am attaching a small sample
project
| > that
| > | > | reproduces the problem. The instructions for reproducing the
problem
| > are
| > | > | described in the application.
| > | > |
| > | > | Thanks,
| > | > | Abhishek
| > | > |
| > | > | | > | > | > Hi abhishek.
| > | > | > Thanks for your post!
| > | > | > You mean your mousemove event of your control or your form is
| fired
| > | when
| > | > | > you invoke the P/Invoke SendMessage
| > | > | > method?
| > | > | > I made a small program and tried to repro your problem, however
I
| > | didn't
| > | > | > get any mouse move event on the user control or on the Form when
| > | > invoking
| > | > | > these two methods.
| > | > | > I pasted my test code after the signature, you may try it on
your
| > | > system.
| > | > | > Probably it will be helpful if you could give me a
| > | > | > small sample project to repro this problem.
| > | > | >
| > | > | > Thanks for using MSDN Newsgroup!!
| > | > | >
| > | > | > Best regards,
| > | > | >
| > | > | > Ying-Shen Yu [MSFT]
| > | > | > Microsoft Online Partner Support
| > | > | > Get Secure! - www.microsoft.com/security
| > | > | >
| > | > | > This posting is provided "AS IS" with no warranties and confers
no
| > | > rights.
| > | > | > You should not reply this mail directly, "Online" should be
| removed
| > | > before
| > | > | > sending, Thanks!
| > | > | >
| > | > | > <code file="MyUserControl.cs">
| > | > | > using System;
| > | > | > using System.Collections;
| > | > | > using System.ComponentModel;
| > | > | > using System.Drawing;
| > | > | > using System.Data;
| > | > | > using System.Windows.Forms;
| > | > | > using System.Runtime.InteropServices;
| > | > | >
| > | > | > namespace WinForm_BeginEndUpdate_MouseMove
| > | > | > {
| > | > | > /// <summary>
| > | > | > /// Summary description for MyUserControl.
| > | > | > /// </summary>
| > | > | > public class MyUserControl : System.Windows.Forms.UserControl
| > | > | > {
| > | > | > /// <summary>
| > | > | > /// Required designer variable.
| > | > | > /// </summary>
| > | > | > private System.ComponentModel.Container components = null;
| > | > | >
| > | > | > public MyUserControl()
| > | > | > {
| > | > | > // This call is required by the Windows.Forms Form Designer.
| > | > | > InitializeComponent();
| > | > | >
| > | > | > // TODO: Add any initialization after the InitializeComponent
call
| > | > | >
| > | > | > }
| > | > | >
| > | > | > /// <summary>
| > | > | > /// Clean up any resources being used.
| > | > | > /// </summary>
| > | > | > protected override void Dispose( bool disposing )
| > | > | > {
| > | > | > if( disposing )
| > | > | > {
| > | > | > if(components != null)
| > | > | > {
| > | > | > components.Dispose();
| > | > | > }
| > | > | > }
| > | > | > base.Dispose( disposing );
| > | > | > }
| > | > | >
| > | > | > #region Component Designer generated code
| > | > | > /// <summary>
| > | > | > /// Required method for Designer support - do not modify
| > | > | > /// the contents of this method with the code editor.
| > | > | > /// </summary>
| > | > | > private void InitializeComponent()
| > | > | > {
| > | > | > //
| > | > | > // MyUserControl
| > | > | > //
| > | > | > this.BackColor = System.Drawing.SystemColors.Desktop;
| > | > | > this.Name = "MyUserControl";
| > | > | > this.Size = new System.Drawing.Size(368, 424);
| > | > | >
| > | > | > }
| > | > | > #endregion
| > | > | >
| > | > | > private class NativeMethods
| > | > | > {
| > | > | > [DllImport("user32.dll")]
| > | > | > private extern static int SendMessage(IntPtr hwnd, uint nMsg,
| > | > | > int wParam, int lParam);
| > | > | > private const int WM_SETREDRAW = 0x000B;
| > | > | > public static void BeginUpdate(IntPtr hwnd)
| > | > | > {
| > | > | > SendMessage(hwnd,WM_SETREDRAW,0,0);
| > | > | > }
| > | > | > public static void EndUpdate(IntPtr hwnd)
| > | > | > {
| > | > | > SendMessage(hwnd,WM_SETREDRAW,-1,0);
| > | > | > }
| > | > | >
| > | > | > }
| > | > | >
| > | > | >
| > | > | > public void BeginUpdate()
| > | > | > {
| > | > | > NativeMethods.BeginUpdate(Handle);
| > | > | > }
| > | > | > public void EndUpdate()
| > | > | > {
| > | > | > NativeMethods.EndUpdate(Handle);
| > | > | > }
| > | > | >
| > | > | >
| > | > | > protected override void OnMouseMove(MouseEventArgs e)
| > | > | > {
| > | > | > base.OnMouseMove (e);
| > | > | > System.Diagnostics.Debug.WriteLine("MouseMove received");
| > | > | > }
| > | > | > public void DoUpdate()
| > | > | > {
| > | > | > Graphics g = CreateGraphics();
| > | > | > g.FillRectangle(Brushes.Indigo,this.Bounds);
| > | > | > g.Dispose();
| > | > | > }
| > | > | > }
| > | > | > }
| > | > | > </code>
| > | > | > <code file="Form1.cs">
| > | > | > using System;
| > | > | > using System.Drawing;
| > | > | > using System.Collections;
| > | > | > using System.ComponentModel;
| > | > | > using System.Windows.Forms;
| > | > | > using System.Data;
| > | > | >
| > | > | > namespace WinForm_BeginEndUpdate_MouseMove
| > | > | > {
| > | > | > /// <summary>
| > | > | > /// Summary description for Form1.
| > | > | > /// </summary>
| > | > | > public class Form1 : System.Windows.Forms.Form
| > | > | > {
| > | > | > private WinForm_BeginEndUpdate_MouseMove.MyUserControl
| > myUserControl1;
| > | > | > private System.Timers.Timer timer1;
| > | > | > /// <summary>
| > | > | > /// Required designer variable.
| > | > | > /// </summary>
| > | > | > private System.ComponentModel.Container components = null;
| > | > | >
| > | > | > public Form1()
| > | > | > {
| > | > | > //
| > | > | > // Required for Windows Form Designer support
| > | > | > //
| > | > | > InitializeComponent();
| > | > | >
| > | > | > //
| > | > | > // TODO: Add any constructor code after InitializeComponent call
| > | > | > //
| > | > | > }
| > | > | >
| > | > | > /// <summary>
| > | > | > /// Clean up any resources being used.
| > | > | > /// </summary>
| > | > | > protected override void Dispose( bool disposing )
| > | > | > {
| > | > | > if( disposing )
| > | > | > {
| > | > | > if (components != null)
| > | > | > {
| > | > | > components.Dispose();
| > | > | > }
| > | > | > }
| > | > | > base.Dispose( disposing );
| > | > | > }
| > | > | >
| > | > | > #region Windows Form Designer generated code
| > | > | > /// <summary>
| > | > | > /// Required method for Designer support - do not modify
| > | > | > /// the contents of this method with the code editor.
| > | > | > /// </summary>
| > | > | > private void InitializeComponent()
| > | > | > {
| > | > | > this.myUserControl1 = new
| > | > | > WinForm_BeginEndUpdate_MouseMove.MyUserControl();
| > | > | > this.timer1 = new System.Timers.Timer();
| > | > | >
| > ((System.ComponentModel.ISupportInitialize)(this.timer1)).BeginInit();
| > | > | > this.SuspendLayout();
| > | > | > //
| > | > | > // myUserControl1
| > | > | > //
| > | > | > this.myUserControl1.BackColor =
| System.Drawing.SystemColors.Desktop;
| > | > | > this.myUserControl1.Location = new System.Drawing.Point(72, 64);
| > | > | > this.myUserControl1.Name = "myUserControl1";
| > | > | > this.myUserControl1.Size = new System.Drawing.Size(256, 240);
| > | > | > this.myUserControl1.TabIndex = 2;
| > | > | > //
| > | > | > // timer1
| > | > | > //
| > | > | > this.timer1.Enabled = true;
| > | > | > this.timer1.Interval = 500;
| > | > | > this.timer1.SynchronizingObject = this;
| > | > | > this.timer1.Elapsed += new
| > | > | > System.Timers.ElapsedEventHandler(this.timer1_Elapsed);
| > | > | > //
| > | > | > // Form1
| > | > | > //
| > | > | > this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
| > | > | > this.ClientSize = new System.Drawing.Size(408, 421);
| > | > | > this.Controls.Add(this.myUserControl1);
| > | > | > this.Name = "Form1";
| > | > | > this.Text = "Form1";
| > | > | > this.MouseMove += new
| > | > | > System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);
| > | > | >
| ((System.ComponentModel.ISupportInitialize)(this.timer1)).EndInit();
| > | > | > this.ResumeLayout(false);
| > | > | >
| > | > | > }
| > | > | > #endregion
| > | > | >
| > | > | > /// <summary>
| > | > | > /// The main entry point for the application.
| > | > | > /// </summary>
| > | > | > [STAThread]
| > | > | > static void Main()
| > | > | > {
| > | > | > Application.Run(new Form1());
| > | > | > }
| > | > | >
| > | > | > private void Form1_MouseMove(object sender,
| > | > | > System.Windows.Forms.MouseEventArgs e)
| > | > | > {
| > | > | > System.Diagnostics.Debug.WriteLine("MainForm MouseMove
received");
| > | > | > }
| > | > | >
| > | > | > private void timer1_Elapsed(object sender,
| > | > System.Timers.ElapsedEventArgs
| > | > | > e)
| > | > | > {
| > | > | > myUserControl1.BeginUpdate();
| > | > | > System.Diagnostics.Debug.WriteLine("BeginUpdate");
| > | > | > myUserControl1.DoUpdate();
| > | > | > myUserControl1.EndUpdate();
| > | > | > System.Diagnostics.Debug.WriteLine("EndUpdate");
| > | > | >
| > | > | > }
| > | > | > }
| > | > | > }
| > | > | >
| > | > | > </code>
| > | > | >
| > | > | >
| > | > | >
| > | > | >
| > | > |
| > | > |
| > | > |
| > | >
| > |
| > |
| > |
| >
|
|
|
 
hi Abhishek,
Thanks for you reply,
I'm sorry there is no public information on the custom redraw code which
avoids the mousemove. Have you tried handling the redraw message completly
by yourself and don't call the defwndproc on these control? If this doesn't
take effect, you have to follow the advice of our develop team.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!
 
Back
Top