加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

重拾VB6(25):Using Graphics Methods

发布时间:2020-12-16 23:28:51 所属栏目:大数据 来源:网络整理
导读:来自MSDN-2001-OCT: Visual Tools and Languages/Visual Studio 6.0 Documentation/Visual Basic Documentation/Using Visual Basic/Programmer’s Guide/Part 2: What Can You Do With Visual Basic/ Working with Text and Graphics / 1. basics of Graphi

来自MSDN-2001-OCT: Visual Tools and Languages/Visual Studio 6.0 Documentation/Visual Basic Documentation/Using Visual Basic/Programmer’s Guide/Part 2: What Can You Do With Visual Basic/Working with Text and Graphics/

1. basics of Graphics Methods

(1)

Method Description
Cls Clears all graphics and Print output.
PSet Sets the color of an individual pixel.
Point Returns the color value of a specified point.
Line Draws a line,rectangle,or filled-in box.
Circle Draws a circle,ellipse,or arc.
PaintPicture Paints graphics at arbitrary locations.

(2) The graphics methods work well in situations where using graphical controls require too much work.

(3) Graphics methods offer some visual effects that are not available in the graphical controls. For example,you can only create arcs or paint individual pixels using the graphics methods.

(4) Graphics you create with these graphics methods appear on the form in a layer of their own. This layer is below all other controls on a form,so using the graphics methods can work well when you want to create graphics that appear behind everything else in your application.

(5) 短处:在设计时不可见(而用图形控件则可在设计时就知道效果)。

(6) Every graphics method draws output on a form,in a picture box,or to the Printer object. To indicate where you want to draw,precede a graphics method with the name of a form or picture box control.

Each drawing area has its own coordinate system that determines what units apply to the coordinates. In addition,every drawing area has its own complete set of graphics properties.

2. Drawing points,lines,boxes,circles,ellipses,pictures

(1) You can precede each of these points with the Step keyword,specifying that the location of the point is relative to the last point drawn.

(2) 用Line可以画box: 直接画4条线或用B参数。还可用F参数及指定填充颜色和FillStyle。

(3) The Circle method draws a variety of circular and elliptical (oval) shapes. In addition,Circle draws arcs (segments of circles) and pie-shaped wedges.

(4) The PaintPicture method can be used in place of the BitBlt Windows API function to perform a wide variety of bit operations while moving a rectangular block of graphics from one position to any other position.

The pic argument must be a Picture object,as from the Picture property of a form or control.

3. DrawWidth,DrawMode

(1) The DrawWidth property specifies the width of the line for output from the graphics methods. The BorderWidth property specifies the outline thickness of line and shape controls.

(2) The DrawMode property determines what happens when you draw one pattern on top of another.

(3) (4)

Setting Description
4 Not Copy Pen. Draws the inverse of the line pattern,regardless of what is already there.
7 Xor Pen. Displays the difference between the line pattern and the existing display,as explained later in this section. Drawing an object twice with this mode restores the background precisely as it was.
11 No operation. In effect,this turns drawing off.
13 Copy Pen (default). Applies the line’s pattern,regardless of what is already there.

4. Creating Graphics When a Form Loads

When creating graphics that appear on a form when it loads,consider placing the graphics methods in the Form_Paint event. Form_Paint graphics will get repainted automatically in every paint event. If you place graphics in the Form_Load event,set the AutoRedraw property on the form to True. In this case,Form_Load should show the form,then draw the graphics. Remember,forms are not visible during the Form_Load event. Because Visual Basic does not process graphics methods on a form that is not visible,graphics methods in the Form_Load event are ignored unless AutoRedraw is set to True.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读