Thread: SetConsoleWindowInfo

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    44

    SetConsoleWindowInfo

    I wrote a really annoying program that goes something like this:
    Code:
    #include <time.h>
    #include <windows.h>
    #include <stdlib.h>
    
    int main()
    {
          time_t now;
          time(&now);
          srand(now);
          while(true)
          {
              Sleep(100);
              SMALL_RECT WinRect = {0, 0, rand() % 100 + 1, rand() % 70 + 1};
              SMALL_RECT* WinSize = &WinRect;
              SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), true, WinSize);
          }
          return 0;
    }
    I was wondering, is there a way to move the console window? All this does is resize.
    Check out all my dimensions:
    Height, width, and for a limited time only... Depth!
    -sb

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    There is not a specific console routine to do this, however, you can of course cheat.

    Code:
    #include <windows.h>
    
    int main()
    {
        HWND hWnd;
        RECT WinRect;
    
        SetConsoleTitle("Home");
        hWnd = FindWindow(NULL,
                          "Home");
    
        GetWindowRect(hWnd,
                      &WinRect);
    
        MoveWindow(hWnd,
                   0,
                   0,
                   WinRect.right - WinRect.left,
                   WinRect.bottom - WinRect.top,
                   TRUE);
    
        return 0;
    }
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    Registered User
    Join Date
    May 2002
    Posts
    66
    You can have console applications that uses MFC, which allows you to control the current window and do a lot of other things.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. SetConsoleWindowInfo
    By Supar in forum C++ Programming
    Replies: 1
    Last Post: 12-18-2002, 07:52 PM