Cursor.Draw メソッドとは? わかりやすく解説

Cursor.Draw メソッド

カーソルを、指定した範囲内の、指定した表面描画ます。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Sub Draw ( _
    g As Graphics, _
    targetRect As Rectangle _
)
Dim instance As Cursor
Dim g As Graphics
Dim targetRect As Rectangle

instance.Draw(g, targetRect)
public void Draw (
    Graphics g,
    Rectangle targetRect
)
public:
void Draw (
    Graphics^ g, 
    Rectangle targetRect
)
public void Draw (
    Graphics g, 
    Rectangle targetRect
)

パラメータ

g

Cursor描画される Graphics 表面

targetRect

Cursor境界を表す Rectangle

解説解説
使用例使用例

フォーム上に、指定されカーソルをその通常サイズ描画し、次にストレッチ モードで 2 倍のサイズ描画するコード次に示します。この例では、Form存在しメソッド呼び出されたときに渡す Cursor オブジェクト存在する必要があります

Private Sub DrawCursorsOnForm(cursor As
 Cursor)
   ' If the form's cursor is not the Hand cursor and the 
   ' Current cursor is the Default, Draw the specified 
   ' cursor on the form in normal size and twice normal size. 
   If (Not Me.Cursor.Equals(Cursors.Hand))
 And _
     Cursor.Current.Equals(Cursors.Default) Then

      ' Draw the cursor stretched.
      Dim graphics As Graphics = Me.CreateGraphics()
      Dim rectangle As New
 Rectangle(New Point(10, 10), _
        New Size(cursor.Size.Width * 2, cursor.Size.Height * 2))
      cursor.DrawStretched(graphics, rectangle)
     
      ' Draw the cursor in normal size.
      rectangle.Location = New Point(rectangle.Width + _
        rectangle.Location.X, rectangle.Height + rectangle.Location.Y)
      rectangle.Size = cursor.Size
      cursor.Draw(graphics, rectangle)

      ' Dispose of the cursor.
      cursor.Dispose()
   End If
End Sub
private void DrawCursorsOnForm(Cursor cursor)
{
   // If the form's cursor is not the Hand cursor and the 
   // Current cursor is the Default, Draw the specified 
   // cursor on the form in normal size and twice normal size.
   if(this.Cursor != Cursors.Hand & 
     Cursor.Current == Cursors.Default)
   {
      // Draw the cursor stretched.
      Graphics graphics = this.CreateGraphics();
      Rectangle rectangle = new Rectangle(
        new Point(10,10), new Size(cursor.Size.Width
 * 2, 
        cursor.Size.Height * 2));
      cursor.DrawStretched(graphics, rectangle);
        
      // Draw the cursor in normal size.
      rectangle.Location = new Point(
      rectangle.Width + rectangle.Location.X, 
        rectangle.Height + rectangle.Location.Y);
      rectangle.Size = cursor.Size;
      cursor.Draw(graphics, rectangle);

      // Dispose of the cursor.
      cursor.Dispose();
   }
}
void DrawCursorsOnForm( System::Windows::Forms::Cursor^ cursor
 )
{
   
   // If the form's cursor is not the Hand cursor and the
   // Current cursor is the Default, Draw the specified
   // cursor on the form in normal size and twice normal size.
   if ( this->Cursor != Cursors::Hand &&
 System::Windows::Forms::Cursor::Current == Cursors::Default )
   {
      
      // Draw the cursor stretched.
      Graphics^ graphics = this->CreateGraphics();
      Rectangle rectangle = Rectangle(Point(10,10),System::Drawing::Size( cursor->Size.Width
 * 2, cursor->Size.Height * 2 ));
      cursor->DrawStretched( graphics, rectangle );
      
      // Draw the cursor in normal size.
      rectangle.Location = Point(rectangle.Width + rectangle.Location.X,rectangle.Height
 + rectangle.Location.Y);
      rectangle.Size = cursor->Size;
      cursor->Draw( graphics, rectangle );
      
      // Dispose of the cursor.
      delete cursor;
   }
}
private void DrawCursorsOnForm(Cursor cursor)
{
    // If the form's cursor is not the Hand cursor and the 
    // Current cursor is the Default, Draw the specified 
    // cursor on the form in normal size and twice normal size.
        if (!(this.get_Cursor().Equals(Cursors.get_Hand()))
 
            & get_Cursor().get_Current().Equals(Cursors.get_Default())) {
        // Draw the cursor stretched.
        Graphics graphics = this.CreateGraphics();
        Rectangle rectangle = new Rectangle(new
 Point(10, 10), 
            new Size(cursor.get_Size().get_Width() * 2, 
            cursor.get_Size().get_Height() * 2));
        cursor.DrawStretched(graphics, rectangle);
        // Draw the cursor in normal size.
        rectangle.set_Location(new Point(rectangle.get_Width()
 
            + rectangle.get_Location().get_X(), rectangle.get_Height() 
            + rectangle.get_Location().get_Y()));
        rectangle.set_Size(cursor.get_Size());
        cursor.Draw(graphics, rectangle);
        // Dispose of the cursor.
        cursor.Dispose();
    }
} //DrawCursorsOnForm
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Cursor.Draw メソッド」の関連用語

Cursor.Draw メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Cursor.Draw メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS