Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>_settextposition() set new text output position</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _settextposition()      Set new text output position

 #include   <graph.h>

 struct rccoord far _settextposition(row, column);
  short row;        New row position
  short column;          New column position

    _settextposition() moves the current text output position to (row,
    column). The row and column values are based on character locations
    displaced from the upper-left screen corner ( row 0, column 0).
    Succeeding text output using _outtext(), printf(), etc., proceeds
    from that position.

       Returns:     _settextposition() returns the previous text position
                    in an rccoord structure, defined in graph.h:

                    struct rccoord {
                       short row;  Row coordinate
                       short col;  Column coordinate
                       };

         Notes:     _settextposition() does not affect the current image
                    position, which is a separate location based on pixel
                    coordinates.  Use _setcliprgn() or _setviewport() for
                    images.

                    The row and column values are based on character
                    locations displaced from the upper-left screen corner
                    ( row 0, column 0).  The number of rows and columns
                    depend on the available display hardware and the
                    selected video mode. These values are accessible at
                    run time by examining the numtextrows and numtextcols
                    members of the videoconfig structure returned by
                    _getvideoconfig(). It is possible to convert from
                    image pixel coordinates to text coordinates (for
                    linking the locations of images and text) using
                    numxpixels and numypixels from _getvideoconfig(). See
                    example for _getviewcoord().

   Portability:     MS-DOS only, true MDPA, CGA, EGA, MCGA, or VGA video
                    compatibles

 -------------------------------- Example ---------------------------------

    This program writes text at a new logical origin in the center of the
    display.

           #include <conio.h>
           #include <graph.h>

           char text[80] = {"<-- Logical origin"};
           char xloc[10], yloc[10];

           main()
           {
              struct xycoord xy;
              struct videoconfig config;
              short pix_row, pix_col;

              _setvideomode( _MRES4COLOR );
              _getvideoconfig( &config );

              /* shift logical origin to center of screen  */
              _setlogorg( config.numxpixels/2-1, config.numypixels/2-1);

              /* reset text position to new logical origin */
              pix_col = config.numxpixels / config.numtextcols;
              pix_row = config.numypixels / config.numtextrows;
              _settextposition( (config.numypixels/2-1)/pix_row+1,
                                (config.numxpixels/2-1)/pix_col+1 );

              /* print location of logical origin */
              _outtext( text );

              while ( !kbhit() );
              _setvideomode( _DEFAULTMODE );
           }


See Also: _gettextposition() _outtext() _moveto() _getcurrentposition()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson