Submitted by admin on Wed, 05/11/2016 - 12:08
1.File->New->Other...
2. C++ and UseVCL
3. Source code
#include <conio.h> #include <windows.h> #include <vcl.h> int main() { int number = 897; char str[3]; // Console window descriptor HWND Handle = GetConsoleWindow(); // Content descriptor HDC dc = GetDC(Handle); // Specifying new color using RGB format COLORREF color = RGB(0, 0, 255); HPEN PenHandle; HBRUSH BrushHandle; // Creating new pen with solid type and color = color PenHandle = CreatePen(PS_SOLID, 1, color); // Creating solid brush BrushHandle = CreateSolidBrush(clRed); SelectObject(dc, PenHandle); SelectObject(dc, BrushHandle); // Red rectangle with blue border Rectangle(dc, 130, 110, 180, 180); // Updating start position for drawing a line MoveToEx(dc, 20, 100, NULL); // Draw a blue line from start position to specified position LineTo(dc, 40, 200); // Converting number to string itoa(number,str,10); // Writing a string at the specified location TextOut(dc, 200 , 200 , str , 3); DeleteObject(BrushHandle); DeleteObject(PenHandle); getch(); ReleaseDC(Handle, dc); return 0; }
4. Result