vel06.htm
来自「简单的说明如何使用VB,非常适合初学使用者,而且是用图表来解说的」· HTM 代码 · 共 2,468 行 · 第 1/4 页
HTM
2,468 行
</TABLE><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE><I>Definition: MDI</I> stands for <I>M</I>ultiple <I>D</I>ocument <I>I</I>nterface.</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>MDIChild</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>If True, the form is a MDI form—that is, a child form within a parent form. If False (the default), the form is not a MDI form.</FONT></TABLE><TABLE BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 WIDTH="100%" CELLPADDING=2 ><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>MinButton</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>If True (the default), the minimize button appears on the form at runtime. If False, the user cannot minimize the form window.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>MousePointer</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>The shape to which the mouse cursor changes if the user moves the mouse cursor over the form. The possible values range from 0 to 12 and represent the different shapes the mouse cursor can take on. (See Lesson 12.)</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Name</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>The name of the form. By default, Visual Basic generates the name Form1.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Picture</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>A picture file that displays on the form's background.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>ScaleHeight</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>The height of the form. ScaleMode determines the unit of measurement used.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>ScaleLeft</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>The distance from the left of the screen to the left edge of the form. ScaleMode determines the unit of measurement used.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>ScaleMode</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Enables you to determine how to measure coordinates on the form. You can choose from eight values. The default unit of measurement is twips, indicated by 1. The other Scale... properties measure use twips. Table 6.2 describes the possible units of measurement.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>ScaleTop</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>The distance from the top of the screen to the top edge of the form. ScaleMode determines the unit of measurement used.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>ScaleWidth</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>The width of the form. ScaleMode determines the unit of measurement used.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Tag</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Not used by Visual Basic. The programmer can use it for identifying comments applied to the form.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Top</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>The number of twips from the top edge of the screen to the top of the form.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Visible</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>True or False, indicating whether the user can see and, therefore, use the form.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Width</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>The width of the form in twips.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>WindowState</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Describes the startup state of the form when the user runs the program. If set to 0 (the default), the form first appears the same size as you designed it. If set to 1, the form first appears minimized. If set to 2, the form first appears maximized.</FONT></TABLE><P>ScaleMode enables you to determine how to measure coordinates on the form. You can choose from eight values. The default unit of measurement is twips. Table 6.2 describes the possible units of measurement.<BR><BR><P ALIGN=CENTER><CENTER><FONT COLOR="#000080"><B>Table 6.2. The </B><B>ScaleMode</B><B> property values.</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>Value</I></FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080><I>Description</I></FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>0</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Customized values</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>1</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Twips (the default)</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>2</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Points</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>3</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Pixels</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>4</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>A standard character that is 120 twips wide and 240 twips high</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>5</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Inches</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>6</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Millimeters</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>7</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Centimeters</FONT></TABLE><P><FONT COLOR="#FF8000"><B><I>Review: </I></B></FONT>You can customize your form in all kinds of ways. You can make it appear maximized or minimized. You can use colors and various styles. Most of the time, you want just a simple form with a caption that identifies the application; the only property values that you probably will have to modify are the Caption properties.<BR><BR><A NAME="E68E49"></A><H3 ALIGN=CENTER><CENTER><FONT SIZE=5 COLOR="#FF0000"><B>Advanced Labels</B></FONT></CENTER></H3><BR><P><FONT COLOR="#FF8000"><B><I>Concept: </I></B></FONT>In the previous unit, you saw all the property values that you can set with labels. Some of the property values produce interesting effects, which are described in this section.<BR><P>Suppose that you design a label that contains this long caption:<BR><BR><PRE><FONT COLOR="#000080">If a label's caption is too lengthy, you will need to adjust the label some way.</FONT></PRE><P>A label is rarely wide enough or tall enough to hold this caption. If you attempt to type text into a label's Caption property that is longer than what fits the size of the label, one of the following things can take place depending on how you have set up the label:<BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE><I>Definition: Truncate</I> means to chop off.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><OL><LI>The text might not fit inside the label, and Visual Basic truncates the text. Figure 6.1 shows the result.<BR>Set the AutoSize property to False if you want the label to remain the same size. The application assigns the text, and the label might not hold the entire caption.<BR><BR><P><B> <A HREF="06vel01.gif">Figure 6.1. The label is not large enough.</A></B><BR><LI>The label automatically expands downward to hold the entire caption in a multiline box. Figure 6.2 shows the result.<BR>Set both the AutoSize and WordWrap properties to True if you want the label to expand vertically to hold the entire caption that you assign at design time and during execution.<BR><BR><P><B> <A HREF="06vel02.gif">Figure 6.2. The label resizes vertically.</A></B><BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE><B>Tip: </B>Set WordWrap to True before you set the AutoSize property to True. If you set AutoSize first, the label expands horizontally before you have a chance to set the WordWrap property.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE><B>Warning: </B>Be careful about placing too many automatically-resizing labels. The labels might overwrite important information on the form if their captions are too long.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><LI>The label automatically expands across the screen to hold the entire caption in a long label control. Figure 6.3 shows the result.<BR>A long label like this is not necessarily incorrect. Depending on the length of the text that you assign to the label during the program's execution, there might be plenty of screen space to display long labels. To automatically expand the label horizontally, set the AutoSize property to True and leave WordWrap set to False. This is the default setting.<BR><BR></OL><P><B> <A HREF="06vel03.gif">Figure 6.3. The label is not tall enough.</A></B><BR><P><FONT COLOR="#FF8000"><B><I>Review: </I></B></FONT>Putting captions in labels seems easy until you think about the effects that can occur if the label is too large or too small to hold the text. By using the property combinations described here, you can add automatically-adjusting labels for whatever text the labels need to hold.<BR><BR><A NAME="E68E50"></A><H3 ALIGN=CENTER><CENTER><FONT SIZE=5 COLOR="#FF0000"><B>Scrolling Text Boxes</B></FONT></CENTER></H3><BR><P><FONT COLOR="#FF8000"><B><I>Concept: </I></B></FONT>By adding scroll bars to text boxes, you can give the user multiline text box capabilities. That way, the user can enter and edit long lengths of text without running out of room inside the text boxes.<BR><P>The MultiLine property for text box controls determines whether or not the text box can contain one or more lines of text. The multiline text might be an initial default value that you store in the text box's Text property when you place the form on the control. The multiline text also might consist of the user's input when the program runs.<BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE><B>Warning: </B>If you set the MultiLine property to True, you must also set the Scrollbars property to something other that 0-None. The user has to have a way to see the multiple lines of text inside the text box and the scroll bars give the user that ability.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><P>Figure 6.4 shows a text box that contains scroll bars and a True value for the MultiLine property. As the user enters text in a box like this, he can press Enter to move to the next line in the box. He does not, however, have to press Enter just because the text happens to scroll to the right; the horizontal scroll bars enables him to scroll left and right. When the user wants to end each line in the text box though, he presses Enter to move the carriage return character to the next line.<BR><P><B> <A HREF="06vel04.gif">Figure 6.4. The label's scroll bars give the user </B><B>more data-entry freedom.</A></B><BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE><B>Note: </B>You cannot enter an initial default value for a multiline text box. You can only initialize a text box with text that spans more than one line in the text box at runtime.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><P><FONT COLOR="#FF8000"><B><I>Review: </I></B></FONT>By setting the MultiLine and the ScrollBars properties, you can use multiline text boxes in your applications. Multiline text boxes respond to user input by accepting more than one line of text.<BR><BR><A NAME="E68E51"></A><H3 ALIGN=CENTER><CENTER><FONT SIZE=5 COLOR="#FF0000"><B>Using Focus to Control Text Boxes</B></FONT></CENTER></H3><BR><P><FONT COLOR="#FF8000"><B><I>Concept: </I></B></FONT>Although access keys are not available for text boxes, you can use a little-known trick to supply access keystroke shortcuts for text box data entry.<BR><P>As you begin to build Visual Basic applications, you will use text box controls to capture user input. Don't just throw a text box on a form and expect the user to know what to enter in it. In Figure 6.5, for example, the user does not know what data he should enter in the text box controls.<BR><P><B> <A HREF="06vel05.gif">Figure 6.5. Text boxes without labels confuse the </B><B>user.</A></B><BR><P>You must label the text box with a label control that tells the user what you want. The application shown in Figure 6.6 is identical to the application shown in Figure 6.5, but the labels in front of each text box tell the user what kind of data to enter.<BR>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?