• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            我住包子山

            this->blog.MoveTo("blog.baozishan.in")

            [基礎(chǔ)]Win32 Console Applications - Part 1. of 6

            Win32 Console Applications - Part 1.

            Hello World

            Okay, hands up, who here started out with something like this, possibly in another language, possibly on another OS, but whatever, with something like that. I'm willing to bet there are a good few people who can say "yes, that was me". You don't really want to see the source do you? Oh all right then.

            #include <iostream>
            using namespace std;
            
            int main()
            {
                cout << "Hello World!" << endl;
                return 0;
            }
            

            8 lines. Could be less, by why make things harder to read? This is really the great strength of a Windows Console Application, you really do not need to do much in order to make a working program. That is why I use consoles. If I want to test out a bit of non GUI code, and I don't have a suitable application I can use as a framework, I knock together a quick console application, and I'm sure just about every other Windows programmer does as well. The user interface only needs to be sophisticated enough to get the job done.

            Some of the other tutorials on the site demostrate powerful techniques, but do it in a Console App because that's all that was needed.

            Can you do anything else with a Console App? Of course, the answer is yes, you can, and these tutorials demostrate some of the things that can be done with a console. Believe it or not, a huge number of questions concerning consoles crop up in help forums every week, so people are interested. If you are, read on.

            ----------

            What is a Console? It is a Window, a special kind, yes, but it is a Window. You will frequently hear these things called "DOS boxes" because DOS had a character based UI, but this term is incorrect. There is no DOS under the NT cored WIndows operating systems, (NT, 2000, XP), and yet you can use a console. Why? Because it is a Window. (There are actually DOS emulators for these platforms - but this is a totally unrelated topic.)

            What makes a Console window special is that it is character based rather than pixel based. A normal window, like this browser window for example, (unless you're using a REALLY basic browser), is measured in pixels, each pixel is individually addressable and modifiable. With a character based medium, that is not the case, the smallest unit that can be addressed and thus modified is a character cell.

            A console's display area consist of rows and columns of character cells. It is a grid or two dimensional array or matrix of cells, all these terms are in use - they amount ot the same thing. Traditionally, the character cell at the top left is the origin or "home" position, and is designated (0,0) in an imaginary (x,y) grid. The character cell to it's immediate right is (1,0), the next (2,0) and so on. The cell just below (0,0) is (0,1), the one below that (0,2) and so on. On a typical console there are 80 cell positions across the screen, and 25 down, thus on such a console, the bottom right cell will be (79,24) remembering the grid is zero based. The little picture below shows graphically the cell numbers of the upper left portion of a larger screen or the entire grid of a 4x4 console of course.

            CellGrid

            Incidently, the reason for chosing 80x25 is historical. In the days before graphical terminals were widely available, people used character based terminals called "Visual Display Units", or VDU's. These typically had an 80x25 screen layout. I was one of those who used these beasts.

            ----------

            Each character cell can contain one and only one character. I'll illustrate an artifact of this below. I type 5 "w" characters, then on the line below, 5 "i" characters...

            wwwww
            iiiii

            ... notice the length of the lines. Assuming you are using a modern browser, you should see that the upper line is longer than the lower. Now I'll write a console app which does the same, here is the output...

            FixedFont

            ... as you see, since each cell can only hold a single character, the last "i" character is directly below the last "w". There can be no proportional spacing in a console with the default font, (it is possible to simulate a very crude form of proportional spacing if only a few letters are used - but forget it - it's not worth the hassle).

            Okay, so we've got a grid of cells, what is in a cell? Simply, a cell is another grid, each cell being 8 pixels wide and 12 high. The characters that make up the font must be represented within this grid including any spacing - that's right, the pixels of one cell lie directly adjacent to the pixels of the next. This is somewhat limiting, and accounts for the rather poor quality of the console font, but as we will see later, it does have some advantages. The pictures below show how the "w" and "i" characters are encoded into a cell.

            w Grid i Grid

            Notice the blank column on the right of the "w", this ensures that two adjacent "w" characters will have at least a single pixel space between them. If you look at the last picture, you will see that is the case. Also notice, the dot over the "i" does not go to the top of the cell, this ensures that any character on the line above an "i" that has a descender, an extension below the normal line, "y" for example, will still have at least a one pixel gap between the descender and a "high" character. Thus, normal characters are represented by 7x11 grids with a blank row at the top and a blank column on the right side.

            The pixels marked with a "X" in the pictures above are rendered in the foreground colour, those in the empty pixels positions, in the background colour. By default, the foreground is white, the background black. Later on in the tutorial, I will show you how to change these colours, within limits.

            ----------

            There is a one pixel wide gap around the outside edge of the consoles display area. This prevents the top, bottom and edge characters merging with the frame. You cannot write into this gap. Thus a console's display area is 2+(8x) pixels wide, where x is the number of character cells in a row, and 2+(12y) pixels high where y is the number of visible rows, (there may be more rows above or below the current view as determined by the position of the scroll bar).

            I'm afraid this first page has really been rather a lot of dry theory. A lot of what you can do with consoles assumes you understand this material though, so read it through, and if later on in this tutorial, you find something that sounds weird, try reading this page again!

            In the next part, I'll show you how to name your Console, obtain the consoles standard handles, move the cursor about, write blocks of characters and clear the screen.

            posted on 2006-07-20 22:39 Gohan 閱讀(466) 評(píng)論(1)  編輯 收藏 引用 所屬分類: C++

            Feedback

            # re: [基礎(chǔ)]Win32 Console Applications - Part 1. of 6 2006-07-20 22:40 Gohan

            來源于http://www.adrianxw.dk  回復(fù)  更多評(píng)論   

            蜜臀久久99精品久久久久久小说| 大伊人青草狠狠久久| 亚洲伊人久久综合影院| 狠狠色噜噜色狠狠狠综合久久| 亚洲精品高清国产一线久久| 久久精品国产影库免费看| 国产亚洲精午夜久久久久久| 久久热这里只有精品在线观看| 丰满少妇高潮惨叫久久久| 久久这里只有精品视频99| 久久久精品2019免费观看| 久久久久亚洲AV无码专区网站| 久久综合综合久久综合| 久久人人爽人人澡人人高潮AV| 日韩精品久久无码中文字幕| 精品久久久久久无码中文字幕| 亚洲狠狠婷婷综合久久久久| 狠狠色伊人久久精品综合网| 久久久久无码精品国产| 亚洲综合久久久| 久久久久国色AV免费观看| 久久精品国产精品国产精品污| 久久精品桃花综合| 久久国产成人| 91久久精品无码一区二区毛片| 麻豆一区二区99久久久久| 中文字幕乱码人妻无码久久| 香蕉久久AⅤ一区二区三区| 成人综合伊人五月婷久久| 人妻中文久久久久| 久久久久亚洲AV无码去区首| 秋霞久久国产精品电影院| 午夜不卡久久精品无码免费| 久久精品一本到99热免费| 香蕉99久久国产综合精品宅男自| 久久精品国产精品亜洲毛片| 伊人丁香狠狠色综合久久| 久久免费精品视频| 久久99国产精品一区二区| 69国产成人综合久久精品| 国产精品免费福利久久|