重拾VB6(24):Using Graphical Controls

本文介绍了使用Visual Basic进行图形设计的基本方法,包括利用图形控件、图片显示方式、持久化绘图、裁剪区域设定等。此外,还讲解了如何通过属性设置实现图形层叠效果,动态调整控件位置及大小,以及创建简单的动画效果。

来自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

内容概要:本文详细分析了西门子S7-200 PLC使用的PPI(Point-to-Point)通信协议,通过串口监控软件捕获并解析PC与PLC之间的通信数据包,揭示了PPI协议的核心报文格式和通信机制。文章介绍了PPI协议的主从通信模式,阐述了读写操作的具体指令结构、功能码、地址编码规则、校验方式以及完整的通信流程,包括寻呼、确认、读写命令和响应等环节,并提供了多个实际应用示例,如读取密码、版本号、变量数据及控制PLC运行状态(RUN/STOP)等。此外,文档还深入解析了数据帧中各字段的含义,特别是存储器类型、偏移量计算(地址×8)、数据长度与校验码生成方法,帮助开发者掌握底层通信细节。; 适合人群:具备基本工控知识和串口通信基础,熟悉PLC原理及VB、VC等上位机开发语言的研发人员、自动化工程师和技术爱好者;尤其适用于希望绕过官方编程工具、自主实现与S7-200 PLC通信的开发人员。; 使用场景及目标:① 实现上位机(如PC)通过串口直接与西门子S7-200 PLC通信,读写I/Q/M/V/S等存储区数据;② 开发自定义HMI、监控系统或数据采集系统,无需依赖STEP7-Micro/WIN软件;③ 破解或绕过PLC密码保护机制,进行设备维护或逆向分析;④ 深入理解工业通信协议的设计逻辑,提升工控安全防护能力。; 阅读建议:建议结合串口调试工具(如串口助手)和实际PLC硬件进行实践验证,逐步测试文中提供的十六进制指令,观察返回数据以加深理解;注意通信参数设置(9600, E, 8, 1)和校验码计算准确性;对于关键操作(如写入、RUN/STOP控制),应在测试环境中先行验证,避免对生产系统造成影响。
内容概要:本文档聚焦于“复现-基于IEEE9节点低惯量电力系统混合拓扑的构网型变流器控制”,深入研究下垂控制、虚拟同步机控制(VSM)、匹配控制与可调度虚拟振荡器控制(dVOC)在电磁暂态过程中的建模与仿真。文档提供基于Simulink的仿真模型和MATLAB代码,涵盖构网型变流器多种先进控制策略的实现细节,重点分析其在低惯量电网环境下的动态响应特性、稳定性表现及不同控制方法之间的对比。作为电力系统自动化与新能源并网领域的高阶科研资料,该资源不仅服务于具体仿真任务,还配套多项相关课题(如微电网优化、储能调度、电动汽车V2G等)的技术支持,构建了完整的学术复现与工程验证体系。; 适合人群:面向具备电力系统、自动控制或新能源并网等相关背景的硕士、博士研究生及科研人员,特别适用于需开展高水平学术论文复现、SCI/EI期刊投稿或复杂电力系统仿真实验的工程技术人员;要求读者熟悉MATLAB/Simulink环境并具备一定的控制系统理论基础。; 使用场景及目标:① 实现IEEE9节点系统中构网型变流器多种前沿控制策略(如下垂、VSM、dVOC)的电磁暂态仿真与性能对比;② 掌握构网型控制在弱电网条件下的建模方法、参数整定技巧与稳定性分析手段;③ 支撑高水平科研项目中的仿真验证环节,助力完成学术论文中的图表复现与结果分析。; 阅读建议:建议结合MATLAB与Simulink仿真平台,严格按照文档提供的模型结构与代码流程进行操作,重点关注控制器的设计逻辑、系统初始化设置、扰动注入方式及仿真结果的时域与频域分析;推荐同步查阅配套网盘中的完整代码与模型文件,确保复现过程的准确性与完整性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值