Chat LIVE With Programming Experts! There Are 23 Online Right Now...

Welcome to Dream.In.Code
Become a C++ Expert!

Join 244,310 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 862 people online right now. Registration is fast and FREE... Join Now!




[C++] How to remove a blinking caret!

 
Reply to this topicStart new topic

[C++] How to remove a blinking caret!, My example code. :)

Hyper
11 Nov, 2008 - 02:43 PM
Post #1

Banned
*****

Joined: 15 Oct, 2008
Posts: 2,129



Thanked: 87 times
Dream Kudos: 425
My Contributions
No blinking caret!!

#include <iostream>

using namespace std;

HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO CursoInfo;

int main() {

CursoInfo.dwSize = 1; /* The size of caret */
CursoInfo.bVisible = false; /* Caret visible? */
SetConsoleCursorInfo(hConsole, &CursoInfo);

SetConsoleTextAttribute(hConsole, 12);
cout << "Hi, how're you?";
cin.get();

return 0;
}


As you can clearly see, not much to it! smile.gif

It can be VERY useful when designing games in C++, where the caret is unneeded/wanted (makes graphical errors with ASCII art).

User is offlineProfile CardPM
+Quote Post


salindor
RE: [C++] How To Remove A Blinking Caret!
11 Nov, 2008 - 04:42 PM
Post #2

D.I.C Head
Group Icon

Joined: 10 Nov, 2006
Posts: 182



Thanked: 12 times
Dream Kudos: 50
My Contributions
Altough prolly not exactly what you were thinking...

cpp

#include <conio.h>
#include <ctype.h>

void main(){
// for (int i=0; i<60; i++)
// printf("\n");
/* Display message until key is pressed. */
while( !_kbhit() )
{
_putch(' ');

}

/* Use _getch to throw key away. */
printf( "\nKey struck was '%c'\n", _getch() );

}


I don't think this will work on anything but windows. I remember doing it with similar methods several years ago(without the _putch)...

Salindor
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic

Time is now: 7/4/09 07:24PM

Live C++ Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month