Control.OnMouseMove メソッド
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Protected Overridable Sub OnMouseMove ( _ e As MouseEventArgs _ )
Dim e As MouseEventArgs Me.OnMouseMove(e)
protected virtual void OnMouseMove ( MouseEventArgs e )
protected: virtual void OnMouseMove ( MouseEventArgs^ e )
protected void OnMouseMove ( MouseEventArgs e )
protected function OnMouseMove ( e : MouseEventArgs )

イベントが発生すると、デリゲートを使用してイベント ハンドラが呼び出されます。詳細については、「イベントの発生」を参照してください。
OnMouseMove メソッドを使用すると、デリゲートを結び付けずに、派生クラスでイベントを処理することもできます。派生クラスでイベントを処理する場合は、この手法をお勧めします。
継承時の注意 派生クラスで OnMouseMove をオーバーライドする場合は、登録されているデリゲートがイベントを受け取ることができるように、基本クラスの OnMouseMove メソッドを呼び出してください。
派生クラスの OnMouseHover メソッドおよび OnMouseMove メソッドをオーバーライドする方法を次のコード例に示します。この例を実行するには、次のコードを新しいフォームに貼り付けて、同じファイルを形成するこのクラスを、そのフォームの後に貼り付けます。そして、FunButton 型のボタンをフォームに追加します。
Public Class FunButton Inherits Button Protected Overrides Sub OnMouseHover(ByVal e As System.EventArgs) ' Get the font size in Points, add one to the ' size, and reset the button's font to the larger ' size. Dim fontSize As Single = Font.SizeInPoints fontSize += 1 Dim buttonSize As System.Drawing.Size = Size Me.Font = New System.Drawing.Font _ (Font.FontFamily, fontSize, Font.Style) ' Increase the size width and height of the button ' by 5 points each. Size = New System.Drawing.Size _ (Size.Width + 5, Size.Height + 5) ' Call myBase.OnMouseHover to activate the delegate. MyBase.OnMouseHover(e) End Sub Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs) ' Make the curser the Hand curser when the mouse moves ' over the button. Cursor = Cursors.Hand ' Call MyBase.OnMouseHover to activate the delegate. MyBase.OnMouseHover(e) End Sub
public class FunButton: Button { protected override void OnMouseHover(System.EventArgs e) { // Get the font size in Points, add one to the // size, and reset the button's font to the larger // size. float fontSize = Font.SizeInPoints; fontSize += 1; System.Drawing.Size buttonSize = Size; this.Font = new System.Drawing.Font( Font.FontFamily, fontSize, Font.Style); // Increase the size width and height of the button // by 5 points each. Size = new System.Drawing.Size(Size.Width+5, Size.Height+5); // Call myBase.OnMouseHover to activate the delegate. base.OnMouseHover(e); } protected override void OnMouseMove(MouseEventArgs e) { // Make the curser the Hand curser when the mouse moves // over the button. Cursor = Cursors.Hand; // Call MyBase.OnMouseHover to activate the delegate. base.OnMouseHover(e); }
// To use this example create a new form and paste this class // forming the same file, after the form class in the same file. // Add a button of type FunButton to the form. public ref class FunButton: public Button { protected: virtual void OnMouseHover( System::EventArgs^ e ) override { // Get the font size in Points, add one to the // size, and reset the button's font to the larger // size. float fontSize = Font->SizeInPoints; fontSize += 1; System::Drawing::Size buttonSize = Size; this->Font = gcnew System::Drawing::Font( Font->FontFamily,fontSize,Font->Style ); // Increase the size width and height of the button // by 5 points each. Size = System::Drawing::Size( Size.Width + 5, Size.Height + 5 ); // Call myBase.OnMouseHover to activate the delegate. Button::OnMouseHover( e ); } virtual void OnMouseMove( MouseEventArgs^ e ) override { // Make the curser the Hand curser when the mouse moves // over the button. Cursor = Cursors::Hand; // Call MyBase.OnMouseHover to activate the delegate. Button::OnMouseHover( e ); }
public class FunButton extends Button { protected void OnMouseHover(System.EventArgs e) { // Get the font size in Points, add one to the // size, and reset the button's font to the larger // size. float fontSize = get_Font().get_SizeInPoints(); fontSize += 1; System.Drawing.Size buttonSize = get_Size(); this.set_Font(new System.Drawing.Font(get_Font().get_FontFamily(), fontSize, get_Font().get_Style())); // Increase the size width and height of the button // by 5 points each. set_Size(new System.Drawing.Size(get_Size().get_Width() + 5, get_Size().get_Height() + 5)); // Call myBase.OnMouseHover to activate the delegate. super.OnMouseHover(e); } //OnMouseHover protected void OnMouseMove(MouseEventArgs e) { // Make the curser the Hand curser when the mouse moves // over the button. set_Cursor(Cursors.get_Hand()); // Call MyBase.OnMouseHover to activate the delegate. super.OnMouseHover(e); } //OnMouseMove

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Control クラス
Control メンバ
System.Windows.Forms 名前空間
MouseMove
MouseEventArgs
その他の技術情報
Windows フォームの座標
Windows フォームにおけるマウス イベント
Weblioに収録されているすべての辞書からControl.OnMouseMove メソッドを検索する場合は、下記のリンクをクリックしてください。

- Control.OnMouseMove メソッドのページへのリンク