大家帮帮忙,告诉我在VC++中怎么制作一个滚动画面?其代码?最好有注释?

解决方案 »

  1.   

    fanqing(火影忍者+28%(准备学习进程/线程)) 好久不见你了,呵呵。
    图片放到picture里
      

  2.   

    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;namespace ScrollShapes
    {
    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    { // member fields
    private Point rectangleTopLeft = new Point(0, 0);
    private Size rectangleSize = new Size(200,200);
    private Point ellipseTopLeft = new Point(50, 200);
    private Size ellipseSize = new Size(200, 150);
    private Pen bluePen = new Pen(Color.Blue, 3);
    private Pen redPen = new Pen(Color.Red, 2); /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.Container components = null;
    protected override void OnPaint( PaintEventArgs e )
    {
    Graphics dc = e.Graphics;
    Point ScrollOffset = this.AutoScrollPosition;
    dc.TranslateTransform(ScrollOffset.X, ScrollOffset.Y); if (e.ClipRectangle.Top+ScrollOffset.X < 350 || 
    e.ClipRectangle.Left+ScrollOffset.Y < 250)
    {
    Rectangle RectangleArea = 
    new Rectangle (rectangleTopLeft, rectangleSize);
    Rectangle EllipseArea = 
    new Rectangle (ellipseTopLeft, ellipseSize);
    dc.DrawRectangle(bluePen, RectangleArea);
    dc.DrawEllipse(redPen, EllipseArea);
    }
    base.OnPaint(e); }    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>
    public new void Dispose()
    {
    if (components != null) 
    {
    components.Dispose();
    }
    base.Dispose();
    } #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.SuspendLayout();
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.BackColor = System.Drawing.Color.White;
    this.ClientSize = new System.Drawing.Size(292, 269);
    this.Name = "Form1";
    this.Text = "ScrollShapes";
    this.ResumeLayout(false);
    }
    #endregion /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    }
    }
    }