C++ :: Clear Screen In Console - Change Text Color In EXE
Dec 28, 2013How I can clear the whole screen in console...
And I'm using clrscr(); and its not working.
How i can change the text color in the .exe without using system function
How I can clear the whole screen in console...
And I'm using clrscr(); and its not working.
How i can change the text color in the .exe without using system function
I try to change the text color of console in C++. I know some commands like .
system("color fg");
But I want to change the color of only one line of console. Is this possible?
i am using c++v30.5 version i want red color text in in my output screen . i viewed various site but the result is 0 ,wat to do?
View 2 Replies View RelatedHow do i change color of text in the program more than once . rite now i use the code
system ("color 0c");//makes the color of the text red
cout <<"hey";
system ("color 02") //change color to green;
cout<<"only in green ";
it displays both the lines in green not the first in red and second in green.
I was trying to change the text and background color to :red blue
Is there a way to do this? is there a certain function? ...
I've tried this (without success):
ui->tableView->model()->setData(ui->tableView->model()->index(5, 5, QModelIndex()), QVariant(QColor(Qt::red)), Qt::DecorationRole);
I have a derived CComboBox class, where I tried to change text and background of edit from CComboBox, just like this:
Code:
HBRUSH CMyComboBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) {
HBRUSH hbr = CComboBox::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
//if(CTLCOLOR_EDIT == nCtlColor || CTLCOLOR_MSGBOX == nCtlColor) {
[Code] ......
but is not working if CComboBox has CBS_DROPDOWNLIST style ... is working only for CBS_DROPDOWN style ... why ?
I needed to change Default Text attributes (font and color) . So I wrote following code , UnicodeTextOut function. I called this function once in each 55ms to update the display screen. but I observed that my Screen used to become grey like a crash after sometime . If I use Minimize an Maximize window , the screen was restoring back for some time.
When I thought over the code , I got my mistake that CreateFont initialization should be done once in the program and probably outside the function.
void UnicodeTextOut(int x, int y, CString s, UINT justify,int GreyScaleFlag) {
HFONT hFontUnicode;
HFONT hfOld ;
hFontUnicode = CreateFont(16, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0, _T("Aerial"));
[Code] ....
Then I shifted the line hFontUnicode = CreateFont(16, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0, _T("Aerial")); in my screen class constructor and made hFontUnicode global .
This solved my problem as expected. Why a system crash after certain no of CreateFont calls ?
I have a one simple question :D. I want to output to the console some symbols. Let's say that i have a loop.
for(int i = 0; i < 10; i++) cou << "* ";
Then I want to output other symbols but I want to overwrite the previous symbols. I know I can use system("cls"); but it blinks if I try to output the same characters. For example if I have:
for(int i = 0; i < 10; i++) cou << "* ";
system("cls");
for(int i = 0; i < 10; i++) cou << "* ";
After I run this code the first loop outputs ten "*". Then there is a blink and there are again ten "*" shown. How can I avoid this blink?
Is there any way I can clear only a selected part of the screen? (I'm aware of system("cls"))
For example, when you enter a date, and is wrong, could it just errase that input and only say "Wrong try again" without errasing everything else you where doing?
In this case, a function that only errases what is in the while
while(not wrong)
{
cout<<"DIA: ";
cin>>obj.dia;
cout<<"MES: ";
cin>>obj.mes;
cout<<"ANIO: ";
cin>>obj.anio;
}
PS: Also, is there any whay in which you can ask the user to enter the date DD/MM/YYY?
I checked through the net and most of the solution like clrcr(); is not working for microsoft visual 2010. SO i was wondering for those who was using the same ver of c++ as me how do you clear the screen?
View 5 Replies View RelatedI am working on a simple calculator in C++ .... All works fine with the calculator up until the requirement for the user to input "do you want to go again y/n" .... What i want to happen is the screen to clear down and reloop to the enter name part....but i can't get it to do that
Program Description: To write and develop a programme where a user can input a cost or price of something before VAT our program must then process the input number and must output the price with the original value plus VAT
#include <iostream>// I must use this to start my programming
#include <string> // I have added this for the extension task so the user has to input their name
#include <iomanip> // this is to manipulate the text
#include <stdlib.h>
using namespace std; // using the "using namespace std" shows that i will be using standard text throughout this programme
[Code] .....
For my C programming module, I've been asked to create a program which is basically a ten question mathematics quiz or test if you like. Below is a copy and paste of my current, working program.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main () {
[Code]....
I am also trying to include into my program; If the user achieves 4 or less marks in the test, they are asked if they would like to repeat the test (have a second chance).
I have been asked by my Lecturer to ask the Question; "Would you like to try again" and the response is 'Y' for yes, 'N' for no. Would this be shown by:
char Y = Y;
char N = N;
printf("Would you like another go?");
scanf(%d%, &Y, &N);
And finally; If the user would like another go, then I am trying to include the code that clears the screen and then reloads the program?
What code is used to clear the screen and no clue what code is written to refresh or reload the program. I assume it's a loop statement or some sort.
I'm creating a simpe program using Qt/C++ and MySQL.
I am trying to change row color of QTableView, but it has to change depending on value on the database.
For example I have QTableview wich is conected to mysql database:
this->model1 = new QSqlQueryModel();
model1->setQuery("SELECT ID, value, Name FROM DB_Table ");
ui->tableView->setModel(model1);
Now I want to change row color to red if the value = 1 .
I searched alot and found this:My link But dont understand how to use these clases in my code, i'm cind a new in programing.
I've changed the listbox foreground color to default application background color so I get: [URL] which is fine but when I select any element I get white background/foreground(or whatever it is): [URL]
How can I change this so I will have the same default color in the second case?
It is a windows store app
Xaml code(listbox is at the end):
<Page
x:Name="pageRoot"
x:Class="ExchangeRate2.MainPage"
DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
[Code]....
void SetupPieces() {
pieces[0] = Piece(Bads(0,2), Bads(0,1), Bads(0,0), Bads(0,-1));
pieces[1] = Piece(Bads(0,0), Bads(0,1), Bads(1,0), Bads(1,1));
pieces[2] = Piece(Bads(-1,0), Bads(0,0), Bads(1,0), Bads(0,-1));
pieces[3] = Piece(Bads(-1,1), Bads(-1,0), Bads(0,0), Bads(0,-1));
pieces[4] = Piece(Bads(1,1), Bads(1,0), Bads(0,0), Bads(0,-1));
pieces[5] = Piece(Bads(1,1), Bads(1,0), Bads(0,0), Bads(-1,0));
pieces[6] = Piece(Bads(-1,1), Bads(1,0), Bads(0,0), Bads(-1,0));
}
Okay, I have a form and I have a tab control thing. On the second tab, I have a button which is supposed to turn the background green.
So, I have this:
#pragma endregion
private: System::Void greenButton_Click(System::Object^ sender, System::EventArgs^ e) {
this ->BackColor = System::Drawing::Color::Green;
But clearly that just turns the FORMS background green. How can I change the TAB background to green.
I am working on this project where I need to update an edit box every couple of seconds with a status and based on the status I need to change the color of the background to a particular color.I am able to update the edit box with the status but is clueless on how to update background color.I have read some info on line about this but is confused.This edit box is on a tab in a dialog. Also, on this tab is a Groupable List Ctrl.
View 2 Replies View RelatedI'm creating a simple game with my friend that runs in the Terminal/Command Prompt window, but I would like to know how to change the color of the entire window via C++. I'm on a Mac, but my friend is on a Windows, so I need to a solution that is portable, if possible.
I've tried using a printf statement to change the color, but it only changes the background color of the text being printed.
I had a program (on console) that uses a third-part software to draw some graphs. In order to hold the graphs on the screen, I used cin.get(); and that worked.
Now I created a GUI with Qt. The code remains generally the same. The code continues to call the software to draw graphs (during drawing graphs, there is a console opened automatically). Butcin.get(); in the code cannot hold the graphs on screen anymore. The graphs appear and disappear immediately.
Alright so I'm in a computer programming class and I was given the following problem..Write a problem that takes an integer value and multiplies each of the digits together. 4 digit numbers only.
IE; What number do you want to process? 2684
Starting number 2684
End result 384
I know how to start the begging of the program, but i dont understand how to have it to where you can type in all four digits and then it will multiply each number by the other. Also, what are some ways to change the color scheme of the program? I know how it works using CMD, but in Visual C++ its totally different aha.
I wanted to change the Backcolor of subitem to Red, while inserting data in Listview from List<string> result. After executing the below code Data from List<string> are well placed below their respective column in listview, only their Subitem Color doesn't change.
Here my Code
//Here result is List<string>
for (int i = 0; i < result.Count; i += 5) {
ListViewItem item = new ListViewItem();
item.Text = result[i].ToString();
for (int j = i + 1; j < i + 5; j++) {
item.SubItems.Add(result[j].ToString());
[Code] ....
Here is my code:
#include <graphics.h>
#include <stdio.h>
#include <conio.h>
int main() {
int gdriver = DETECT, gmode, errorcode,i;
initgraph(&gdriver, &gmode, "c:cgi");
errorcode = graphresult();
[Code] ....
Here is what I did,
Code:
oldHook = ::SetWindowsHookEx(WH_CALLWNDPROCRET, CallWndRetProc, NULL, ::GetCurrentThreadId());
MessageBox(...);
UnhookWindowsHookEx(oldHook);
Then within the callback function CallWndRetProc, I tried to change the background color of the dialog,
Code:
PAINTSTRUCT ps;
HDC hdc = BeginPaint(msg->hwnd, &ps);
::SetBkColor(hdc, RGB(255, 0, 0));
EndPaint(msg->hwnd, &ps);
But it doesn't change the background color of the dialog. I wonder what is the right way to do that?
im making a menu system to change the color of pixels in a gravity engine i made. the engine works fine, and the menu colors the particles, but will only ever turn them to red, no matter what color i tell it to change it to.
bool running = true;
bool colorChosen = false;
Uint32 particleColor;
Uint32 randomColor;
[Code]....
I know how to change the back color of text in th ListView for all the View, but if I only want to change the back color of one cell i don`t find any way. Is it possible?
View 1 Replies View Related