17. Windows API graphical user interface (1)

Source: Internet
Author: User

I. Basic Concepts

Windows user interface is divided into two parts:Character graphical interface and graphical user interface. The character graphic interface is relatively simple. Its main content includes how to read user input on the interface and how to output information to the interface terminal. How to control the font, background, and color of the interface.

there is only one type of man-machine interaction interface on the Character interface, called console (console) . You can enter commands and data to the Program in the console. The application displays running results or prompts on the console. For example, cmd.exe .

console , API All functions use console .

console there are two types of handles, standard Input (stand in) handle and standard output (stand out) Handle, which is used to read input from the interface and output to the interface respectively.

In most cases, the character interface application only has one console window. Both the standard input handle and standard output handle represent the console. However, they are indeed two handles, and the operations and permissions they can perform are different. If "standard input handle" is used as a parameterWriteconsoleFor console outputAPIFunctions produce errors.

1, Character Unit(Cell)

The minimum unit in the console is the character unit. A character unit can contain one character. Character units are the minimum unit for operations on the console. All attribute modification operations are also in the unit of characters.

In fact, similar Printf And other standards C Function in Windows The system uses the dynamic link library of the system. Crtdll. dll Export, Printf Function implementation is also located in Crtdll. dll Medium, analysis Printf And other functionsCodeYou can find that Windows On the platform, the actual Printf After formatting strings, the function calls Writeconsole And so on API Function.

2 console subsystem

Windows system applications run on several subsystems respectively. Windows and consystemic is the two most commonly used subsystems. The graphic user interface runs on Windows subsystem, the console interface is running on consystemic subsystem. The application window of the graphic user interface is called by the application API functions are created, but the console interface of the console application does not require application creation, the system will automatically create it.

3Console read/write

UseWindows APIThe process of writing data to the console to obtain the input from the console is as follows:

◇ UseGetstdhandleFunction to obtain the standard input and output handle of the application Console (of course, this application is a console program with a console. When linking the console program, you need to select subsystemConsole, Link options:/Subsystem: Console).

◇ Use the standard output handle as a parameter to callWriteconsole APIWrite output.

◇ Use the standard input handle as a parameter to callReadconsole APIRead input.

Sample Code

MoreUsing LEs and character-mode support, See[1, 2].

[1]ProficientWindows APIFunctions, interfaces, and programming instances

[2] http://msdn.microsoft.com/en-us/library/ms682010%28VS.85%29.aspx

Related Article

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.