2 Replies - 3383 Views - Last Post: 11 October 2009 - 10:22 AM Rate Topic: -----

#1 poncho4all  Icon User is offline

  • D.I.C Head!
  • member icon

Reputation: 123
  • View blog
  • Posts: 1,405
  • Joined: 15-July 09

Blink after text with graphics

Posted 11 October 2009 - 07:21 AM

Well im trying to put a blinking line after the text like in every text editor.
But i cant see how to the one right now gets to far away from the text after a few letters.
#include<iostream>
#include"graphics.h"
using namespace std;

void lectura(int x,int y,char cadena[100]){
	int letra=0,i=0,cont=0,place=0,s=0;
	char temp[1];
	char blink[1];
	blink[0]='|';
	blink[1]='\0';
	while(!kbhit()){
		setcolor(WHITE);
		outtextxy(x,y,blink);		
		setcolor(BLACK);
		outtextxy(x,y,blink);
	}
	while(letra!=13){
		letra=getch(); 
		if(letra==13){
			cadena[i]='\x0';
			break;
		}else
			if(letra==8){
				--i;
				cadena[i]='\x0';
				cleardevice();
				setcolor(WHITE);
				outtextxy(x,y,cadena);
			}else{
				temp[0]=letra;
				temp[1]='\x0';
				setcolor(WHITE);
				cadena[i]=temp[0];
				i++;
				cadena[i]='\x0';
				outtextxy(x,y,cadena);
			}
			while(!kbhit()){
				(cadena[i-1]>='A'&&cadena[i-1]<='Z')?s=10:s=8;
				setcolor(WHITE);
				outtextxy(x+(i*s),y,blink);	
				delay(5);
				setcolor(BLACK);
				outtextxy(x+(i*s),y,blink);
			}
			outtextxy(x,y,cadena);
	}
}
int main(){
	int gd=DETECT, gm;
	char cadena[100];
	int mx,my;
	initgraph(&gd,&gm,"");
	while(!ismouseclick(WM_LBUTTONDOWN)){
		delay(1);
	}
	getmouseclick(WM_LBUTTONDOWN,mx,my);
	lectura(mx,my,cadena);
	outtextxy(mx,my,cadena);
	closegraph();
	cin.get();
	return 0;
}



Anyone knows a better way?

Is This A Good Question/Topic? 0
  • +

Replies To: Blink after text with graphics

#2 ccubed  Icon User is offline

  • It's That Guy
  • member icon

Reputation: 162
  • View blog
  • Posts: 1,409
  • Joined: 13-June 08

Re: Blink after text with graphics

Posted 11 October 2009 - 10:18 AM

There really isn't. The only way to get blinking text is using the ASCII escape sequences. And what do you mean it gets too far away?
Was This Post Helpful? 1
  • +
  • -

#3 poncho4all  Icon User is offline

  • D.I.C Head!
  • member icon

Reputation: 123
  • View blog
  • Posts: 1,405
  • Joined: 15-July 09

Re: Blink after text with graphics

Posted 11 October 2009 - 10:22 AM

Well for the first five six letters it is right where it should be beside the letter but after that it moves away like " " from the letter

[EDIT]NVM i didnt knew about the acsii sequence thank you sir

This post has been edited by poncho4all: 11 October 2009 - 10:24 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1