How to blink a text?

Page 1 of 1

6 Replies - 4337 Views - Last Post: 22 August 2012 - 09:43 AM Rate Topic: -----

#1 SHENGTON  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 112
  • Joined: 10-October 08

How to blink a text?

Posted 24 November 2010 - 09:01 PM

Hello, good morning. :)

I think this code won't work to blink the text that I type in printf.

textattr(128 + 10);
cprintf("This is blinking text\n");


Can someone help me to blink the text? I'm using Borland C++.
Is This A Good Question/Topic? 0
  • +

Replies To: How to blink a text?

#2 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 841
  • View blog
  • Posts: 2,472
  • Joined: 20-March 10

Re: How to blink a text?

Posted 25 November 2010 - 02:42 PM

textattr is Turbo C++ code

one example to blink text

#include <conio.h>
#include <iostream>
#include <windows.h>
using namespace std;

void blink(int);

int main()
{

    for (;;)/>
    {

        blink(FOREGROUND_RED);
        Sleep(500);
        blink(0);
        Sleep(500);
    }
    _getch();
    return 0;
}

void blink(int color)
{
    system("CLS");
    HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute( handle, color );
    cout<< " Hello ";
}



but there are other ways to do this.
Was This Post Helpful? 0
  • +
  • -

#3 ExoticSpliff  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 22-August 12

Re: How to blink a text?

Posted 22 August 2012 - 09:00 AM

Quote

Heres another example, by the way I am sure this question is late lol


//ExoticSpliff
#include <conio.h>
#include <iostream>
#include <windows.h>
#include <string>

void nictate(int);

void ClearConsole(void);

signed int ChillConsole(std::string chill);

int main() {
	for (;;)/> {
		nictate(0xf); //0xf = 15 = White. Either (or) one could have written 15 or hexadecimal 0xf 
		Sleep(1000);
		nictate(0);
        Sleep(1000);
	}
	ChillConsole("Chill"); //Pretty Cool, my own Command LOL!
}

signed int ChillConsole(std::string chill = (" ")) {
	while(true) {
		std::cin>>chill;
		if (chill == ("chill") || chill == ("CHILL") || chill == ("Chill") || chill == ("CHiLL")) {
			std::cin.sync(), std::cin.ignore(), std::cin.clear();
		return 0;
		} else { return 1; }
	}
	return false;
}

void ClearConsole(void) {
		DWORD n, size;
		COORD coord = {0};
		CONSOLE_SCREEN_BUFFER_INFO csbi;
		HANDLE h = GetStdHandle (STD_OUTPUT_HANDLE);
		GetConsoleScreenBufferInfo (h, &csbi);
		size = csbi.dwSize.X * csbi.dwSize.Y;
		FillConsoleOutputCharacter (h, TEXT(' '), size, coord, &n);
		GetConsoleScreenBufferInfo (h, &csbi);
		FillConsoleOutputAttribute (h, csbi.wAttributes, size, coord, &n);
		SetConsoleCursorPosition (h, coord);
}

void nictate(int color) {
	ClearConsole();
	HANDLE text = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleTextAttribute(text, color);
	std::printf("By: Exotic Spliff"); 
}


Was This Post Helpful? 0
  • +
  • -

#4 aresh  Icon User is offline

  • It's a 16-Bit World!
  • member icon

Reputation: 273
  • View blog
  • Posts: 4,176
  • Joined: 08-January 12

Re: How to blink a text?

Posted 22 August 2012 - 09:24 AM

Wow, thank you for necro-ing this two year old thread.
Was This Post Helpful? 0
  • +
  • -

#5 ExoticSpliff  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 22-August 12

Re: How to blink a text?

Posted 22 August 2012 - 09:39 AM

Quote

Lol and I come back and notice a reply, finished my third blunt gotta repost my code, it seems kind icky,


//Two year old post your right LOL
//ExoticSpliff
#include <iostream>
#include <windows.h>
#include <string>

void nictate(int);
void ClearConsole(int);
signed int ChillConsole(std::string chill);

int main() {
	for (;;)/> {
		nictate(0xf); //0xf = 15 = White. Either (or) one could have written 15 or hexadecimal 0xf 
		Sleep(1000);
		nictate(0);
        Sleep(1000);
	}
	ChillConsole("Chill");
}

signed int ChillConsole(std::string chill) {
	while(true) {
		std::cin>>chill;
		if (chill == ("chill") || chill == ("CHILL") || chill == ("Chill") || chill == ("CHiLL")) {
			std::cin.sync(), std::cin.ignore(), std::cin.clear();
		return 0;
		} else return 1;
	}
	return false;
}

void ClearConsole(int z) {
	COORD coord = {z};
	DWORD n, size;
	CONSOLE_SCREEN_BUFFER_INFO csbi;
	HANDLE h = GetStdHandle (STD_OUTPUT_HANDLE);
	GetConsoleScreenBufferInfo (h, &csbi);
	size = csbi.dwSize.X * csbi.dwSize.Y;
	FillConsoleOutputCharacter (h, TEXT(' '), size, coord, &n);
	GetConsoleScreenBufferInfo (h, &csbi);
	FillConsoleOutputAttribute (h, csbi.wAttributes, size, coord, &n);
	SetConsoleCursorPosition (h, coord);
}

void nictate(int color) {
	ClearConsole(0);
	HANDLE text = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleTextAttribute(text, color);
	std::printf("Test"); 
}


Was This Post Helpful? 0
  • +
  • -

#6 aresh  Icon User is offline

  • It's a 16-Bit World!
  • member icon

Reputation: 273
  • View blog
  • Posts: 4,176
  • Joined: 08-January 12

Re: How to blink a text?

Posted 22 August 2012 - 09:42 AM

Even then, this code will not be acceptable to poster, since he mentioned he uses TC++, which does not support std::string for your ChilliConsole. Didn't actually read your code, but that is a glaring error.
Was This Post Helpful? 0
  • +
  • -

#7 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6111
  • View blog
  • Posts: 23,671
  • Joined: 23-August 08

Re: How to blink a text?

Posted 22 August 2012 - 09:43 AM

Closed.

ExoticSpliff, you're not starting out well.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1