重拾VB6(24):Using Graphical Controls

来自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. Using Graphical Controls

(1) The image, line, and shape controls are very useful for creating graphics at design time, and they require fewer system resources than other Visual Basic controls.

(2) Pictures can be displayed in three places in Visual Basic applications: On a form; In a picture box; In an image control.

(3) 设计时插图的话,图会被直接编到exe里;而运行时插图的话,自己要负责把图打包到exe里。

(4)

CategoryProperties
Display processingAutoRedraw, ClipControls
Current drawing locationCurrentX, CurrentY
Drawing techniquesDrawMode, DrawStyle, DrawWidth, BorderStyle, BorderWidth
Filling techniquesFillColor, FillStyle
ColorsBackColor, ForeColor, BorderColor, FillColor

2. Creating Persistent Graphics with AutoRedraw

(1) AutoRedraw is a Boolean property that, when set to True, causes graphics output to be saved in memory. You can use the AutoRedraw property to create persistent graphics.

(2) You can include code in the Paint event for a form or picture box that redraws all lines, circles, and points as appropriate. This approach usually works best when you have a limited amount of graphics that you can reconstruct easily.

(3) A Paint event procedure is called whenever part of a form or picture box needs to be redrawn — for example, when a window that covered the object moves away, or when resizing causes graphics to come back into view. If AutoRedraw is set to True, the object’s Paint procedure is never called unless your application calls it explicitly. The visible contents of the object are stored in the memory canvas, so the Paint event isn’t needed.

(4) You can change the setting of AutoRedraw at run time. If AutoRedraw is False, graphics and output from the Print method are written only to the screen, not to memory. If you clear the object with the Cls method, any output written when AutoRedraw was set to True does not get cleared. This output is retained in memory, and you must set AutoRedraw to True again and then use the Cls method to clear it.

3. Clipping Regions with ClipControls

(1) Clipping is the process of determining which parts of a form or container are painted when the form or container is displayed.

(2) When the ClipControls property is True, Windows defines a clipping region for the background of the form or container before a Paint event. This clipping region surrounds all nongraphical controls.

(3)

image

(4) Since calculating and managing a clipping region takes time, setting ClipControls to False may cause forms with many nonoverlapping controls (such as complex dialog boxes) to display faster.

4. Layering Graphics with AutoRedraw and ClipControls

(1) As you create graphics, keep in mind that graphical controls and labels, nongraphical controls, and graphics methods appear on different layers in a container.

(2) Combining settings for AutoRedraw and ClipControls and placing graphics methods inside or outside the Paint event affects layering and the performance of the application..

(3)

image

(4) Confining graphics methods to the Paint event causes those methods to paint in a predictable sequence.

5. Moving Controls Dynamically

(1) You can either directly change the properties that define the position of a control or use the Move method.

(2) Using the Left and Top Properties

(3) Moving a Line Control using X1, X2, Y1, Y2 properties

(4) Using the Move Method可以控制movement的速度(从而平滑度)和距离。

6. Resizing Controls Dynamically

Align, Height, Width, AutoSize, Stretch,

7. Creating Simple Animation

(1) Toggling Between Two Pictures

(2) Rotating Through Several Pictures

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值