Thread: how do i print a colored rectangle?!?!

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    4

    how do i print a colored rectangle?!?!

    i want to print a big blue rectangle let's say 25* 25
    so what would be the function and the header file?

    furthermore, i want to print a colored square on the size of the cursor (1*1) lets say the color is green for example

    what about a colored text?

    plz do send examples
    thanks in advance

    ---------------------------------------------------
    MSVC++ 6.0

    best regards

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    If you're doing it on the console, something along the lines of -

    Code:
    #include <iostream>
    #include <windows.h>
    using namespace std; 
    
    
    
    int main() {
    	
    	HANDLE h;
    	h=GetStdHandle(STD_OUTPUT_HANDLE);
    	SetConsoleTextAttribute(h,BACKGROUND_BLUE);
    	COORD start={0,0};
    	COORD t;
    	COORD end = {5,5};
    	
    	for(int i=start.X;i<end.X;++i)
    		for(int j=start.Y;j<end.Y;++j)
    		{
    			t.X=i;
    			t.Y=j;
    			SetConsoleCursorPosition(h,t);
    			cout << ' ';
    		}
    
    	return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. merging linked lists
    By scwizzo in forum C++ Programming
    Replies: 15
    Last Post: 09-14-2008, 05:07 PM
  2. Personal Program that is making me go wtf?
    By Submeg in forum C Programming
    Replies: 20
    Last Post: 06-27-2006, 12:13 AM
  3. Scope And Parameter Passing
    By djwicks in forum C Programming
    Replies: 6
    Last Post: 03-28-2005, 08:26 PM
  4. What kind of programs should I start writing?
    By Macabre in forum C++ Programming
    Replies: 23
    Last Post: 04-12-2003, 08:13 PM
  5. Help With pointers in classes.
    By indigo0086 in forum C++ Programming
    Replies: 12
    Last Post: 10-10-2002, 02:03 PM