Skocz do zawartości

Recommended Posts

Napisano

Witam.
Czy wie ktoś może jak uzyskać kolory w konsoli (DOS), gdzieś znalazlem ale do Borlanda, lub Visuala... a ja chce cos standardowego... Sam uzywam Dev-C++.

Jesli ktos wie jak to zrobic to z gory dziekuje.

  • 2 weeks later...
  • 1 month later...
  • 1 month later...
  • 3 weeks later...
Napisano

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);

cool :D znasz wiecej?? 8) moze na tlo albo rysowanie kola jak w pascalu chyba ;] pogrubienie, kursywa , czcionka rozmiar itp? :) 

FOREGROUND_RED // czerwony
FOREGROUND_GREEN // zielony? :>

Napisano

W konsoli nie ma pogrubienia ani kursywy.
konsola to jets jak DOS w wersji Winows;)
w konsoli nei da sie rysowac zadnych obiektów
w DOSowych programach inicjowlao sie tryb graficzny zeby cos przedstawic graficznie :D
Wiec trzeba w konsoli wyywloac takowy typ graficzny (p za pomoca OpenGL :D )
Ogolne mowiac w konsoli nie porysujecie sobei kółek anie lini

Napisano

Ja się nie załamuję:) i podjąłem się szukania. Odpowiedź była blisko. Tera zobaczę czy to zadziała.

// Borland C++ - (C) Copyright 1991 by Borland International

/* VCIRC.CPP--Example from Getting Started */

// A Circle class derived from Point

#include <graphics.h> // graphics library declarations
#include "vpoint.h" // Location and Point class declarations
#include <conio.h> // for getch() function

// link with vpoint.obj and graphics.lib

class Circle : public Point { // derived from class Point
// and ultimately from class Location
int Radius; // private by default

public:
Circle(int InitX, int InitY, int InitRadius);
void Show(void);
void Hide(void);
void Expand(int ExpandBy);
void Contract(int ContractBy);
};

// Circle constructor calls base Point constructor first
Circle::Circle(int InitX, int InitY, int InitRadius) : Point(InitX,InitY)
{
Radius = InitRadius;
};

void Circle::Show()
{
Visible = true;
circle(X, Y, Radius); // draw the circle using BGI function
}

void Circle::Hide()
{
if (!Visible) return; // no need to hide
unsigned int TempColor; // to save current color
TempColor = getcolor(); // set to current color
setcolor(getbkcolor()); // set drawing color to background
Visible = false;
circle(X, Y, Radius); // draw in background color to erase
setcolor(TempColor); // set color back to current color
};

void Circle::Expand(int ExpandBy)
{
Boolean vis = Visible; // is current circle visible?
if (vis) Hide(); // if so, hide it
Radius += ExpandBy; // expand radius
if (Radius < 0) // avoid negative radius
Radius = 0;
if (vis) Show(); // draw new circle if previously visible
};

inline void Circle::Contract(int ContractBy)
{
Expand(-ContractBy); // redraws with (Radius - ContractBy)
};

main() // test the functions
{
// initialize the graphics system
int graphdriver = DETECT, graphmode;
initgraph(&graphdriver, &graphmode, "..\\bgi");

Circle MyCircle(50, 100, 25); // declare a circle object
MyCircle.Show(); // show it
getch(); // wait for keypress
MyCircle.MoveTo(100, 125); // move the circle (tests hide
// and show also)
getch();
MyCircle.Expand(25); // make it bigger
getch();
MyCircle.Contract(35); // make it smaller
getch();
closegraph();
return 0;
}

Napisano

NO widzisz. Bo tamto to jest grafika BGI stworzona przez Borlanda i tam sie inicjuje tryb graficzny bo to sa programt pod DOS. A konsola to nie program DOSowy

  • 6 months later...
Napisano

jakby ktos jeswzcze potrzebowal kiedys kolorowania textu itp w konsolce to w razie czego zamieszczam tu pełną odpowiedz w kodzie :D:

#include <windows.h>
#include <iostream.h>
#include <stdlib.h>

int main()
{
    HANDLE hOut;

    hOut = GetStdHandle(STD_OUTPUT_HANDLE);

    SetConsoleTextAttribute(hOut,
                            BACKGROUND_RED);
    cout << "This text is red." << flush << endl;

    SetConsoleTextAttribute(hOut,
                            FOREGROUND_GREEN);
    cout << "This text is green." << endl;

    SetConsoleTextAttribute(hOut,
                            FOREGROUND_BLUE);
    cout << "This text is blue." << endl;
    system("PAUSE");
    return 0;
}
Napisano

thnx. wielkie :D
dawno mnie tu nie było zalogowanego... dawno nie pisałem ale ci±gle czytałem :)

PS. Pamiętam jeszcze w asemblerze, jeden bajt na literkę, drugi na atrybuty... :) 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gość
Odpowiedz...

×   Wkleiłeś zawartość bez formatowania.   Usuń formatowanie

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Utwórz nowe...