VB toolbar, dialog box (ii)

Source: Internet
Author: User
Tags integer

Display Options
The code determines how the dialog box will fit into memory and how to display it. The following table describes the various types of display tasks and the keywords used to perform those tasks.

The Show method loads the form and sets its Visible property to True. The parameters passed to the Show method identify the type of the dialog box. If the style argument is omitted or set to Vbmodeless or 0 (the default), the dialog box is a modeless type, and if the style argument is vbmodal or 1, the dialog box is the mode type.
Use the Unload statement or the Hide method when you choose OK or Cancel to exit the dialog box. For example:
Unload Frmabout
Or
Frmabout.hide
The Unload statement deletes the dialog box from memory, and the Hide method removes it from the window simply by setting the Visible property of the dialog box to False. When the form is unloaded, the form itself and its controls are unloaded from memory (including any controls that are running in the fashion). When a form is hidden, the form and its controls remain in memory. When you need to conserve memory space, it is a good idea to uninstall the form because the Unload form frees up memory. If you use a dialog box frequently, you can select a hidden form. A hidden form can still retain any data associated with it, including property values, printouts, and dynamically created controls. After the form is hidden, you can continue to refer to the properties and controls of the hidden form from your code.

Design of various display types
Microsoft Windows is device-independent-windows-based applications can run on many computers with different display resolutions and color concentrations. Also, applications written in Visual Basic will run on different types of monitors, which you need to take into account when designing your application.

Design Resolution-independent forms
By default, Microsoft Visual Basic does not change the size of forms and controls when you change the screen resolution. This means that a form designed on a screen with a resolution of 1024x768 will extend beyond the boundaries of the screen when it is running on a screen with 640x480 resolution. If you want to create forms and controls that have the same proportions regardless of the screen resolution you use, you must design the form at the lowest resolution, or add code that changes the form to your program. The easiest way to
avoid dimension problems is to design the form at the resolution of 640x480. If you prefer to work at a higher resolution, you still need to consider how the form will appear at a lower resolution. The way to do this is to preview the size and position of the form using the "Form Layout" window. You can also use "resolution guides" to see which parts of the screen are visible at low resolution. To switch to resolution guides, you can right-click in the Form Layout window and choose Resolution Guides menu item from the pop-up menu.
at run time, Visual Basic places the form according to its location at design time. If the design is run at a 1024x768 resolution and the form is placed in the lower-right corner of the screen, the form may not be visible when it runs at a lower resolution. To avoid this, you can choose the Startup Position menu item at design time from the pop-up menu in the Form Layout window to set the starting position of the form. Similarly, you can set the position of the form at run time with the code in the following form Load event:
Private Sub form_load ()
Me.move 0, 0
End Sub
Although setting the left and top properties of a form The same effect can be achieved for 0, but the Move method can only be done in one step.
Visual Basic uses device-independent units of measure, twips, which is the unit used to calculate dimensions and positions. The two properties of the screen object Twipsperpixelx and twipsperpixely can be used to determine the display dimensions at run time. By applying these properties, you can write code to adjust the size and position of the form and the controls.
Private Sub setcontrols ()
Dim X As Integer
Dim Y As Integer

X = Screen.twipsperpixelx
Y = screen.twipsperpixely
Select Case X, Y
Case 15, 15
' Resize the control and move the control again.
Txtname.height = 200
Txtname.width = 500
Txtname.move 200, 200
' Increase the code written for the other resolution.
...
End Sub
You also need to know the location of Visual Basic's own window at design time. If you put the Project window to the right of the screen at a high resolution, you will find that when you open the project at a low resolution, it is no longer accessible.

Design different concentrations of colors
When designing an application, you also need to consider the possible color display capabilities of running the application computer. Some computers can display 256 or more colors, while others can display only 16 colors. If you design a form with a 256-color palette, dithering (one way of imitating an invalid color) on a 16-color display causes some elements on the form to disappear.
To avoid this, it is a good idea to limit the colors used by your application to the 16 colors of Windows standard. These colors are represented by the color constants of Visual Basic (such as Vbblack, Vbblue, and Vbcyan, and so on). If you need more than 16 colors in your application, you should still stick to the standard color for text, buttons, and other interface elements.

The design of the heart thinking of the user
Unless you create a Visual Basic application solely for your own use, the value of authoring can only be evaluated by someone else. The user interface of an application has a great impact on the user-no matter how good the code is or how well optimized it is, it is difficult for users to accept it if they find the application difficult to use.
As a programmer, there is no doubt that computer technology is already very familiar. It's easy to forget that most users don't understand (and perhaps don't care) the technology behind the application. Think of an application as a tool to achieve the goal: the way to accomplish a task is easier to imagine than the help of a computer.
A well-designed user interface separates the user from the underlying technology, making it easy to complete the scheduled tasks. In the process of designing an application user interface, you need to think about users all the time. How can you discover the various functions of an application without guidance? How does the application respond when an error occurs? What will be offered to help or assist users? Does the design make the user happy with an artistic beauty? The answers to these questions and other user-centric design issues are covered in this section.

The foundation of Interface design
It doesn't have to be the artist who created the user interface--most of the user interface design principles are the same as those of the basic design taught in any basic art class. The basic design principles of composition, color, etc., as they apply to paper or oil paintings, can also be well applied on the screen of a single computer.
Although Visual Basic makes it easy to create a user interface by simply dragging and dropping controls onto a form, a little planning before you design can make a great difference in the usability of your application. You might want to start by drawing a form on paper, deciding which controls you need, the relative importance of different elements, and the relationships between controls.

Composition: The perception and feeling of the application
The composition or layout of a form affects not only its beauty but also the usability of the application. The composition includes such factors as the position of the control, the consistency of the elements, the movement, the use of the blank space and the simplicity of the design.

The location of the control
in most interface designs, not all elements are as important. Careful design is necessary to ensure that the more important elements are quickly displayed to the user. Important or frequently accessed elements should be placed in a prominent position, while less important elements should be relegated to less significant positions.
In most languages we are accustomed to reading from left to right, from top to bottom, from one page to the next. This is true for computer screens, where most users gaze first at the top left of the screen, so the most important elements should be placed on the upper left side of the screen. For example, if the information on a form is related to a customer, its name field should be displayed where it can be seen first. buttons, such as OK or next, should be placed in the lower-right part of the screen, and users typically do not access these buttons until they have finished working on the form.
It is also important to divide elements into groups with controls. Try to logically group information by function or relationship. Because their functions are related to each other, the button to locate the database should be visually divided into groups rather than scattered around the form. The same is true for information, where the Name field and address are usually in a group because they are closely related. In many cases, you can use frame controls to help strengthen the connection between controls.

Consistency of interface elements
Consistency is an advantage in user interface design. Consistent look and feel can create a harmony in the application, everything seems so coordinated. If there is a lack of consistency in the interface, it is likely to cause confusion and make the application look very confusing, disorganized, and less valuable, and may even raise doubts about the reliability of the application.
To maintain visual consistency, you should create design policies and type conventions before you start developing your application. Design elements such as the type of the control, the size of the control, the criteria for grouping, and the selection of fonts should be identified in advance. You can create design templates to help with your design.
There are a number of controls available in Visual Basic, which may cause someone to want to use all of the controls. To avoid this temptation, select a subset of controls that are well suited to a particular application. Although controls such as list boxes, combo boxes, grids, and trees can be used to represent lists of information, it is best to use one type as much as possible.
Also, use the controls as appropriately as possible, although the TextBox control can be set to read-only and display text, but the Label control is usually more appropriate for that purpose. Keep consistency when you set properties for a control, and if you use a white background for editable text in one place, don't use gray anywhere else unless you have good reasons.
Maintaining consistency among different forms in your application has a very important effect on their usability. If you use a gray background and three-dimensional effects on a form, and a white background on another form, the two forms are irrelevant. Select a type and keep the entire application consistent, even if it means redesigning certain features.

Dynamic: The form matches its function
Motion is a visible clue to the function of an object. While the term may not be familiar to you, the dynamic example is everywhere. The handle on the bike, hands on top of it, the action will be the hands of the hand clasp the matter appears. Press the button, rotate the knob and the switch that lights the light to be able to carry on the movement to say, can see its use at the sight of them.
The user interface also uses motion. For example, a three-dimensional effect on a command button makes them look like they were pressed down. If you design a command button with a flat border, you lose this dynamic, so you can't tell the user clearly that it is a command button. In some cases, a flat button might be appropriate, such as a game or multimedia application, as long as it is consistent throughout the application.
The text box also provides a dynamic that allows the user to expect a box with a border and a white background, and a box containing editable text. It is also possible to display a text box without a border (BorderStyle = 0), which makes it look like a label and does not significantly prompt the user that it is editable.

Use of Blank Space
Using white space in the user interface helps to highlight elements and improve usability. Whitespace does not have to be white-it is considered a blank area between form controls and around controls. Too many controls on a form can cause clutter in the interface, making it difficult to find a field or control. You need to insert blank space in your design to highlight the design elements.
The consistent spacing between controls and the alignment of vertical and horizontal elements can also make the design more usable. Just like the text in the magazine, the rows are arranged neatly, the line spacing is consistent, and the neat interface makes it easy to read.
Visual Basic provides several tools that make it easy to adjust the spacing, arrangement, and size of controls. Commands such as arrange, make by same size, horizontal spacing, vertical spacing, and center in form can be found on the Format menu.

Keep the interface Concise
Perhaps the most important principle of interface design is simplicity. For an application, if the interface looks difficult, it may be difficult for the program itself. A little deeper thinking helps create an interface that looks (and indeed is) very simple to use. From an aesthetic standpoint, a neat, straightforward design is often preferable.
In the interface design, a common error is to try to use the interface to imitate the real world object. For example, imagine an application that requires the creation of a complete insurance policy. The natural response is to design an interface that is completely modelled on the policy on the screen. There are a few problems with this: the form and size of the insurance policy are very different from the screen, and it is very good to copy such a table to limit it to the text box and check box, and there is no real benefit to the user.
It is best to design your own interface, which can also provide a printed copy of the original policy (with print preview). By creating a logical group of fields from the original policy, and using a tabbed interface or several linked forms, you can display all the information without requiring a scrolling screen. You can also use additional controls, such as a list box with a select preloaded in, which can reduce the typing effort.
You can also simplify many applications by taking out infrequently used functions and moving them into their own forms. Providing defaults can sometimes simplify the application, or if nine of the 10 users choose bold text, make the text bold as the default, rather than asking the user to pick it up every time (don't forget to provide an option to override the default value). Wizards also help simplify tasks that are complex or infrequently used.
The best test for simplicity is to observe the application in the application. If a representative user does not have the online Help to complete the task immediately, then the design needs to be reconsidered.

Working with colors and images
The use of color in the interface can increase the visual appeal, but the phenomenon of abuse has also occurred. Many monitors can display millions of of colors, which makes it easy for people to use them all. If you don't think about it carefully at the beginning of the design, the color will have many problems as well as other basic design principles.
The color of each person's love is very different, the user's taste will vary. Color can trigger a strong emotion, and if you are designing a program for a global audience, some colors may have significant cultural significance. Generally, it's best to keep the tradition in a softer, more neutral color.
Of course, the intended readers and the tone and mood they are trying to convey will also affect the choice of color. Bright red, green, and yellow apply to children's applications, but it is hard to bring financial accountability in banking applications.
A small amount of bright colors can effectively highlight or attract attention to important areas. As a experience, you should try to limit the kinds of colors that your application uses, and you should keep the tones consistent. If possible, it's best to stick to a standard 16-color palette, and when viewed on a 16-color monitor, the jitter will make some other colors appear. Another issue to consider when using colors is color blindness. Some people cannot tell the difference between different base colors, such as red and green. For people with this situation, the red text on the green background will not be visible.

Images and icons
The use of pictures and icons can also increase the visual interest of the application, but careful design is also essential. Without text, images can convey information visually, but often different people understand the image differently.
A toolbar with icons that represent a variety of features is a useful interface device, but it will backfire if you can't easily identify the features that the icon represents. When you design a toolbar icon, you should look at other applications to see what standards have been created. For example, many applications represent the new file icon with a sheet of paper on a corner with a roll edge. There may be a better metaphor for this, but switching to other representations can cause confusion for the user.
It is also important to consider the meaning of image culture. Many programs use an idyllic mailbox with a banner (Figure 6.21) to represent mail functionality. This was originally an icon of the United States; other countries/regions or cultures may not think of it as a mailbox.

When you design your own icons and images, you should try to make them simple. Complex pictures with multiple colors, either as toolbar icons for 16x16 pixels or when displayed on a high-resolution screen, do not fit well.

Select font
Fonts are also an important part of the user interface because they often convey important information to the user. You need to choose fonts that are easy to read at different resolutions and different types of monitors. It's best to stick with a simple sans serif or serif font. usually handwriting or other decorative fonts are printed more effectively than on the screen, and the smaller the font, the harder it is to read.
Unless you plan to configure fonts by application, you should insist on using standard Windows fonts, such as Arial, New times Roman, or System. If the user's system does not contain the specified font, the system uses an alternative font, and the result may be completely different from what is envisaged. If you are designing for an international audience, you need to investigate what fonts are available in the desired language. Also, when designing for other languages, you need to consider the extension of the text--some languages can take up more than 50% of the text strings.
Also, the consistency of the design is important when selecting fonts. In most cases, you should not use more than two fonts in your application. Too many fonts make the application look like a fine notice.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.