Note: Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation. To learn more about these changes please visit the announcement which can be found HERE.
How to create a cursor in c# Graph application

已答复 How to create a cursor in c# Graph application

  • 2011年12月14日 14:03
     
     

    Hai friends,

    I am creating a graph application c# . I want to create a cursor which is a line of length 100 . 

    Please help me ... Your  suggestions are welcomed

    Thanks and regards


    Leenu Thomas

    Leenu Thomas

全部回复

  • 2011年12月15日 7:57
    版主
     
     已答复 包含代码
    Hello Leenu,

    The following code example draws the specified cursor on the form in its normal size, and in stretched mode, twice its size. This example requires that you have a Form and a Cursor object to pass into the method when it is called.
    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();
       }
    }
    
    For more information please check the MSDN document: Cursor.Draw Method

    Regards,
    Helen Zhou [MSFT]
    MSDN Community Support | Feedback to us