vel06.htm
来自「简单的说明如何使用VB,非常适合初学使用者,而且是用图表来解说的」· HTM 代码 · 共 2,468 行 · 第 1/4 页
HTM
2,468 行
<HTML><HEAD><TITLE>Visual Basic in 12 Easy Lessons vel06.htm </TITLE><LINK REL="ToC" HREF="index.htm"><LINK REL="Index" HREF="htindex.htm"><LINK REL="Next" HREF="velp03.htm"><LINK REL="Previous" HREF="vel05.htm"></HEAD><body bgcolor="#FFFFFF" vlink="#800080"><A NAME="I0"></A><H2>Visual Basic in 12 Easy Lessons vel06.htm</H2><P ALIGN=LEFT><A HREF="vel05.htm" TARGET="_self"><IMG SRC="purprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A><A HREF="index.htm" TARGET="_self"><IMG SRC="purtoc.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A><A HREF="velp03.htm" TARGET="_self"><IMG SRC="purnext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A><HR ALIGN=CENTER><P><UL><UL><UL><LI><A HREF="#E68E47" >What You'll Learn</A><LI><A HREF="#E68E48" >Properties of the Form</A><LI><A HREF="#E68E49" >Advanced Labels</A><LI><A HREF="#E68E50" >Scrolling Text Boxes</A><LI><A HREF="#E68E51" >Using Focus to Control Text Boxes</A><LI><A HREF="#E68E52" >Introducing Control Events</A><LI><A HREF="#E68E53" >Homework</A><UL><LI><A HREF="#E69E42" >General Knowledge</A><LI><A HREF="#E69E43" >Write Code That...</A><LI><A HREF="#E69E44" >Find the Bug</A><LI><A HREF="#E69E45" >Extra Credit</A></UL></UL></UL></UL><HR ALIGN=CENTER><A NAME="E66E8"></A><H1 ALIGN=CENTER><CENTER><FONT SIZE=6 COLOR="#FF0000"><B>Lesson 3, Unit 6</B></FONT></CENTER></H1><BR><A NAME="E67E11"></A><H2 ALIGN=CENTER><CENTER><FONT SIZE=6 COLOR="#FF0000"><B>Polishing Forms and Controls</B></FONT></CENTER></H2><BR><BR><A NAME="E68E47"></A><H3 ALIGN=CENTER><CENTER><FONT SIZE=5 COLOR="#FF0000"><B>What You'll Learn</B></FONT></CENTER></H3><BR><UL><LI> [lb] Properties of the form<BR><BR><LI> [lb] Advanced labels<BR><BR><LI> [lb] Scrolling text boxes<BR><BR><LI> [lb] Using focus to control text boxes<BR><BR><LI> [lb] Control events<BR><BR></UL><P>This unit continues the work begun in <A HREF="vel05.htm">Unit 5</A>. It explains more about the form and its property settings. In addition, this unit delves further into label and text box controls by showing you some of the more advanced uses of those controls. Not only will you learn more about the property settings, but you will also learn what events are possible for these controls.<BR><P>By the time you complete this unit, you will know virtually everything there is to know about forms, command buttons, labels, and text boxes. The project at the end of this lesson demonstrates these controls in action. It will give you a better sense of the ways in which you can implement them.<BR><BR><A NAME="E68E48"></A><H3 ALIGN=CENTER><CENTER><FONT SIZE=5 COLOR="#FF0000"><B>Properties of the Form</B></FONT></CENTER></H3><BR><P><FONT COLOR="#FF8000"><B><I>Concept: </I></B></FONT>The form is yet another Visual Basic object. As such, it has property settings that you can set and change while you design the application and during the program's execution. This section explains all the form's property settings in detail.<BR><P>Table 6.1 describes the property settings of the form that appear in the Properties window when you click the Form window and press F4. The form has more properties than the command button, label, and text box controls, whose properties you saw in the previous unit. As with all control property values, you never need to worry about all these properties at once. Most of the time, the default values are satisfactory for your applications.<BR><BR><P ALIGN=CENTER><CENTER><FONT COLOR="#000080"><B>Table 6.1. Properties of the form.</B></FONT></CENTER><BR><TABLE BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 WIDTH="100%" CELLPADDING=2 ><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080><I>Property</I></FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080><I>Description</I></FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>AutoRedraw</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>If True, Visual Basic automatically redraws graphic images that reside on the form when another window hides the image or when the user resizes the object. If False (the default), Visual Basic does not automatically redraw.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>BackColor</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>The background color of the form. You can enter a hexadecimal Windows color value or select from the color palette.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>BorderStyle</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Set to 0 for no border or border elements such as a control menu or minimize and maximize buttons, 1 for a fixed-size border, 2 (the default) for a sizable border, or 3 for a fixed-size border that includes a double-size edge.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Caption</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>The text that appears in the form's title bar. The default Caption is the Name of the form.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>ClipControls</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>If True (the default), the Paint event—a redrawing event triggered when graphic images are covered and then uncovered—redraws the graphics. If False, only newly-exposed areas of the graphics are repainted.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>ControlBox</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>If True (the default), the form contains a control button and control menu. If False, the form does not contain a control button and a control menu.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>DrawMode</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Contains 16 advanced settings that interact with drawing properties to produce special drawing effects. (See Lesson 11 for more information on graphics.)</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>DrawStyle</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Contains seven advanced settings that determine the appearance of lines that you draw.</FONT></TABLE><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE><I>Definition: </I>A <I>pixel</I> is the smallest screen width possible on your monitor.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><TABLE BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 WIDTH="100%" CELLPADDING=2 ><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>DrawWidth</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>The width, in pixels, of lines drawn on the form.</FONT></TABLE><TABLE BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 WIDTH="100%" CELLPADDING=2 ><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Enabled</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>If True (the default), the form can respond to events. Otherwise, Visual Basic halts event processing for the form.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>FillColor</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>The color value used to fill shapes drawn on the form.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>FillStyle</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Contains eight styles that determine the appearance of the interior patterns of shapes drawn on the form.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>FontBold</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Has no effect on the form's Caption property, but does affect text that you eventually display on the form if you use the Print command.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>FontItalic</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Has no effect on the form's Caption property, but does affect text that you eventually display on the form if you use the Print command.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>FontName</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Has no effect on the form's Caption property, but does affect text that you eventually display on the form if you use the Print command.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>FontSize</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Has no effect on the form's Caption property, but does affect text that you eventually display on the form if you use the Print command.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>FontStrikethru</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Has no effect on the form's Caption property, but does affect text that you eventually display on the form if you use the Print command.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>FontTransparent</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Has no effect on the form's Caption property, but does affect text that you eventually display on the form if you use the Print command.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>FontUnderline</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Has no effect on the form's Caption property, but does affect text that you eventually display on the form if you use the Print command.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>ForeColor</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>The color of foreground text that you display on the form if you use the Print command.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Height</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>The form’s height in twips.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>HelpContextID</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Provides the identifying number for the help text if you add advanced context-sensitive help to your application.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Icon</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>The picture icon that the user sees after minimizing the form.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>KeyPreview</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>If False (the default), the control with the focus receives these events: KeyDown, KeyUp, and KeyPress before the form does . If True, the form receives the events before the focused control.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Left</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>The number of twips from the left edge of the screen to the left edge of the form.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>LinkMode</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Set to 0 (the default) for no DDE allowance, 1 for automatic DDE allowance, 2 for a code-based DDE, or 3 for a code-based notify requirement.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>LinkTopic</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Specifies the source application and topic for a DDE application.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>MaxButton</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>If True (the default), the maximize button appears on the form at runtime. If False, the user cannot maximize the form window.</FONT>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?