AngelFireMateo
asked on
printing a char in graphics mode
How can I print a character in graphics mode with the
outtextxy function? I'm doing the following:
#include <graphics.h>
#include <conio.h>
#include <iostream.h>
#include <stdlib.h>
#include <ctype.h>
void main()
{
int gdriver = DETECT, gmode;
int Errcode ;
char key;
initgraph(&gdriver,&gmode, "D:\\BORLA ND\\BORLAN DC\\BGI\\" ) ;
Errcode = graphresult();
if (Errcode != grOk)
{
cout<<"Graphics Error:"<< grapherrormsg(Errcode);
exit(1);
}
setcolor(15);
key=getch();
outtextxy(10,30,key);
}
How can I print key with this function?
Thanks in advance
AFM
outtextxy function? I'm doing the following:
#include <graphics.h>
#include <conio.h>
#include <iostream.h>
#include <stdlib.h>
#include <ctype.h>
void main()
{
int gdriver = DETECT, gmode;
int Errcode ;
char key;
initgraph(&gdriver,&gmode,
Errcode = graphresult();
if (Errcode != grOk)
{
cout<<"Graphics Error:"<< grapherrormsg(Errcode);
exit(1);
}
setcolor(15);
key=getch();
outtextxy(10,30,key);
}
How can I print key with this function?
Thanks in advance
AFM
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
it works well thanks
Barry
#include <graphics.h>
#include <conio.h>
#include <iostream.h>
#include <stdlib.h>
#include <ctype.h>
struct key_word
{
unsigned int key_code;
};
struct key_bytes
{
unsigned char ascii;
unsigned char scan_code;
};
union key_fields
{
struct key_word kw;
struct key_bytes kb;
};
union key_fields key;
void main()
{
int gdriver = DETECT, gmode;
int Errcode;
int c;
char msgbuf[80];
initgraph(&gdriver, &gmode, "D:\\BORLAND\\BORLANDC\\BG
Errcode = graphresult();
if (Errcode != grOk)
{
cout<<"Graphics Error:"<< grapherrormsg(Errcode);
exit(1);
}
setcolor(15);
key.kw.key_code = getch();
memset(msgbuf , '\0', 80);
msgbuf[0] = key.kb.ascii;
outtextxy(10, 30, msgbuf);
} // end main()