Hello there.
This a part of a program i am trying to make. I am trying to learn how to use graphics in a console C++ App.
I am using the Visual C++ 6 and whenever I try to run this code, I can never see any lines.
Code :
Basically, I am trying to change the console background to white and i am trying to draw a black line on it.
Can people please help me by helping me make this work?
When I run it, I cant see any graphics.
Please Help.
This a part of a program i am trying to make. I am trying to learn how to use graphics in a console C++ App.
I am using the Visual C++ 6 and whenever I try to run this code, I can never see any lines.
Code :
Code:
//This is my graphics experiment
#include <cstdio>
#include <cmath>
#include <windows.h>
#include <iostream>
using namespace std;
int main(void)
{
//Colour Declarations
COLORREF white = RGB(255,255,255);// White background
COLORREF black = RGB(0,0,0);
COLORREF lightblue = RGB(173,216,230);
int x = 0; // X coordinate
int y = 0; // Y coordinate
int r, g, b; // RGB values
SetConsoleTitle("Title Goes Here");
HWND hWnd = FindWindow(NULL, "Title Goes Here");
HDC hDC = GetDC(hWnd);
SetBkColor(hDC, white);
SetTextColor(hDC, black);
while (x != 50)
{
SetPixel(hDC, x, y, lightblue);
x = x + 1;
}
ReleaseDC(hWnd, hDC);
DeleteDC(hDC);
return 0;
}
Can people please help me by helping me make this work?
When I run it, I cant see any graphics.
Please Help.
Comment