zoukankan      html  css  js  c++  java
  • 绘制带滚动条的窗体

    public partial class FormScroll : Form
        {
            Pen pen = new Pen(Color.Black);
            Rectangle recE = new Rectangle(0, 0, 100, 200);
            Rectangle recR = new Rectangle(200, 200, 100, 200);
    
            public FormScroll()
            {
                InitializeComponent();
                this.AutoScaleMode = AutoScaleMode.Font;
    
                //正常显示,而且图形的右侧和下侧还会出现空白区域。因为图像显示区域为(400,400)
                //this.AutoScrollMinSize = new Size(500, 500);
    
                //设置为窗体的高度和宽度的时候,会出现滚动条,但是图形不能显示完全。
                //this.AutoScrollMinSize = new Size(this.Width, this.Height);
    
                //此时不会出滚动条,因为最小滚动区域小于窗体大小。
                this.AutoScrollMinSize = new Size(200, 200);
                this.AutoScroll = true;
            }
    
            protected override void OnPaint(PaintEventArgs e)
            {
                base.OnPaint(e);
                var dc = e.Graphics;
                Size s = new Size(AutoScrollPosition);
                System.Diagnostics.Debug.WriteLine(s.Width + ":" + s.Height);
                if (e.ClipRectangle.Top + s.Height < 300)
                {
                    var nrecE = new Rectangle(recE.Location + s, recE.Size);
                    dc.DrawEllipse(pen, nrecE);
                    var nrecR = new Rectangle(recR.Location + s, recR.Size);
                    dc.DrawRectangle(pen, nrecR);
                }
                //e.Graphics.TranslateTransform(this.AutoScrollOffset.X, this.AutoScrollOffset.Y);
                //e.Graphics.DrawEllipse(pen, recE);
                //e.Graphics.DrawRectangle(pen, recR);
            }
        }
    

      

  • 相关阅读:
    CSS基础
    AXIS2 开发笔记
    Tomcat和Weblogic下ajax或get中文乱码
    Jetty和Tomcat的选择:按场景而定
    分页
    windows linux 下,获取java项目绝对路径的方法
    oracle SQL
    ArrayUtils
    Xcode 调试技巧
    Core Data持久化数据存储(1)
  • 原文地址:https://www.cnblogs.com/363546828/p/3103323.html
Copyright © 2011-2022 走看看