settextjustify in C++

Here is a code I have written:
#include
#include
#include

void main ()
{
int gd,gm;
clrscr ();
detectgraph (&gd,&gm);
initgraph (&gd,&gm,"c:\tc\bgi");
outtext("


Welcome to the graphics mode!!!");
getch ();
cleardevice ();
settextstyle (3,0,2);
outtext("Experimenting with fonts......");
getch ();
cleardevice ();
setcolor (5);
outtext("Experimenting with fonts......");
getch ();
cleardevice ();
settextjustify (1,1);
outtext ("Justification of text........");
if (graphresult () == -11)
outtext ("Error.....");
getch ();
}

Now, when I run this code, the settextjustify function does not align the text in the center of the screen. I have also tried the enumetations for the center alignment but still this thing doesn't work. Please help!!!!

Comments

  • [color=Blue]settextjustify() aligns the text RELATIVE TO CURRENT PEN POSITION. It means two choices:

    1. You can use moveto() to set the pen position
    2. You can use outtextxy() instead of outtext()

    See RED: I set up the center of screen and changed all calls to outtext() to its equivalent, but with X,Y passed.[/color]
    [code]
    : #include
    : #include
    : #include
    :
    : void main ()
    : {
    : int gd,gm[color=Red],x,y[/color];
    : clrscr ();
    : detectgraph (&gd,&gm);
    : initgraph (&gd,&gm,"c:\tc\bgi");
    : outtext("


    Welcome to the graphics mode!!!");
    : getch ();
    : cleardevice ();
    : settextstyle (3,0,2);
    : outtext("Experimenting with fonts......");
    : getch ();
    : [color=Red]x=getmaxx () / 2;[/color]
    : [color=Red]y=getmaxy () / 2;[/color]
    : cleardevice ();
    : setcolor (5);
    : outtext("Experimenting with fonts......");
    : getch ();
    : cleardevice ();
    : settextjustify (1,1);
    : outtext[color=Red]xy[/color] ([color=Red]x,y,[/color]"Justification of text........");
    [color=Red]: settextjustify (0,1);
    : outtextxy (x,y,"-- settextjustify (0,1) --");
    : settextjustify (1,0);
    : outtextxy (x,y,"-- settextjustify (1,0) --");[/color]
    : if (graphresult () == -11)
    : outtext ("Error.....");
    : getch ();
    : }
    [/code]
  • Thanks!!! It has helped me a lot!!!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories