重拾VB6(25):Using Graphics Methods
来自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)
(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) 用 (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)
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. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |