C Language Console window graphical interface programming five functions to control text movement

Source: Internet
Author: User
Tags functions printf

Controlling the movement of text is a very important function of the interface programming of the console window, we can realize the scrolling of the interface with this function. Here's a function that controls the movement of text, as follows:

BOOL Scrollconsolescreenbuffer (             //text move function    
    HANDLE hconsoleoutput,                  //handle    
    const SMALL_RECT * Lpscrollrectangle,    //move Zone    
    const small_rect *lpcliprectangle,      //crop area, if NULL, will represent the entire screen buffer    
    COORD Dwdestinationorigin,              //moving to the position, this point becomes the    
    padding character of the const char_info *lpfill                 //vacated region of the upper left vertex of the moving region    
;

Let's look at a sample program that moves the text as follows

#include <stdio.h> #include <conio.h> #include <Windows.h> #include <stdlib.h>    int main () {HANDLE handle_out = GetStdHandle (Std_output_handle);        Obtain the standard output device handle Console_screen_buffer_info csbi;      Defines the window buffer information structure body small_rect scroll;     Define Mobile Area COORD pos = {0, 5};       Moving position char_info Chfill;  Defines the fill character getconsolescreenbufferinfo (handle_out, &AMP;CSBI);    
    Get the window buffer information//define the various parameters and attributes of the fill character ChFill.Char.AsciiChar = ';    
    Chfill.attributes = csbi.wattributes;    
    Output text printf ("00000000000000000000000000000\n");    
    printf ("11111111111111111111111111111\n");    
    printf ("22222222222222222222222222222\n");    
    printf ("33333333333333333333333333333\n"); Determine the area scroll.    
    left = 1; Scroll.    
    top = 1; Scroll.    
    right = 10; Scroll.    
    Bottom = 2; Scrollconsolescreenbuffer (Handle_out, &scroll, NULL, POS, &cHfill);    
Move text return 0; }

In the sample program above, the clipping area is the screen buffer of the entire console window, and now if we set the clipping area to be the same as the moving region, that is, the third parameter of the Scrollconsolescreenbuffer function is changed to &scroll, So what's the result?

This column more highlights: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/C/

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.